@clickhouse/client-common 0.3.1 → 0.100.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +14 -0
- package/dist/clickhouse_types.d.ts +59 -1
- package/dist/clickhouse_types.js +27 -0
- package/dist/clickhouse_types.js.map +1 -1
- package/dist/client.d.ts +126 -95
- package/dist/client.js +119 -76
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +173 -0
- package/dist/config.js +309 -0
- package/dist/config.js.map +1 -0
- package/dist/connection.d.ts +44 -13
- package/dist/connection.js.map +1 -1
- package/dist/data_formatter/format_query_params.d.ts +11 -1
- package/dist/data_formatter/format_query_params.js +74 -13
- package/dist/data_formatter/format_query_params.js.map +1 -1
- package/dist/data_formatter/format_query_settings.js +1 -2
- package/dist/data_formatter/format_query_settings.js.map +1 -1
- package/dist/data_formatter/formatter.d.ts +32 -14
- package/dist/data_formatter/formatter.js +27 -46
- package/dist/data_formatter/formatter.js.map +1 -1
- package/dist/data_formatter/index.d.ts +1 -1
- package/dist/data_formatter/index.js +2 -1
- package/dist/data_formatter/index.js.map +1 -1
- package/dist/error/error.d.ts +20 -0
- package/dist/error/error.js +69 -0
- package/dist/error/error.js.map +1 -0
- package/dist/error/index.d.ts +1 -1
- package/dist/error/index.js +1 -1
- package/dist/error/index.js.map +1 -1
- package/dist/index.d.ts +18 -12
- package/dist/index.js +35 -12
- package/dist/index.js.map +1 -1
- package/dist/logger.js +8 -8
- package/dist/logger.js.map +1 -1
- package/dist/parse/column_types.d.ts +127 -0
- package/dist/parse/column_types.js +540 -0
- package/dist/parse/column_types.js.map +1 -0
- package/dist/parse/index.d.ts +2 -0
- package/dist/parse/index.js +19 -0
- package/dist/parse/index.js.map +1 -0
- package/dist/parse/json_handling.d.ts +19 -0
- package/dist/parse/json_handling.js +8 -0
- package/dist/parse/json_handling.js.map +1 -0
- package/dist/result.d.ts +52 -8
- package/dist/result.js.map +1 -1
- package/dist/settings.d.ts +38 -2
- package/dist/settings.js.map +1 -1
- package/dist/ts_utils.d.ts +4 -0
- package/dist/ts_utils.js +3 -0
- package/dist/ts_utils.js.map +1 -0
- package/dist/utils/connection.d.ts +11 -3
- package/dist/utils/connection.js +19 -7
- package/dist/utils/connection.js.map +1 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/sleep.d.ts +1 -0
- package/dist/utils/sleep.js +9 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/stream.d.ts +15 -0
- package/dist/utils/stream.js +50 -0
- package/dist/utils/stream.js.map +1 -0
- package/dist/utils/url.d.ts +5 -4
- package/dist/utils/url.js +22 -13
- package/dist/utils/url.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +6 -2
- package/dist/error/parse_error.d.ts +0 -12
- package/dist/error/parse_error.js +0 -41
- package/dist/error/parse_error.js.map +0 -1
- package/dist/utils/permutations.d.ts +0 -1
- package/dist/utils/permutations.js +0 -12
- package/dist/utils/permutations.js.map +0 -1
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
export declare class ColumnTypeParseError extends Error {
|
|
2
|
+
readonly args: Record<string, unknown>;
|
|
3
|
+
constructor(message: string, args?: Record<string, unknown>);
|
|
4
|
+
}
|
|
5
|
+
export declare const SimpleColumnTypes: readonly ["Bool", "UInt8", "Int8", "UInt16", "Int16", "UInt32", "Int32", "UInt64", "Int64", "UInt128", "Int128", "UInt256", "Int256", "Float32", "Float64", "String", "UUID", "Date", "Date32", "IPv4", "IPv6"];
|
|
6
|
+
export type SimpleColumnType = (typeof SimpleColumnTypes)[number];
|
|
7
|
+
export interface ParsedColumnSimple {
|
|
8
|
+
type: 'Simple';
|
|
9
|
+
/** Without LowCardinality and Nullable. For example:
|
|
10
|
+
* * UInt8 -> UInt8
|
|
11
|
+
* * LowCardinality(Nullable(String)) -> String */
|
|
12
|
+
columnType: SimpleColumnType;
|
|
13
|
+
/** The original type before parsing. */
|
|
14
|
+
sourceType: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ParsedColumnFixedString {
|
|
17
|
+
type: 'FixedString';
|
|
18
|
+
sizeBytes: number;
|
|
19
|
+
sourceType: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ParsedColumnDateTime {
|
|
22
|
+
type: 'DateTime';
|
|
23
|
+
timezone: string | null;
|
|
24
|
+
sourceType: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ParsedColumnDateTime64 {
|
|
27
|
+
type: 'DateTime64';
|
|
28
|
+
timezone: string | null;
|
|
29
|
+
/** Valid range: [0 : 9] */
|
|
30
|
+
precision: number;
|
|
31
|
+
sourceType: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ParsedColumnEnum {
|
|
34
|
+
type: 'Enum';
|
|
35
|
+
/** Index to name */
|
|
36
|
+
values: Record<number, string>;
|
|
37
|
+
/** UInt8 or UInt16 */
|
|
38
|
+
intSize: 8 | 16;
|
|
39
|
+
sourceType: string;
|
|
40
|
+
}
|
|
41
|
+
/** Int size for Decimal depends on the Precision
|
|
42
|
+
* * 32 bits for precision < 10
|
|
43
|
+
* * 64 bits for precision < 19
|
|
44
|
+
* * 128 bits for precision < 39
|
|
45
|
+
* * 256 bits for precision >= 39
|
|
46
|
+
*/
|
|
47
|
+
export interface DecimalParams {
|
|
48
|
+
precision: number;
|
|
49
|
+
scale: number;
|
|
50
|
+
intSize: 32 | 64 | 128 | 256;
|
|
51
|
+
}
|
|
52
|
+
export interface ParsedColumnDecimal {
|
|
53
|
+
type: 'Decimal';
|
|
54
|
+
params: DecimalParams;
|
|
55
|
+
sourceType: string;
|
|
56
|
+
}
|
|
57
|
+
/** Tuple, Array or Map itself cannot be Nullable */
|
|
58
|
+
export interface ParsedColumnNullable {
|
|
59
|
+
type: 'Nullable';
|
|
60
|
+
value: ParsedColumnSimple | ParsedColumnEnum | ParsedColumnDecimal | ParsedColumnFixedString | ParsedColumnDateTime | ParsedColumnDateTime64;
|
|
61
|
+
sourceType: string;
|
|
62
|
+
}
|
|
63
|
+
/** Array cannot be Nullable or LowCardinality, but its value type can be.
|
|
64
|
+
* Arrays can be multidimensional, e.g. Array(Array(Array(T))).
|
|
65
|
+
* Arrays are allowed to have a Map as the value type.
|
|
66
|
+
*/
|
|
67
|
+
export interface ParsedColumnArray {
|
|
68
|
+
type: 'Array';
|
|
69
|
+
value: ParsedColumnNullable | ParsedColumnSimple | ParsedColumnFixedString | ParsedColumnDecimal | ParsedColumnEnum | ParsedColumnMap | ParsedColumnDateTime | ParsedColumnDateTime64 | ParsedColumnTuple;
|
|
70
|
+
/** Array(T) = 1 dimension, Array(Array(T)) = 2, etc. */
|
|
71
|
+
dimensions: number;
|
|
72
|
+
sourceType: string;
|
|
73
|
+
}
|
|
74
|
+
/** @see https://clickhouse.com/docs/en/sql-reference/data-types/map */
|
|
75
|
+
export interface ParsedColumnMap {
|
|
76
|
+
type: 'Map';
|
|
77
|
+
/** Possible key types:
|
|
78
|
+
* - String, Integer, UUID, Date, Date32, etc ({@link ParsedColumnSimple})
|
|
79
|
+
* - FixedString
|
|
80
|
+
* - DateTime
|
|
81
|
+
* - Enum
|
|
82
|
+
*/
|
|
83
|
+
key: ParsedColumnSimple | ParsedColumnFixedString | ParsedColumnEnum | ParsedColumnDateTime;
|
|
84
|
+
/** Value types are arbitrary, including Map, Array, and Tuple. */
|
|
85
|
+
value: ParsedColumnType;
|
|
86
|
+
sourceType: string;
|
|
87
|
+
}
|
|
88
|
+
export interface ParsedColumnTuple {
|
|
89
|
+
type: 'Tuple';
|
|
90
|
+
/** Element types are arbitrary, including Map, Array, and Tuple. */
|
|
91
|
+
elements: ParsedColumnType[];
|
|
92
|
+
sourceType: string;
|
|
93
|
+
}
|
|
94
|
+
export type ParsedColumnType = ParsedColumnSimple | ParsedColumnEnum | ParsedColumnFixedString | ParsedColumnNullable | ParsedColumnDecimal | ParsedColumnDateTime | ParsedColumnDateTime64 | ParsedColumnArray | ParsedColumnTuple | ParsedColumnMap;
|
|
95
|
+
/**
|
|
96
|
+
* @experimental - incomplete, unstable API;
|
|
97
|
+
* originally intended to be used for RowBinary/Native header parsing internally.
|
|
98
|
+
* Currently unsupported source types:
|
|
99
|
+
* * Geo
|
|
100
|
+
* * (Simple)AggregateFunction
|
|
101
|
+
* * Nested
|
|
102
|
+
* * Old/new JSON
|
|
103
|
+
* * Dynamic
|
|
104
|
+
* * Variant
|
|
105
|
+
*/
|
|
106
|
+
export declare function parseColumnType(sourceType: string): ParsedColumnType;
|
|
107
|
+
export declare function parseDecimalType({ columnType, sourceType, }: ParseColumnTypeParams): ParsedColumnDecimal;
|
|
108
|
+
export declare function parseEnumType({ columnType, sourceType, }: ParseColumnTypeParams): ParsedColumnEnum;
|
|
109
|
+
export declare function parseMapType({ columnType, sourceType, }: ParseColumnTypeParams): ParsedColumnMap;
|
|
110
|
+
export declare function parseTupleType({ columnType, sourceType, }: ParseColumnTypeParams): ParsedColumnTuple;
|
|
111
|
+
export declare function parseArrayType({ columnType, sourceType, }: ParseColumnTypeParams): ParsedColumnArray;
|
|
112
|
+
export declare function parseDateTimeType({ columnType, sourceType, }: ParseColumnTypeParams): ParsedColumnDateTime;
|
|
113
|
+
export declare function parseDateTime64Type({ columnType, sourceType, }: ParseColumnTypeParams): ParsedColumnDateTime64;
|
|
114
|
+
export declare function parseFixedStringType({ columnType, sourceType, }: ParseColumnTypeParams): ParsedColumnFixedString;
|
|
115
|
+
export declare function asNullableType(value: ParsedColumnType, sourceType: string): ParsedColumnNullable;
|
|
116
|
+
/** Used for Map key/value types and Tuple elements.
|
|
117
|
+
* * `String, UInt8` results in [`String`, `UInt8`].
|
|
118
|
+
* * `String, UInt8, Array(String)` results in [`String`, `UInt8`, `Array(String)`].
|
|
119
|
+
* * Throws if parsed values are below the required minimum. */
|
|
120
|
+
export declare function getElementsTypes({ columnType, sourceType }: ParseColumnTypeParams, minElements: number): string[];
|
|
121
|
+
interface ParseColumnTypeParams {
|
|
122
|
+
/** A particular type to parse, such as DateTime. */
|
|
123
|
+
columnType: string;
|
|
124
|
+
/** Full type definition, such as Map(String, DateTime). */
|
|
125
|
+
sourceType: string;
|
|
126
|
+
}
|
|
127
|
+
export {};
|
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SimpleColumnTypes = exports.ColumnTypeParseError = void 0;
|
|
4
|
+
exports.parseColumnType = parseColumnType;
|
|
5
|
+
exports.parseDecimalType = parseDecimalType;
|
|
6
|
+
exports.parseEnumType = parseEnumType;
|
|
7
|
+
exports.parseMapType = parseMapType;
|
|
8
|
+
exports.parseTupleType = parseTupleType;
|
|
9
|
+
exports.parseArrayType = parseArrayType;
|
|
10
|
+
exports.parseDateTimeType = parseDateTimeType;
|
|
11
|
+
exports.parseDateTime64Type = parseDateTime64Type;
|
|
12
|
+
exports.parseFixedStringType = parseFixedStringType;
|
|
13
|
+
exports.asNullableType = asNullableType;
|
|
14
|
+
exports.getElementsTypes = getElementsTypes;
|
|
15
|
+
class ColumnTypeParseError extends Error {
|
|
16
|
+
constructor(message, args) {
|
|
17
|
+
super(message);
|
|
18
|
+
Object.defineProperty(this, "args", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: void 0
|
|
23
|
+
});
|
|
24
|
+
this.args = args ?? {};
|
|
25
|
+
// Set the prototype explicitly, see:
|
|
26
|
+
// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
|
27
|
+
Object.setPrototypeOf(this, ColumnTypeParseError.prototype);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.ColumnTypeParseError = ColumnTypeParseError;
|
|
31
|
+
exports.SimpleColumnTypes = [
|
|
32
|
+
'Bool',
|
|
33
|
+
'UInt8',
|
|
34
|
+
'Int8',
|
|
35
|
+
'UInt16',
|
|
36
|
+
'Int16',
|
|
37
|
+
'UInt32',
|
|
38
|
+
'Int32',
|
|
39
|
+
'UInt64',
|
|
40
|
+
'Int64',
|
|
41
|
+
'UInt128',
|
|
42
|
+
'Int128',
|
|
43
|
+
'UInt256',
|
|
44
|
+
'Int256',
|
|
45
|
+
'Float32',
|
|
46
|
+
'Float64',
|
|
47
|
+
'String',
|
|
48
|
+
'UUID',
|
|
49
|
+
'Date',
|
|
50
|
+
'Date32',
|
|
51
|
+
'IPv4',
|
|
52
|
+
'IPv6',
|
|
53
|
+
];
|
|
54
|
+
/**
|
|
55
|
+
* @experimental - incomplete, unstable API;
|
|
56
|
+
* originally intended to be used for RowBinary/Native header parsing internally.
|
|
57
|
+
* Currently unsupported source types:
|
|
58
|
+
* * Geo
|
|
59
|
+
* * (Simple)AggregateFunction
|
|
60
|
+
* * Nested
|
|
61
|
+
* * Old/new JSON
|
|
62
|
+
* * Dynamic
|
|
63
|
+
* * Variant
|
|
64
|
+
*/
|
|
65
|
+
function parseColumnType(sourceType) {
|
|
66
|
+
let columnType = sourceType;
|
|
67
|
+
let isNullable = false;
|
|
68
|
+
if (columnType.startsWith(LowCardinalityPrefix)) {
|
|
69
|
+
columnType = columnType.slice(LowCardinalityPrefix.length, -1);
|
|
70
|
+
}
|
|
71
|
+
if (columnType.startsWith(NullablePrefix)) {
|
|
72
|
+
columnType = columnType.slice(NullablePrefix.length, -1);
|
|
73
|
+
isNullable = true;
|
|
74
|
+
}
|
|
75
|
+
let result;
|
|
76
|
+
if (exports.SimpleColumnTypes.includes(columnType)) {
|
|
77
|
+
result = {
|
|
78
|
+
type: 'Simple',
|
|
79
|
+
columnType: columnType,
|
|
80
|
+
sourceType,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
else if (columnType.startsWith(DecimalPrefix)) {
|
|
84
|
+
result = parseDecimalType({
|
|
85
|
+
sourceType,
|
|
86
|
+
columnType,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
else if (columnType.startsWith(DateTime64Prefix)) {
|
|
90
|
+
result = parseDateTime64Type({ sourceType, columnType });
|
|
91
|
+
}
|
|
92
|
+
else if (columnType.startsWith(DateTimePrefix)) {
|
|
93
|
+
result = parseDateTimeType({ sourceType, columnType });
|
|
94
|
+
}
|
|
95
|
+
else if (columnType.startsWith(FixedStringPrefix)) {
|
|
96
|
+
result = parseFixedStringType({ sourceType, columnType });
|
|
97
|
+
}
|
|
98
|
+
else if (columnType.startsWith(Enum8Prefix) ||
|
|
99
|
+
columnType.startsWith(Enum16Prefix)) {
|
|
100
|
+
result = parseEnumType({ sourceType, columnType });
|
|
101
|
+
}
|
|
102
|
+
else if (columnType.startsWith(ArrayPrefix)) {
|
|
103
|
+
result = parseArrayType({ sourceType, columnType });
|
|
104
|
+
}
|
|
105
|
+
else if (columnType.startsWith(MapPrefix)) {
|
|
106
|
+
result = parseMapType({ sourceType, columnType });
|
|
107
|
+
}
|
|
108
|
+
else if (columnType.startsWith(TuplePrefix)) {
|
|
109
|
+
result = parseTupleType({ sourceType, columnType });
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
throw new ColumnTypeParseError('Unsupported column type', { columnType });
|
|
113
|
+
}
|
|
114
|
+
if (isNullable) {
|
|
115
|
+
return asNullableType(result, sourceType);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function parseDecimalType({ columnType, sourceType, }) {
|
|
122
|
+
if (!columnType.startsWith(DecimalPrefix) ||
|
|
123
|
+
columnType.length < DecimalPrefix.length + 5 // Decimal(1, 0) is the shortest valid definition
|
|
124
|
+
) {
|
|
125
|
+
throw new ColumnTypeParseError('Invalid Decimal type', {
|
|
126
|
+
sourceType,
|
|
127
|
+
columnType,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
const split = columnType.slice(DecimalPrefix.length, -1).split(', ');
|
|
131
|
+
if (split.length !== 2) {
|
|
132
|
+
throw new ColumnTypeParseError('Expected Decimal type to have both precision and scale', {
|
|
133
|
+
sourceType,
|
|
134
|
+
columnType,
|
|
135
|
+
split,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
let intSize = 32;
|
|
139
|
+
const precision = parseInt(split[0], 10);
|
|
140
|
+
if (Number.isNaN(precision) || precision < 1 || precision > 76) {
|
|
141
|
+
throw new ColumnTypeParseError('Invalid Decimal precision', {
|
|
142
|
+
columnType,
|
|
143
|
+
sourceType,
|
|
144
|
+
precision,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
const scale = parseInt(split[1], 10);
|
|
148
|
+
if (Number.isNaN(scale) || scale < 0 || scale > precision) {
|
|
149
|
+
throw new ColumnTypeParseError('Invalid Decimal scale', {
|
|
150
|
+
columnType,
|
|
151
|
+
sourceType,
|
|
152
|
+
precision,
|
|
153
|
+
scale,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
if (precision > 38) {
|
|
157
|
+
intSize = 256;
|
|
158
|
+
}
|
|
159
|
+
else if (precision > 18) {
|
|
160
|
+
intSize = 128;
|
|
161
|
+
}
|
|
162
|
+
else if (precision > 9) {
|
|
163
|
+
intSize = 64;
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
type: 'Decimal',
|
|
167
|
+
params: {
|
|
168
|
+
precision,
|
|
169
|
+
scale,
|
|
170
|
+
intSize,
|
|
171
|
+
},
|
|
172
|
+
sourceType,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function parseEnumType({ columnType, sourceType, }) {
|
|
176
|
+
let intSize;
|
|
177
|
+
if (columnType.startsWith(Enum8Prefix)) {
|
|
178
|
+
columnType = columnType.slice(Enum8Prefix.length, -1);
|
|
179
|
+
intSize = 8;
|
|
180
|
+
}
|
|
181
|
+
else if (columnType.startsWith(Enum16Prefix)) {
|
|
182
|
+
columnType = columnType.slice(Enum16Prefix.length, -1);
|
|
183
|
+
intSize = 16;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
throw new ColumnTypeParseError('Expected Enum to be either Enum8 or Enum16', {
|
|
187
|
+
columnType,
|
|
188
|
+
sourceType,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
// The minimal allowed Enum definition is Enum8('' = 0), i.e. 6 chars inside.
|
|
192
|
+
if (columnType.length < 6) {
|
|
193
|
+
throw new ColumnTypeParseError('Invalid Enum type values', {
|
|
194
|
+
columnType,
|
|
195
|
+
sourceType,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
const names = [];
|
|
199
|
+
const indices = [];
|
|
200
|
+
let parsingName = true; // false when parsing the index
|
|
201
|
+
let charEscaped = false; // we should ignore escaped ticks
|
|
202
|
+
let startIndex = 1; // Skip the first '
|
|
203
|
+
// Should support the most complicated enums, such as Enum8('f\'' = 1, 'x =' = 2, 'b\'\'\'' = 3, '\'c=4=' = 42, '4' = 100)
|
|
204
|
+
for (let i = 1; i < columnType.length; i++) {
|
|
205
|
+
if (parsingName) {
|
|
206
|
+
if (charEscaped) {
|
|
207
|
+
charEscaped = false;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
if (columnType.charCodeAt(i) === BackslashASCII) {
|
|
211
|
+
charEscaped = true;
|
|
212
|
+
}
|
|
213
|
+
else if (columnType.charCodeAt(i) === SingleQuoteASCII) {
|
|
214
|
+
// non-escaped closing tick - push the name
|
|
215
|
+
const name = columnType.slice(startIndex, i);
|
|
216
|
+
if (names.includes(name)) {
|
|
217
|
+
throw new ColumnTypeParseError('Duplicate Enum name', {
|
|
218
|
+
columnType,
|
|
219
|
+
sourceType,
|
|
220
|
+
name,
|
|
221
|
+
names,
|
|
222
|
+
indices,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
names.push(name);
|
|
226
|
+
i += 4; // skip ` = ` and the first digit, as it will always have at least one.
|
|
227
|
+
startIndex = i;
|
|
228
|
+
parsingName = false;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// Parsing the index, skipping next iterations until the first non-digit one
|
|
233
|
+
else if (columnType.charCodeAt(i) < ZeroASCII ||
|
|
234
|
+
columnType.charCodeAt(i) > NineASCII) {
|
|
235
|
+
pushEnumIndex(startIndex, i);
|
|
236
|
+
// the char at this index should be comma.
|
|
237
|
+
i += 2; // skip ` '`, but not the first char - ClickHouse allows something like Enum8('foo' = 0, '' = 42)
|
|
238
|
+
startIndex = i + 1;
|
|
239
|
+
parsingName = true;
|
|
240
|
+
charEscaped = false;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
// Push the last index
|
|
244
|
+
pushEnumIndex(startIndex, columnType.length);
|
|
245
|
+
if (names.length !== indices.length) {
|
|
246
|
+
throw new ColumnTypeParseError('Expected Enum to have the same number of names and indices', { columnType, sourceType, names, indices });
|
|
247
|
+
}
|
|
248
|
+
const values = {};
|
|
249
|
+
for (let i = 0; i < names.length; i++) {
|
|
250
|
+
values[indices[i]] = names[i];
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
type: 'Enum',
|
|
254
|
+
values,
|
|
255
|
+
intSize,
|
|
256
|
+
sourceType,
|
|
257
|
+
};
|
|
258
|
+
function pushEnumIndex(start, end) {
|
|
259
|
+
const index = parseInt(columnType.slice(start, end), 10);
|
|
260
|
+
if (Number.isNaN(index) || index < 0) {
|
|
261
|
+
throw new ColumnTypeParseError('Expected Enum index to be a valid number', {
|
|
262
|
+
columnType,
|
|
263
|
+
sourceType,
|
|
264
|
+
names,
|
|
265
|
+
indices,
|
|
266
|
+
index,
|
|
267
|
+
start,
|
|
268
|
+
end,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
if (indices.includes(index)) {
|
|
272
|
+
throw new ColumnTypeParseError('Duplicate Enum index', {
|
|
273
|
+
columnType,
|
|
274
|
+
sourceType,
|
|
275
|
+
index,
|
|
276
|
+
names,
|
|
277
|
+
indices,
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
indices.push(index);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
function parseMapType({ columnType, sourceType, }) {
|
|
284
|
+
if (!columnType.startsWith(MapPrefix) ||
|
|
285
|
+
columnType.length < MapPrefix.length + 11 // the shortest definition seems to be Map(Int8, Int8)
|
|
286
|
+
) {
|
|
287
|
+
throw new ColumnTypeParseError('Invalid Map type', {
|
|
288
|
+
columnType,
|
|
289
|
+
sourceType,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
columnType = columnType.slice(MapPrefix.length, -1);
|
|
293
|
+
const [keyType, valueType] = getElementsTypes({ columnType, sourceType }, 2);
|
|
294
|
+
const key = parseColumnType(keyType);
|
|
295
|
+
if (key.type === 'DateTime64' ||
|
|
296
|
+
key.type === 'Nullable' ||
|
|
297
|
+
key.type === 'Array' ||
|
|
298
|
+
key.type === 'Map' ||
|
|
299
|
+
key.type === 'Decimal' ||
|
|
300
|
+
key.type === 'Tuple') {
|
|
301
|
+
throw new ColumnTypeParseError('Invalid Map key type', {
|
|
302
|
+
key,
|
|
303
|
+
sourceType,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
const value = parseColumnType(valueType);
|
|
307
|
+
return {
|
|
308
|
+
type: 'Map',
|
|
309
|
+
key,
|
|
310
|
+
value,
|
|
311
|
+
sourceType,
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function parseTupleType({ columnType, sourceType, }) {
|
|
315
|
+
if (!columnType.startsWith(TuplePrefix) ||
|
|
316
|
+
columnType.length < TuplePrefix.length + 5 // Tuple(Int8) is the shortest valid definition
|
|
317
|
+
) {
|
|
318
|
+
throw new ColumnTypeParseError('Invalid Tuple type', {
|
|
319
|
+
columnType,
|
|
320
|
+
sourceType,
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
columnType = columnType.slice(TuplePrefix.length, -1);
|
|
324
|
+
const elements = getElementsTypes({ columnType, sourceType }, 1).map((type) => parseColumnType(type));
|
|
325
|
+
return {
|
|
326
|
+
type: 'Tuple',
|
|
327
|
+
elements,
|
|
328
|
+
sourceType,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
function parseArrayType({ columnType, sourceType, }) {
|
|
332
|
+
if (!columnType.startsWith(ArrayPrefix) ||
|
|
333
|
+
columnType.length < ArrayPrefix.length + 5 // Array(Int8) is the shortest valid definition
|
|
334
|
+
) {
|
|
335
|
+
throw new ColumnTypeParseError('Invalid Array type', {
|
|
336
|
+
columnType,
|
|
337
|
+
sourceType,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
let dimensions = 0;
|
|
341
|
+
while (columnType.length > 0) {
|
|
342
|
+
if (columnType.startsWith(ArrayPrefix)) {
|
|
343
|
+
columnType = columnType.slice(ArrayPrefix.length, -1); // Array(T) -> T
|
|
344
|
+
dimensions++;
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if (dimensions === 0 || dimensions > 10) {
|
|
351
|
+
// TODO: check how many we can handle; max 10 seems more than enough.
|
|
352
|
+
throw new ColumnTypeParseError('Expected Array to have between 1 and 10 dimensions', { columnType });
|
|
353
|
+
}
|
|
354
|
+
const value = parseColumnType(columnType);
|
|
355
|
+
if (value.type === 'Array') {
|
|
356
|
+
throw new ColumnTypeParseError('Unexpected Array as value type', {
|
|
357
|
+
columnType,
|
|
358
|
+
sourceType,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
return {
|
|
362
|
+
type: 'Array',
|
|
363
|
+
value,
|
|
364
|
+
dimensions,
|
|
365
|
+
sourceType,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
function parseDateTimeType({ columnType, sourceType, }) {
|
|
369
|
+
if (columnType.startsWith(DateTimeWithTimezonePrefix) &&
|
|
370
|
+
columnType.length > DateTimeWithTimezonePrefix.length + 4 // DateTime('GB') has the least amount of chars
|
|
371
|
+
) {
|
|
372
|
+
const timezone = columnType.slice(DateTimeWithTimezonePrefix.length + 1, -2);
|
|
373
|
+
return {
|
|
374
|
+
type: 'DateTime',
|
|
375
|
+
timezone,
|
|
376
|
+
sourceType,
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
else if (columnType.startsWith(DateTimePrefix) &&
|
|
380
|
+
columnType.length === DateTimePrefix.length) {
|
|
381
|
+
return {
|
|
382
|
+
type: 'DateTime',
|
|
383
|
+
timezone: null,
|
|
384
|
+
sourceType,
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
throw new ColumnTypeParseError('Invalid DateTime type', {
|
|
389
|
+
columnType,
|
|
390
|
+
sourceType,
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
function parseDateTime64Type({ columnType, sourceType, }) {
|
|
395
|
+
if (!columnType.startsWith(DateTime64Prefix) ||
|
|
396
|
+
columnType.length < DateTime64Prefix.length + 2 // should at least have a precision
|
|
397
|
+
) {
|
|
398
|
+
throw new ColumnTypeParseError('Invalid DateTime64 type', {
|
|
399
|
+
columnType,
|
|
400
|
+
sourceType,
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
const precision = parseInt(columnType[DateTime64Prefix.length], 10);
|
|
404
|
+
if (Number.isNaN(precision) || precision < 0 || precision > 9) {
|
|
405
|
+
throw new ColumnTypeParseError('Invalid DateTime64 precision', {
|
|
406
|
+
columnType,
|
|
407
|
+
sourceType,
|
|
408
|
+
precision,
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
let timezone = null;
|
|
412
|
+
if (columnType.length > DateTime64Prefix.length + 2) {
|
|
413
|
+
// e.g. DateTime64(3, 'UTC') -> UTC
|
|
414
|
+
timezone = columnType.slice(DateTime64Prefix.length + 4, -2);
|
|
415
|
+
}
|
|
416
|
+
return {
|
|
417
|
+
type: 'DateTime64',
|
|
418
|
+
timezone,
|
|
419
|
+
precision,
|
|
420
|
+
sourceType,
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
function parseFixedStringType({ columnType, sourceType, }) {
|
|
424
|
+
if (!columnType.startsWith(FixedStringPrefix) ||
|
|
425
|
+
columnType.length < FixedStringPrefix.length + 2 // i.e. at least FixedString(1)
|
|
426
|
+
) {
|
|
427
|
+
throw new ColumnTypeParseError('Invalid FixedString type', {
|
|
428
|
+
columnType,
|
|
429
|
+
sourceType,
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
const sizeBytes = parseInt(columnType.slice(FixedStringPrefix.length, -1), 10);
|
|
433
|
+
if (Number.isNaN(sizeBytes) || sizeBytes < 1) {
|
|
434
|
+
throw new ColumnTypeParseError('Invalid FixedString size in bytes', {
|
|
435
|
+
columnType,
|
|
436
|
+
sourceType,
|
|
437
|
+
sizeBytes,
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
return {
|
|
441
|
+
type: 'FixedString',
|
|
442
|
+
sizeBytes,
|
|
443
|
+
sourceType,
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
function asNullableType(value, sourceType) {
|
|
447
|
+
if (value.type === 'Array' ||
|
|
448
|
+
value.type === 'Map' ||
|
|
449
|
+
value.type === 'Tuple' ||
|
|
450
|
+
value.type === 'Nullable') {
|
|
451
|
+
throw new ColumnTypeParseError(`${value.type} cannot be Nullable`, {
|
|
452
|
+
sourceType,
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
if (value.sourceType.startsWith(NullablePrefix)) {
|
|
456
|
+
value.sourceType = value.sourceType.slice(NullablePrefix.length, -1);
|
|
457
|
+
}
|
|
458
|
+
return {
|
|
459
|
+
type: 'Nullable',
|
|
460
|
+
sourceType,
|
|
461
|
+
value,
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
/** Used for Map key/value types and Tuple elements.
|
|
465
|
+
* * `String, UInt8` results in [`String`, `UInt8`].
|
|
466
|
+
* * `String, UInt8, Array(String)` results in [`String`, `UInt8`, `Array(String)`].
|
|
467
|
+
* * Throws if parsed values are below the required minimum. */
|
|
468
|
+
function getElementsTypes({ columnType, sourceType }, minElements) {
|
|
469
|
+
const elements = [];
|
|
470
|
+
/** Consider the element type parsed once we reach a comma outside of parens AND after an unescaped tick.
|
|
471
|
+
* The most complicated cases are values names in the self-defined Enum types:
|
|
472
|
+
* * `Tuple(Enum8('f\'()' = 1))` -> `f\'()`
|
|
473
|
+
* * `Tuple(Enum8('(' = 1))` -> `(`
|
|
474
|
+
* See also: {@link parseEnumType }, which works similarly (but has to deal with the indices following the names). */
|
|
475
|
+
let openParens = 0;
|
|
476
|
+
let quoteOpen = false;
|
|
477
|
+
let charEscaped = false;
|
|
478
|
+
let lastElementIndex = 0;
|
|
479
|
+
for (let i = 0; i < columnType.length; i++) {
|
|
480
|
+
if (charEscaped) {
|
|
481
|
+
charEscaped = false;
|
|
482
|
+
}
|
|
483
|
+
else if (columnType.charCodeAt(i) === BackslashASCII) {
|
|
484
|
+
charEscaped = true;
|
|
485
|
+
}
|
|
486
|
+
else if (columnType.charCodeAt(i) === SingleQuoteASCII) {
|
|
487
|
+
quoteOpen = !quoteOpen; // unescaped quote
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
if (!quoteOpen) {
|
|
491
|
+
if (columnType.charCodeAt(i) === LeftParenASCII) {
|
|
492
|
+
openParens++;
|
|
493
|
+
}
|
|
494
|
+
else if (columnType.charCodeAt(i) === RightParenASCII) {
|
|
495
|
+
openParens--;
|
|
496
|
+
}
|
|
497
|
+
else if (columnType.charCodeAt(i) === CommaASCII) {
|
|
498
|
+
if (openParens === 0) {
|
|
499
|
+
elements.push(columnType.slice(lastElementIndex, i));
|
|
500
|
+
i += 2; // skip ', '
|
|
501
|
+
lastElementIndex = i;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
// Push the remaining part of the type if it seems to be valid (at least all parentheses are closed)
|
|
508
|
+
if (!openParens && lastElementIndex < columnType.length - 1) {
|
|
509
|
+
elements.push(columnType.slice(lastElementIndex));
|
|
510
|
+
}
|
|
511
|
+
if (elements.length < minElements) {
|
|
512
|
+
throw new ColumnTypeParseError('Expected more elements in the type', {
|
|
513
|
+
sourceType,
|
|
514
|
+
columnType,
|
|
515
|
+
elements,
|
|
516
|
+
minElements,
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
return elements;
|
|
520
|
+
}
|
|
521
|
+
const NullablePrefix = 'Nullable(';
|
|
522
|
+
const LowCardinalityPrefix = 'LowCardinality(';
|
|
523
|
+
const DecimalPrefix = 'Decimal(';
|
|
524
|
+
const ArrayPrefix = 'Array(';
|
|
525
|
+
const MapPrefix = 'Map(';
|
|
526
|
+
const Enum8Prefix = 'Enum8(';
|
|
527
|
+
const Enum16Prefix = 'Enum16(';
|
|
528
|
+
const TuplePrefix = 'Tuple(';
|
|
529
|
+
const DateTimePrefix = 'DateTime';
|
|
530
|
+
const DateTimeWithTimezonePrefix = 'DateTime(';
|
|
531
|
+
const DateTime64Prefix = 'DateTime64(';
|
|
532
|
+
const FixedStringPrefix = 'FixedString(';
|
|
533
|
+
const SingleQuoteASCII = 39;
|
|
534
|
+
const LeftParenASCII = 40;
|
|
535
|
+
const RightParenASCII = 41;
|
|
536
|
+
const CommaASCII = 44;
|
|
537
|
+
const ZeroASCII = 48;
|
|
538
|
+
const NineASCII = 57;
|
|
539
|
+
const BackslashASCII = 92;
|
|
540
|
+
//# sourceMappingURL=column_types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column_types.js","sourceRoot":"","sources":["../../src/parse/column_types.ts"],"names":[],"mappings":";;;AAgLA,0CA+CC;AAED,4CA0DC;AAED,sCA0HC;AAED,oCAoCC;AAED,wCAsBC;AAED,wCA2CC;AAED,8CA6BC;AAED,kDAgCC;AAED,oDA0BC;AAED,wCAsBC;AAMD,4CAmDC;AAhrBD,MAAa,oBAAqB,SAAQ,KAAK;IAE7C,YAAY,OAAe,E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