@loaders.gl/sql 5.0.0-beta.6 → 5.0.0-beta.8
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/README.md +2 -2
- package/dist/duckdb-sql-source.d.ts +2 -2
- package/dist/duckdb-sql-source.d.ts.map +1 -1
- package/dist/duckdb-sql-source.js +2 -2
- package/dist/duckdb-sql-source.js.map +1 -1
- package/dist/index.cjs +249 -500
- package/dist/index.cjs.map +3 -3
- package/dist/snowflake-sql-source.d.ts +2 -2
- package/dist/snowflake-sql-source.d.ts.map +1 -1
- package/dist/snowflake-sql-source.js +2 -2
- package/dist/snowflake-sql-source.js.map +1 -1
- package/package.json +2 -2
- package/src/duckdb-sql-source.ts +1 -1
- package/src/snowflake-sql-source.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -69,6 +69,36 @@ function createLog() {
|
|
|
69
69
|
return log2;
|
|
70
70
|
}
|
|
71
71
|
var log = createLog();
|
|
72
|
+
var NullLog = class {
|
|
73
|
+
/** Discards debug messages. */
|
|
74
|
+
log() {
|
|
75
|
+
return ignoreMessage;
|
|
76
|
+
}
|
|
77
|
+
/** Discards informational messages. */
|
|
78
|
+
info() {
|
|
79
|
+
return ignoreMessage;
|
|
80
|
+
}
|
|
81
|
+
/** Discards messages marked to be emitted once. */
|
|
82
|
+
once() {
|
|
83
|
+
return ignoreMessage;
|
|
84
|
+
}
|
|
85
|
+
/** Discards warnings. */
|
|
86
|
+
warn() {
|
|
87
|
+
return ignoreMessage;
|
|
88
|
+
}
|
|
89
|
+
/** Discards errors. */
|
|
90
|
+
error() {
|
|
91
|
+
return ignoreMessage;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
function ignoreMessage() {
|
|
95
|
+
}
|
|
96
|
+
var nullLog = new NullLog();
|
|
97
|
+
function getLoaderLog(options) {
|
|
98
|
+
var _a;
|
|
99
|
+
const logger = ((_a = options == null ? void 0 : options.core) == null ? void 0 : _a.log) !== void 0 ? options.core.log : options == null ? void 0 : options.log;
|
|
100
|
+
return logger === null ? nullLog : logger || log;
|
|
101
|
+
}
|
|
72
102
|
|
|
73
103
|
// ../core/src/loader-utils/lib/javascript-utils/is-type.ts
|
|
74
104
|
var isObject = (value) => value !== null && typeof value === "object";
|
|
@@ -462,7 +492,7 @@ var DataSource = class _DataSource {
|
|
|
462
492
|
if (callback) {
|
|
463
493
|
callback(normalizedError, this);
|
|
464
494
|
} else {
|
|
465
|
-
|
|
495
|
+
getLoaderLog(this.options).warn(`${this.constructor.name}: ${normalizedError.message}`)();
|
|
466
496
|
}
|
|
467
497
|
return normalizedError;
|
|
468
498
|
}
|
|
@@ -512,7 +542,7 @@ function normalizeError(error, message) {
|
|
|
512
542
|
function unavailableCoreApiMethod(methodName) {
|
|
513
543
|
return () => {
|
|
514
544
|
throw new Error(
|
|
515
|
-
`CoreAPI.${methodName} is unavailable. Use @loaders.gl/core.
|
|
545
|
+
`CoreAPI.${methodName} is unavailable. Use @loaders.gl/core.createDataSourceSync().`
|
|
516
546
|
);
|
|
517
547
|
};
|
|
518
548
|
}
|
|
@@ -1858,127 +1888,8 @@ function deserializeArrowDictionaryKeyType(keyType) {
|
|
|
1858
1888
|
}
|
|
1859
1889
|
}
|
|
1860
1890
|
|
|
1861
|
-
// ../core/src/schema-utils/lib/
|
|
1862
|
-
|
|
1863
|
-
switch (table.shape) {
|
|
1864
|
-
case "array-row-table":
|
|
1865
|
-
case "object-row-table":
|
|
1866
|
-
return deduceSchemaFromRows(table.data);
|
|
1867
|
-
case "geojson-table":
|
|
1868
|
-
return deduceSchemaFromGeoJSON(table.features);
|
|
1869
|
-
case "columnar-table":
|
|
1870
|
-
return deduceSchemaFromColumns(table.data);
|
|
1871
|
-
case "arrow-table":
|
|
1872
|
-
default:
|
|
1873
|
-
throw new Error("Deduce schema");
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
function deduceSchemaFromColumns(columnarTable) {
|
|
1877
|
-
const fields = [];
|
|
1878
|
-
for (const [columnName, column] of Object.entries(columnarTable)) {
|
|
1879
|
-
const field = deduceFieldFromColumn(column, columnName);
|
|
1880
|
-
fields.push(field);
|
|
1881
|
-
}
|
|
1882
|
-
return { fields, metadata: {} };
|
|
1883
|
-
}
|
|
1884
|
-
function deduceSchemaFromRows(rowTable) {
|
|
1885
|
-
if (!rowTable.length) {
|
|
1886
|
-
throw new Error("deduce from empty table");
|
|
1887
|
-
}
|
|
1888
|
-
const fields = [];
|
|
1889
|
-
const row0 = rowTable[0];
|
|
1890
|
-
for (const [columnName, value] of Object.entries(row0)) {
|
|
1891
|
-
fields.push(deduceFieldFromValue(value, columnName));
|
|
1892
|
-
}
|
|
1893
|
-
return { fields, metadata: {} };
|
|
1894
|
-
}
|
|
1895
|
-
function deduceSchemaFromGeoJSON(features) {
|
|
1896
|
-
if (!features.length) {
|
|
1897
|
-
throw new Error("deduce from empty table");
|
|
1898
|
-
}
|
|
1899
|
-
const fields = [];
|
|
1900
|
-
const row0 = features[0].properties || {};
|
|
1901
|
-
for (const [columnName, value] of Object.entries(row0)) {
|
|
1902
|
-
fields.push(deduceFieldFromValue(value, columnName));
|
|
1903
|
-
}
|
|
1904
|
-
return { fields, metadata: {} };
|
|
1905
|
-
}
|
|
1906
|
-
function deduceFieldFromColumn(column, name) {
|
|
1907
|
-
if (ArrayBuffer.isView(column)) {
|
|
1908
|
-
const type = getDataTypeFromArray(column);
|
|
1909
|
-
return {
|
|
1910
|
-
name,
|
|
1911
|
-
type: type.type || "null",
|
|
1912
|
-
nullable: type.nullable
|
|
1913
|
-
// metadata: {}
|
|
1914
|
-
};
|
|
1915
|
-
}
|
|
1916
|
-
if (Array.isArray(column) && column.length > 0) {
|
|
1917
|
-
const value = column[0];
|
|
1918
|
-
const type = getDataTypeFromValue(value);
|
|
1919
|
-
return {
|
|
1920
|
-
name,
|
|
1921
|
-
type,
|
|
1922
|
-
nullable: true
|
|
1923
|
-
// metadata: {},
|
|
1924
|
-
};
|
|
1925
|
-
}
|
|
1926
|
-
throw new Error("empty table");
|
|
1927
|
-
}
|
|
1928
|
-
function deduceFieldFromValue(value, name) {
|
|
1929
|
-
const type = getDataTypeFromValue(value);
|
|
1930
|
-
return {
|
|
1931
|
-
name,
|
|
1932
|
-
type,
|
|
1933
|
-
nullable: true
|
|
1934
|
-
// metadata: {}
|
|
1935
|
-
};
|
|
1936
|
-
}
|
|
1937
|
-
|
|
1938
|
-
// ../core/src/schema-utils/lib/table/tables/make-table.ts
|
|
1939
|
-
var arrow2 = __toESM(require("apache-arrow"), 1);
|
|
1940
|
-
function makeTableFromData(data) {
|
|
1941
|
-
let table;
|
|
1942
|
-
switch (getTableShapeFromData(data)) {
|
|
1943
|
-
case "array-row-table":
|
|
1944
|
-
table = { shape: "array-row-table", data };
|
|
1945
|
-
break;
|
|
1946
|
-
case "object-row-table":
|
|
1947
|
-
table = { shape: "object-row-table", data };
|
|
1948
|
-
break;
|
|
1949
|
-
case "columnar-table":
|
|
1950
|
-
table = { shape: "columnar-table", data };
|
|
1951
|
-
break;
|
|
1952
|
-
case "arrow-table":
|
|
1953
|
-
table = { shape: "arrow-table", data };
|
|
1954
|
-
break;
|
|
1955
|
-
default:
|
|
1956
|
-
throw new Error("table");
|
|
1957
|
-
}
|
|
1958
|
-
const schema = deduceTableSchema(table);
|
|
1959
|
-
return { ...table, schema };
|
|
1960
|
-
}
|
|
1961
|
-
function getTableShapeFromData(data) {
|
|
1962
|
-
if (data instanceof arrow2.Table) {
|
|
1963
|
-
return "arrow-table";
|
|
1964
|
-
}
|
|
1965
|
-
if (Array.isArray(data)) {
|
|
1966
|
-
if (data.length === 0) {
|
|
1967
|
-
throw new Error("cannot deduce type of empty table");
|
|
1968
|
-
}
|
|
1969
|
-
const firstRow = data[0];
|
|
1970
|
-
if (Array.isArray(firstRow)) {
|
|
1971
|
-
return "array-row-table";
|
|
1972
|
-
}
|
|
1973
|
-
if (firstRow && typeof firstRow === "object") {
|
|
1974
|
-
return "object-row-table";
|
|
1975
|
-
}
|
|
1976
|
-
}
|
|
1977
|
-
if (data && typeof data === "object") {
|
|
1978
|
-
return "columnar-table";
|
|
1979
|
-
}
|
|
1980
|
-
throw new Error("invalid table");
|
|
1981
|
-
}
|
|
1891
|
+
// ../core/src/schema-utils/lib/table/tables/convert-arrow-table.ts
|
|
1892
|
+
var arrow3 = __toESM(require("apache-arrow"), 1);
|
|
1982
1893
|
|
|
1983
1894
|
// ../core/src/schema-utils/lib/table/tables/table-accessors.ts
|
|
1984
1895
|
function getTableLength(table) {
|
|
@@ -2185,29 +2096,180 @@ function getTableRowAsArray(table, rowIndex, target, copy) {
|
|
|
2185
2096
|
}
|
|
2186
2097
|
}
|
|
2187
2098
|
|
|
2099
|
+
// ../core/src/schema-utils/lib/schema/deduce-table-schema.ts
|
|
2100
|
+
function deduceTableSchema(table) {
|
|
2101
|
+
switch (table.shape) {
|
|
2102
|
+
case "array-row-table":
|
|
2103
|
+
case "object-row-table":
|
|
2104
|
+
return deduceSchemaFromRows(table.data);
|
|
2105
|
+
case "geojson-table":
|
|
2106
|
+
return deduceSchemaFromGeoJSON(table.features);
|
|
2107
|
+
case "columnar-table":
|
|
2108
|
+
return deduceSchemaFromColumns(table.data);
|
|
2109
|
+
case "arrow-table":
|
|
2110
|
+
default:
|
|
2111
|
+
throw new Error("Deduce schema");
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
function deduceSchemaFromColumns(columnarTable) {
|
|
2115
|
+
const fields = [];
|
|
2116
|
+
for (const [columnName, column] of Object.entries(columnarTable)) {
|
|
2117
|
+
const field = deduceFieldFromColumn(column, columnName);
|
|
2118
|
+
fields.push(field);
|
|
2119
|
+
}
|
|
2120
|
+
return { fields, metadata: {} };
|
|
2121
|
+
}
|
|
2122
|
+
function deduceSchemaFromRows(rowTable) {
|
|
2123
|
+
if (!rowTable.length) {
|
|
2124
|
+
throw new Error("deduce from empty table");
|
|
2125
|
+
}
|
|
2126
|
+
const fields = [];
|
|
2127
|
+
const row0 = rowTable[0];
|
|
2128
|
+
for (const [columnName, value] of Object.entries(row0)) {
|
|
2129
|
+
const name = Array.isArray(row0) ? `column${Number(columnName) + 1}` : columnName;
|
|
2130
|
+
fields.push(deduceFieldFromValue(value, name));
|
|
2131
|
+
}
|
|
2132
|
+
return { fields, metadata: {} };
|
|
2133
|
+
}
|
|
2134
|
+
function deduceSchemaFromGeoJSON(features) {
|
|
2135
|
+
if (!features.length) {
|
|
2136
|
+
throw new Error("deduce from empty table");
|
|
2137
|
+
}
|
|
2138
|
+
const fields = [];
|
|
2139
|
+
const row0 = features[0].properties || {};
|
|
2140
|
+
for (const [columnName, value] of Object.entries(row0)) {
|
|
2141
|
+
fields.push(deduceFieldFromValue(value, columnName));
|
|
2142
|
+
}
|
|
2143
|
+
return { fields, metadata: {} };
|
|
2144
|
+
}
|
|
2145
|
+
function deduceFieldFromColumn(column, name) {
|
|
2146
|
+
if (ArrayBuffer.isView(column)) {
|
|
2147
|
+
const type = getDataTypeFromArray(column);
|
|
2148
|
+
return {
|
|
2149
|
+
name,
|
|
2150
|
+
type: type.type || "null",
|
|
2151
|
+
nullable: type.nullable
|
|
2152
|
+
// metadata: {}
|
|
2153
|
+
};
|
|
2154
|
+
}
|
|
2155
|
+
if (Array.isArray(column) && column.length > 0) {
|
|
2156
|
+
const value = column[0];
|
|
2157
|
+
const type = getDataTypeFromValue(value);
|
|
2158
|
+
return {
|
|
2159
|
+
name,
|
|
2160
|
+
type,
|
|
2161
|
+
nullable: true
|
|
2162
|
+
// metadata: {},
|
|
2163
|
+
};
|
|
2164
|
+
}
|
|
2165
|
+
throw new Error("empty table");
|
|
2166
|
+
}
|
|
2167
|
+
function deduceFieldFromValue(value, name) {
|
|
2168
|
+
const type = getDataTypeFromValue(value);
|
|
2169
|
+
return {
|
|
2170
|
+
name,
|
|
2171
|
+
type,
|
|
2172
|
+
nullable: true
|
|
2173
|
+
// metadata: {}
|
|
2174
|
+
};
|
|
2175
|
+
}
|
|
2176
|
+
|
|
2188
2177
|
// ../core/src/schema-utils/lib/table/tables/table-column.ts
|
|
2189
2178
|
function makeColumnFromField(field, length) {
|
|
2190
2179
|
const ArrayType = getArrayTypeFromDataType(field.type, field.nullable);
|
|
2191
2180
|
return new ArrayType(length);
|
|
2192
2181
|
}
|
|
2193
2182
|
|
|
2194
|
-
// ../core/src/schema-utils/lib/table/tables/convert-
|
|
2195
|
-
|
|
2183
|
+
// ../core/src/schema-utils/lib/table/tables/convert-table.ts
|
|
2184
|
+
function convertTable(table, shape) {
|
|
2185
|
+
switch (shape) {
|
|
2186
|
+
case "object-row-table":
|
|
2187
|
+
return convertToObjectRowTable(table);
|
|
2188
|
+
case "array-row-table":
|
|
2189
|
+
return convertToArrayRowTable(table);
|
|
2190
|
+
case "columnar-table":
|
|
2191
|
+
return convertToColumnarTable(table);
|
|
2192
|
+
case "arrow-table":
|
|
2193
|
+
return convertToArrowTable(table);
|
|
2194
|
+
default:
|
|
2195
|
+
throw new Error(shape);
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
function convertToColumnarTable(table) {
|
|
2199
|
+
const schema = table.schema || deduceTableSchema(table);
|
|
2200
|
+
const fields = schema.fields;
|
|
2201
|
+
if (table.shape === "columnar-table") {
|
|
2202
|
+
return { ...table, schema };
|
|
2203
|
+
}
|
|
2204
|
+
const length = getTableLength(table);
|
|
2205
|
+
const columns = {};
|
|
2206
|
+
for (const field of fields) {
|
|
2207
|
+
const column = makeColumnFromField(field, length);
|
|
2208
|
+
columns[field.name] = column;
|
|
2209
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
2210
|
+
column[rowIndex] = getTableCell(table, rowIndex, field.name);
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
return {
|
|
2214
|
+
shape: "columnar-table",
|
|
2215
|
+
schema,
|
|
2216
|
+
data: columns
|
|
2217
|
+
};
|
|
2218
|
+
}
|
|
2219
|
+
function convertToArrayRowTable(table) {
|
|
2220
|
+
if (table.shape === "array-row-table") {
|
|
2221
|
+
return table;
|
|
2222
|
+
}
|
|
2223
|
+
const length = getTableLength(table);
|
|
2224
|
+
const data = new Array(length);
|
|
2225
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
2226
|
+
data[rowIndex] = getTableRowAsArray(table, rowIndex);
|
|
2227
|
+
}
|
|
2228
|
+
return {
|
|
2229
|
+
shape: "array-row-table",
|
|
2230
|
+
schema: table.schema,
|
|
2231
|
+
data
|
|
2232
|
+
};
|
|
2233
|
+
}
|
|
2234
|
+
function convertToObjectRowTable(table) {
|
|
2235
|
+
if (table.shape === "object-row-table") {
|
|
2236
|
+
return table;
|
|
2237
|
+
}
|
|
2238
|
+
const length = getTableLength(table);
|
|
2239
|
+
const data = new Array(length);
|
|
2240
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
2241
|
+
data[rowIndex] = getTableRowAsObject(table, rowIndex);
|
|
2242
|
+
}
|
|
2243
|
+
return {
|
|
2244
|
+
shape: "object-row-table",
|
|
2245
|
+
schema: table.schema,
|
|
2246
|
+
data
|
|
2247
|
+
};
|
|
2248
|
+
}
|
|
2249
|
+
function convertToArrowTable(table) {
|
|
2250
|
+
const schema = table.schema || deduceTableSchema(table);
|
|
2251
|
+
const arrowTable = convertTableToArrow({ ...table, schema });
|
|
2252
|
+
return {
|
|
2253
|
+
shape: "arrow-table",
|
|
2254
|
+
schema,
|
|
2255
|
+
data: arrowTable
|
|
2256
|
+
};
|
|
2257
|
+
}
|
|
2196
2258
|
|
|
2197
2259
|
// ../core/src/schema-utils/lib/table/batches/make-arrow-batch-iterator.ts
|
|
2198
|
-
var
|
|
2260
|
+
var arrow2 = __toESM(require("apache-arrow"), 1);
|
|
2199
2261
|
function* makeArrowRecordBatchIterator(table, options) {
|
|
2200
2262
|
const arrowSchema = convertSchemaToArrow(table.schema);
|
|
2201
2263
|
const length = getTableLength(table);
|
|
2202
2264
|
const numColumns = getTableNumCols(table);
|
|
2203
2265
|
const batchSize = (options == null ? void 0 : options.batchSize) || length;
|
|
2204
2266
|
const builders = arrowSchema == null ? void 0 : arrowSchema.fields.map(
|
|
2205
|
-
(arrowField) =>
|
|
2267
|
+
(arrowField) => arrow2.makeBuilder({
|
|
2206
2268
|
type: arrowField.type,
|
|
2207
2269
|
nullValues: [null, void 0]
|
|
2208
2270
|
})
|
|
2209
2271
|
);
|
|
2210
|
-
const structField = new
|
|
2272
|
+
const structField = new arrow2.Struct(arrowSchema.fields);
|
|
2211
2273
|
let batchLength = 0;
|
|
2212
2274
|
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
2213
2275
|
for (let columnIndex = 0; columnIndex < numColumns; ++columnIndex) {
|
|
@@ -2218,15 +2280,15 @@ function* makeArrowRecordBatchIterator(table, options) {
|
|
|
2218
2280
|
batchLength++;
|
|
2219
2281
|
if (batchLength >= batchSize) {
|
|
2220
2282
|
const datas = builders.map((builder) => builder.flush());
|
|
2221
|
-
const structData = new
|
|
2222
|
-
yield new
|
|
2283
|
+
const structData = new arrow2.Data(structField, 0, batchLength, 0, void 0, datas);
|
|
2284
|
+
yield new arrow2.RecordBatch(arrowSchema, structData);
|
|
2223
2285
|
batchLength = 0;
|
|
2224
2286
|
}
|
|
2225
2287
|
}
|
|
2226
2288
|
if (batchLength > 0) {
|
|
2227
2289
|
const datas = builders.map((builder) => builder.flush());
|
|
2228
|
-
const structData = new
|
|
2229
|
-
yield new
|
|
2290
|
+
const structData = new arrow2.Data(structField, 0, batchLength, 0, void 0, datas);
|
|
2291
|
+
yield new arrow2.RecordBatch(arrowSchema, structData);
|
|
2230
2292
|
batchLength = 0;
|
|
2231
2293
|
}
|
|
2232
2294
|
builders.map((builder) => builder.finish());
|
|
@@ -2243,7 +2305,7 @@ function convertTableToArrow(table, options) {
|
|
|
2243
2305
|
// fall through
|
|
2244
2306
|
default:
|
|
2245
2307
|
const arrowBatchIterator = makeArrowRecordBatchIterator(table, options);
|
|
2246
|
-
return new
|
|
2308
|
+
return new arrow3.Table(arrowBatchIterator);
|
|
2247
2309
|
}
|
|
2248
2310
|
}
|
|
2249
2311
|
function convertArrowToTable(arrowTable, shape) {
|
|
@@ -2307,80 +2369,49 @@ function convertArrowToGeoJSONTable(arrowTable) {
|
|
|
2307
2369
|
};
|
|
2308
2370
|
}
|
|
2309
2371
|
|
|
2310
|
-
// ../core/src/schema-utils/lib/table/tables/
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2372
|
+
// ../core/src/schema-utils/lib/table/tables/make-table.ts
|
|
2373
|
+
var arrow4 = __toESM(require("apache-arrow"), 1);
|
|
2374
|
+
function makeTableFromData(data) {
|
|
2375
|
+
let table;
|
|
2376
|
+
switch (getTableShapeFromData(data)) {
|
|
2315
2377
|
case "array-row-table":
|
|
2316
|
-
|
|
2378
|
+
table = { shape: "array-row-table", data };
|
|
2379
|
+
break;
|
|
2380
|
+
case "object-row-table":
|
|
2381
|
+
table = { shape: "object-row-table", data };
|
|
2382
|
+
break;
|
|
2317
2383
|
case "columnar-table":
|
|
2318
|
-
|
|
2384
|
+
table = { shape: "columnar-table", data };
|
|
2385
|
+
break;
|
|
2319
2386
|
case "arrow-table":
|
|
2320
|
-
|
|
2387
|
+
table = { shape: "arrow-table", data };
|
|
2388
|
+
break;
|
|
2321
2389
|
default:
|
|
2322
|
-
throw new Error(
|
|
2390
|
+
throw new Error("table");
|
|
2323
2391
|
}
|
|
2392
|
+
const schema = deduceTableSchema(table);
|
|
2393
|
+
return { ...table, schema };
|
|
2324
2394
|
}
|
|
2325
|
-
function
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
if (table.shape === "columnar-table") {
|
|
2329
|
-
return { ...table, schema };
|
|
2395
|
+
function getTableShapeFromData(data) {
|
|
2396
|
+
if (data instanceof arrow4.Table) {
|
|
2397
|
+
return "arrow-table";
|
|
2330
2398
|
}
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2399
|
+
if (Array.isArray(data)) {
|
|
2400
|
+
if (data.length === 0) {
|
|
2401
|
+
throw new Error("cannot deduce type of empty table");
|
|
2402
|
+
}
|
|
2403
|
+
const firstRow = data[0];
|
|
2404
|
+
if (Array.isArray(firstRow)) {
|
|
2405
|
+
return "array-row-table";
|
|
2406
|
+
}
|
|
2407
|
+
if (firstRow && typeof firstRow === "object") {
|
|
2408
|
+
return "object-row-table";
|
|
2338
2409
|
}
|
|
2339
2410
|
}
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
schema,
|
|
2343
|
-
data: columns
|
|
2344
|
-
};
|
|
2345
|
-
}
|
|
2346
|
-
function convertToArrayRowTable(table) {
|
|
2347
|
-
if (table.shape === "array-row-table") {
|
|
2348
|
-
return table;
|
|
2349
|
-
}
|
|
2350
|
-
const length = getTableLength(table);
|
|
2351
|
-
const data = new Array(length);
|
|
2352
|
-
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
2353
|
-
data[rowIndex] = getTableRowAsArray(table, rowIndex);
|
|
2354
|
-
}
|
|
2355
|
-
return {
|
|
2356
|
-
shape: "array-row-table",
|
|
2357
|
-
schema: table.schema,
|
|
2358
|
-
data
|
|
2359
|
-
};
|
|
2360
|
-
}
|
|
2361
|
-
function convertToObjectRowTable(table) {
|
|
2362
|
-
if (table.shape === "object-row-table") {
|
|
2363
|
-
return table;
|
|
2364
|
-
}
|
|
2365
|
-
const length = getTableLength(table);
|
|
2366
|
-
const data = new Array(length);
|
|
2367
|
-
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
2368
|
-
data[rowIndex] = getTableRowAsObject(table, rowIndex);
|
|
2411
|
+
if (data && typeof data === "object") {
|
|
2412
|
+
return "columnar-table";
|
|
2369
2413
|
}
|
|
2370
|
-
|
|
2371
|
-
shape: "object-row-table",
|
|
2372
|
-
schema: table.schema,
|
|
2373
|
-
data
|
|
2374
|
-
};
|
|
2375
|
-
}
|
|
2376
|
-
function convertToArrowTable(table) {
|
|
2377
|
-
const schema = table.schema || deduceTableSchema(table);
|
|
2378
|
-
const arrowTable = convertTableToArrow({ ...table, schema });
|
|
2379
|
-
return {
|
|
2380
|
-
shape: "arrow-table",
|
|
2381
|
-
schema,
|
|
2382
|
-
data: arrowTable
|
|
2383
|
-
};
|
|
2414
|
+
throw new Error("invalid table");
|
|
2384
2415
|
}
|
|
2385
2416
|
|
|
2386
2417
|
// ../core/src/schema-utils/deprecated.ts
|
|
@@ -2723,8 +2754,19 @@ function projectArrowTable(source, selections) {
|
|
|
2723
2754
|
// ../core/src/scan/arrow-execution/filter-arrow-table.ts
|
|
2724
2755
|
var arrow7 = __toESM(require("apache-arrow"), 1);
|
|
2725
2756
|
function filterArrowTable(source, predicate, options = {}) {
|
|
2726
|
-
var _a, _b, _c;
|
|
2727
2757
|
validateColumnarPredicate(predicate, new Set(source.schema.fields.map((field) => field.name)));
|
|
2758
|
+
const columnNames = getColumnarPredicateColumns(predicate);
|
|
2759
|
+
return filterArrowRows(
|
|
2760
|
+
source,
|
|
2761
|
+
(batch) => {
|
|
2762
|
+
const columns = getPredicateColumns(new arrow7.Table(source.schema, [batch]), columnNames);
|
|
2763
|
+
return (rowIndex) => evaluatePredicate(predicate, columns, rowIndex) === true;
|
|
2764
|
+
},
|
|
2765
|
+
options
|
|
2766
|
+
);
|
|
2767
|
+
}
|
|
2768
|
+
function filterArrowRows(source, selectBatch, options = {}) {
|
|
2769
|
+
var _a, _b, _c;
|
|
2728
2770
|
let remaining = options.limit ?? Infinity;
|
|
2729
2771
|
if (remaining !== Infinity && (!Number.isSafeInteger(remaining) || remaining < 0)) {
|
|
2730
2772
|
throw new Error("Arrow filter limit must be a non-negative safe integer.");
|
|
@@ -2735,12 +2777,11 @@ function filterArrowTable(source, predicate, options = {}) {
|
|
|
2735
2777
|
if (remaining === 0) break;
|
|
2736
2778
|
(_b = options.signal) == null ? void 0 : _b.throwIfAborted();
|
|
2737
2779
|
const data = new arrow7.Table(source.schema, [batch]);
|
|
2738
|
-
const
|
|
2780
|
+
const selectRow = selectBatch(batch);
|
|
2739
2781
|
const indices = [];
|
|
2740
2782
|
for (let rowIndex = 0; rowIndex < batch.numRows && indices.length < remaining; rowIndex++) {
|
|
2741
2783
|
(_c = options.signal) == null ? void 0 : _c.throwIfAborted();
|
|
2742
|
-
if (
|
|
2743
|
-
indices.push(rowIndex);
|
|
2784
|
+
if (selectRow(rowIndex)) indices.push(rowIndex);
|
|
2744
2785
|
}
|
|
2745
2786
|
remaining -= indices.length;
|
|
2746
2787
|
if (indices.length === 0) continue;
|
|
@@ -3476,7 +3517,7 @@ function throwIfAborted2(signal) {
|
|
|
3476
3517
|
|
|
3477
3518
|
// dist/duckdb-sql-source.js
|
|
3478
3519
|
var import_apache_arrow = require("apache-arrow");
|
|
3479
|
-
var VERSION2 = true ? "5.0.0-beta.
|
|
3520
|
+
var VERSION2 = true ? "5.0.0-beta.8" : "latest";
|
|
3480
3521
|
var DuckDBSQLSource = {
|
|
3481
3522
|
dataType: null,
|
|
3482
3523
|
batchType: null,
|
|
@@ -3515,7 +3556,7 @@ var DuckDBSQLSource = {
|
|
|
3515
3556
|
},
|
|
3516
3557
|
defaultOptions: SQL_SOURCE_DEFAULT_OPTIONS,
|
|
3517
3558
|
testURL: (url) => /^duckdb:\/\//i.test(url),
|
|
3518
|
-
|
|
3559
|
+
createDataSourceSync: (data, options, coreApi) => new DuckDBSQLDataSource(data, options, coreApi)
|
|
3519
3560
|
};
|
|
3520
3561
|
var DuckDBSQLDataSource = class extends SQLDataSource {
|
|
3521
3562
|
/** Uploads an Arrow table through IPC. Supported by the browser DuckDB-Wasm adapter. */
|
|
@@ -3793,7 +3834,7 @@ function getDuckDBDatabasePath(url, options) {
|
|
|
3793
3834
|
}
|
|
3794
3835
|
|
|
3795
3836
|
// dist/snowflake-sql-source.js
|
|
3796
|
-
var VERSION3 = true ? "5.0.0-beta.
|
|
3837
|
+
var VERSION3 = true ? "5.0.0-beta.8" : "latest";
|
|
3797
3838
|
var SnowflakeSQLSource = {
|
|
3798
3839
|
dataType: null,
|
|
3799
3840
|
batchType: null,
|
|
@@ -3832,7 +3873,7 @@ var SnowflakeSQLSource = {
|
|
|
3832
3873
|
},
|
|
3833
3874
|
defaultOptions: SQL_SOURCE_DEFAULT_OPTIONS,
|
|
3834
3875
|
testURL: (url) => /^(sql\+snowflake|snowflake):\/\//i.test(url),
|
|
3835
|
-
|
|
3876
|
+
createDataSourceSync: (data, options, coreApi) => new SnowflakeSQLDataSource(data, options, coreApi)
|
|
3836
3877
|
};
|
|
3837
3878
|
var SnowflakeSQLDataSource = class extends SQLDataSource {
|
|
3838
3879
|
constructor(data, options, coreApi) {
|
|
@@ -3999,304 +4040,12 @@ function getSnowflakeBaseUrl(url, options) {
|
|
|
3999
4040
|
}
|
|
4000
4041
|
|
|
4001
4042
|
// ../core/src/scan/parse-sql-predicate.ts
|
|
4002
|
-
var
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
function parseSQLPredicate(source, options = {}) {
|
|
4006
|
-
const parser = new SQLPredicateParser(
|
|
4007
|
-
source,
|
|
4008
|
-
options.parameters ?? {},
|
|
4009
|
-
options.preserveParameters === true
|
|
4010
|
-
);
|
|
4011
|
-
const predicate = parser.parse();
|
|
4043
|
+
var import_sql = require("@math.gl/expressions/sql");
|
|
4044
|
+
function parseSQLPredicate(source, options) {
|
|
4045
|
+
const predicate = options ? (0, import_sql.parseSQLPredicate)(source, options) : (0, import_sql.parseSQLPredicate)(source);
|
|
4012
4046
|
validateSQLPredicate(predicate);
|
|
4013
4047
|
return predicate;
|
|
4014
4048
|
}
|
|
4015
|
-
var SQLPredicateParser = class {
|
|
4016
|
-
/** Token stream parsed by this parser instance. */
|
|
4017
|
-
tokens;
|
|
4018
|
-
/** Named scalar parameters available to the expression. */
|
|
4019
|
-
parameters;
|
|
4020
|
-
/** Whether named parameters remain references in the parsed AST. */
|
|
4021
|
-
preserveParameters;
|
|
4022
|
-
/** Current index in the token stream. */
|
|
4023
|
-
position = 0;
|
|
4024
|
-
constructor(source, parameters, preserveParameters) {
|
|
4025
|
-
this.tokens = tokenizeSQLPredicate(source);
|
|
4026
|
-
this.parameters = parameters;
|
|
4027
|
-
this.preserveParameters = preserveParameters;
|
|
4028
|
-
}
|
|
4029
|
-
/** Parses the complete token stream. */
|
|
4030
|
-
parse() {
|
|
4031
|
-
const predicate = this.parseOr(0);
|
|
4032
|
-
this.takeSymbol(";");
|
|
4033
|
-
const token = this.peek();
|
|
4034
|
-
if (token) {
|
|
4035
|
-
throw new Error(`SQL predicate contains unexpected token ${JSON.stringify(token.value)}`);
|
|
4036
|
-
}
|
|
4037
|
-
return predicate;
|
|
4038
|
-
}
|
|
4039
|
-
/** Parses left-associative disjunction. */
|
|
4040
|
-
parseOr(depth) {
|
|
4041
|
-
let predicate = this.parseAnd(depth + 1);
|
|
4042
|
-
while (this.takeKeyword("OR")) {
|
|
4043
|
-
predicate = combineLogicalPredicate("or", predicate, this.parseAnd(depth + 1));
|
|
4044
|
-
}
|
|
4045
|
-
return predicate;
|
|
4046
|
-
}
|
|
4047
|
-
/** Parses left-associative conjunction. */
|
|
4048
|
-
parseAnd(depth) {
|
|
4049
|
-
let predicate = this.parseNot(depth + 1);
|
|
4050
|
-
while (this.takeKeyword("AND")) {
|
|
4051
|
-
predicate = combineLogicalPredicate("and", predicate, this.parseNot(depth + 1));
|
|
4052
|
-
}
|
|
4053
|
-
return predicate;
|
|
4054
|
-
}
|
|
4055
|
-
/** Parses boolean negation and parenthesized predicates. */
|
|
4056
|
-
parseNot(depth) {
|
|
4057
|
-
this.assertDepth(depth);
|
|
4058
|
-
if (this.takeKeyword("NOT")) {
|
|
4059
|
-
return { op: "not", args: [this.parseNot(depth + 1)] };
|
|
4060
|
-
}
|
|
4061
|
-
if (this.takeSymbol("(")) {
|
|
4062
|
-
const predicate = this.parseOr(depth + 1);
|
|
4063
|
-
this.expectSymbol(")");
|
|
4064
|
-
return predicate;
|
|
4065
|
-
}
|
|
4066
|
-
return this.parseLeaf();
|
|
4067
|
-
}
|
|
4068
|
-
/** Parses one comparison, membership, or null predicate. */
|
|
4069
|
-
parseLeaf() {
|
|
4070
|
-
var _a, _b;
|
|
4071
|
-
const property = this.parseProperty();
|
|
4072
|
-
if (this.takeKeyword("IS")) {
|
|
4073
|
-
const negated = this.takeKeyword("NOT");
|
|
4074
|
-
this.expectKeyword("NULL");
|
|
4075
|
-
const predicate = { op: "isNull", args: [property] };
|
|
4076
|
-
return negated ? { op: "not", args: [predicate] } : predicate;
|
|
4077
|
-
}
|
|
4078
|
-
const negatedMembership = this.takeKeyword("NOT");
|
|
4079
|
-
if (negatedMembership || this.peekKeyword("IN")) {
|
|
4080
|
-
this.expectKeyword("IN");
|
|
4081
|
-
this.expectSymbol("(");
|
|
4082
|
-
if (((_a = this.peek()) == null ? void 0 : _a.kind) === "symbol" && ((_b = this.peek()) == null ? void 0 : _b.value) === ")") {
|
|
4083
|
-
throw new Error("SQL predicate IN requires at least one scalar value");
|
|
4084
|
-
}
|
|
4085
|
-
const values = [this.parseValue()];
|
|
4086
|
-
while (this.takeSymbol(",")) {
|
|
4087
|
-
values.push(this.parseValue());
|
|
4088
|
-
}
|
|
4089
|
-
this.expectSymbol(")");
|
|
4090
|
-
const predicate = { op: "in", args: [property, values] };
|
|
4091
|
-
return negatedMembership ? { op: "not", args: [predicate] } : predicate;
|
|
4092
|
-
}
|
|
4093
|
-
const token = this.take();
|
|
4094
|
-
if ((token == null ? void 0 : token.kind) !== "symbol" || !["=", "!=", "<>", "<", "<=", ">", ">="].includes(token.value)) {
|
|
4095
|
-
throw new Error("SQL predicate expected a comparison, IN, or IS NULL operator");
|
|
4096
|
-
}
|
|
4097
|
-
const operator = token.value === "!=" ? "<>" : token.value;
|
|
4098
|
-
return {
|
|
4099
|
-
op: operator,
|
|
4100
|
-
args: [property, this.parseValue()]
|
|
4101
|
-
};
|
|
4102
|
-
}
|
|
4103
|
-
/** Parses an identifier into a property reference. */
|
|
4104
|
-
parseProperty() {
|
|
4105
|
-
const token = this.take();
|
|
4106
|
-
if ((token == null ? void 0 : token.kind) !== "identifier") {
|
|
4107
|
-
throw new Error("SQL predicate expected a column identifier");
|
|
4108
|
-
}
|
|
4109
|
-
return token.quoted ? { property: token.value, quoted: true } : { property: token.value };
|
|
4110
|
-
}
|
|
4111
|
-
/** Parses one scalar literal or named parameter. */
|
|
4112
|
-
parseValue() {
|
|
4113
|
-
const negative = this.takeSymbol("-");
|
|
4114
|
-
const token = this.take();
|
|
4115
|
-
if (!token) {
|
|
4116
|
-
throw new Error("SQL predicate expected a scalar value");
|
|
4117
|
-
}
|
|
4118
|
-
if (negative && token.kind !== "number") {
|
|
4119
|
-
throw new Error("SQL predicate only permits unary minus on numeric literals");
|
|
4120
|
-
}
|
|
4121
|
-
if (token.kind === "number") {
|
|
4122
|
-
return parseNumericLiteral(negative ? `-${token.value}` : token.value);
|
|
4123
|
-
}
|
|
4124
|
-
if (negative) {
|
|
4125
|
-
throw new Error("SQL predicate expected a numeric literal after unary minus");
|
|
4126
|
-
}
|
|
4127
|
-
if (token.kind === "string") {
|
|
4128
|
-
return token.value;
|
|
4129
|
-
}
|
|
4130
|
-
if (token.kind === "parameter") {
|
|
4131
|
-
if (this.preserveParameters) {
|
|
4132
|
-
return { parameter: token.value };
|
|
4133
|
-
}
|
|
4134
|
-
if (!Object.hasOwn(this.parameters, token.value)) {
|
|
4135
|
-
throw new Error(`SQL predicate parameter ":${token.value}" requires a value`);
|
|
4136
|
-
}
|
|
4137
|
-
const value = this.parameters[token.value];
|
|
4138
|
-
validateParameterValue(value, token.value);
|
|
4139
|
-
return value;
|
|
4140
|
-
}
|
|
4141
|
-
if (token.kind === "identifier" && !token.quoted && /^(TRUE|FALSE)$/i.test(token.value)) {
|
|
4142
|
-
return /^TRUE$/i.test(token.value);
|
|
4143
|
-
}
|
|
4144
|
-
if (token.kind === "identifier" && !token.quoted && /^NULL$/i.test(token.value)) {
|
|
4145
|
-
throw new Error("SQL predicate comparisons with NULL must use IS NULL or IS NOT NULL");
|
|
4146
|
-
}
|
|
4147
|
-
throw new Error(`SQL predicate does not support scalar token ${JSON.stringify(token.value)}`);
|
|
4148
|
-
}
|
|
4149
|
-
/** Rejects excessively nested inputs before recursion can exhaust the stack. */
|
|
4150
|
-
assertDepth(depth) {
|
|
4151
|
-
if (depth > MAXIMUM_EXPRESSION_DEPTH) {
|
|
4152
|
-
throw new Error("SQL predicate nesting exceeds its safe limit");
|
|
4153
|
-
}
|
|
4154
|
-
}
|
|
4155
|
-
/** Consumes one required keyword. */
|
|
4156
|
-
expectKeyword(keyword) {
|
|
4157
|
-
if (!this.takeKeyword(keyword)) {
|
|
4158
|
-
throw new Error(`SQL predicate expected ${keyword}`);
|
|
4159
|
-
}
|
|
4160
|
-
}
|
|
4161
|
-
/** Returns whether the next token is a keyword without consuming it. */
|
|
4162
|
-
peekKeyword(keyword) {
|
|
4163
|
-
const token = this.peek();
|
|
4164
|
-
return (token == null ? void 0 : token.kind) === "identifier" && !token.quoted && token.value.toUpperCase() === keyword;
|
|
4165
|
-
}
|
|
4166
|
-
/** Consumes one optional keyword. */
|
|
4167
|
-
takeKeyword(keyword) {
|
|
4168
|
-
if (!this.peekKeyword(keyword)) {
|
|
4169
|
-
return false;
|
|
4170
|
-
}
|
|
4171
|
-
this.position++;
|
|
4172
|
-
return true;
|
|
4173
|
-
}
|
|
4174
|
-
/** Consumes one required symbol. */
|
|
4175
|
-
expectSymbol(symbol) {
|
|
4176
|
-
if (!this.takeSymbol(symbol)) {
|
|
4177
|
-
throw new Error(`SQL predicate expected ${JSON.stringify(symbol)}`);
|
|
4178
|
-
}
|
|
4179
|
-
}
|
|
4180
|
-
/** Consumes one optional symbol. */
|
|
4181
|
-
takeSymbol(symbol) {
|
|
4182
|
-
const token = this.peek();
|
|
4183
|
-
if ((token == null ? void 0 : token.kind) !== "symbol" || token.value !== symbol) {
|
|
4184
|
-
return false;
|
|
4185
|
-
}
|
|
4186
|
-
this.position++;
|
|
4187
|
-
return true;
|
|
4188
|
-
}
|
|
4189
|
-
/** Consumes and returns the next token. */
|
|
4190
|
-
take() {
|
|
4191
|
-
const token = this.tokens[this.position];
|
|
4192
|
-
if (token) {
|
|
4193
|
-
this.position++;
|
|
4194
|
-
}
|
|
4195
|
-
return token;
|
|
4196
|
-
}
|
|
4197
|
-
/** Returns the next token without consuming it. */
|
|
4198
|
-
peek() {
|
|
4199
|
-
return this.tokens[this.position];
|
|
4200
|
-
}
|
|
4201
|
-
};
|
|
4202
|
-
function combineLogicalPredicate(operator, left, right) {
|
|
4203
|
-
return left.op === operator ? { op: operator, args: [...left.args, right] } : { op: operator, args: [left, right] };
|
|
4204
|
-
}
|
|
4205
|
-
function parseNumericLiteral(source) {
|
|
4206
|
-
if (/^-?\d+$/.test(source)) {
|
|
4207
|
-
const bigint = BigInt(source);
|
|
4208
|
-
if (bigint > BigInt(Number.MAX_SAFE_INTEGER) || bigint < BigInt(Number.MIN_SAFE_INTEGER)) {
|
|
4209
|
-
return bigint;
|
|
4210
|
-
}
|
|
4211
|
-
}
|
|
4212
|
-
const number = Number(source);
|
|
4213
|
-
if (!Number.isFinite(number)) {
|
|
4214
|
-
throw new Error("SQL predicate numeric literals must be finite");
|
|
4215
|
-
}
|
|
4216
|
-
return number;
|
|
4217
|
-
}
|
|
4218
|
-
function validateParameterValue(value, name) {
|
|
4219
|
-
const probe = { op: "=", args: [{ property: "_" }, value] };
|
|
4220
|
-
try {
|
|
4221
|
-
validateSQLPredicate(probe);
|
|
4222
|
-
} catch {
|
|
4223
|
-
throw new Error(`SQL predicate parameter ":${name}" has an unsupported value`);
|
|
4224
|
-
}
|
|
4225
|
-
}
|
|
4226
|
-
function tokenizeSQLPredicate(source) {
|
|
4227
|
-
if (typeof source !== "string" || source.trim().length === 0 || source.length > MAXIMUM_SQL_LENGTH) {
|
|
4228
|
-
throw new Error("SQL predicate requires a non-empty, safely bounded expression");
|
|
4229
|
-
}
|
|
4230
|
-
const tokens = [];
|
|
4231
|
-
let position = 0;
|
|
4232
|
-
while (position < source.length) {
|
|
4233
|
-
const character = source[position];
|
|
4234
|
-
if (/\s/.test(character)) {
|
|
4235
|
-
position++;
|
|
4236
|
-
continue;
|
|
4237
|
-
}
|
|
4238
|
-
if (character === "'") {
|
|
4239
|
-
const result = readQuotedToken(source, position, "'", "'");
|
|
4240
|
-
tokens.push({ kind: "string", value: result.value });
|
|
4241
|
-
position = result.position;
|
|
4242
|
-
} else if (character === '"') {
|
|
4243
|
-
const result = readQuotedToken(source, position, '"', '"');
|
|
4244
|
-
tokens.push({ kind: "identifier", value: result.value, quoted: true });
|
|
4245
|
-
position = result.position;
|
|
4246
|
-
} else if (character === ":") {
|
|
4247
|
-
const match = /^[A-Za-z_][A-Za-z0-9_]*/.exec(source.slice(position + 1));
|
|
4248
|
-
if (!match) {
|
|
4249
|
-
throw new Error(`SQL predicate contains an invalid parameter at character ${position}`);
|
|
4250
|
-
}
|
|
4251
|
-
tokens.push({ kind: "parameter", value: match[0] });
|
|
4252
|
-
position += match[0].length + 1;
|
|
4253
|
-
} else {
|
|
4254
|
-
const numberMatch = /^(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/.exec(source.slice(position));
|
|
4255
|
-
const identifierMatch = /^[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*/.exec(
|
|
4256
|
-
source.slice(position)
|
|
4257
|
-
);
|
|
4258
|
-
if (numberMatch) {
|
|
4259
|
-
tokens.push({ kind: "number", value: numberMatch[0] });
|
|
4260
|
-
position += numberMatch[0].length;
|
|
4261
|
-
} else if (identifierMatch) {
|
|
4262
|
-
tokens.push({ kind: "identifier", value: identifierMatch[0] });
|
|
4263
|
-
position += identifierMatch[0].length;
|
|
4264
|
-
} else {
|
|
4265
|
-
const twoCharacters = source.slice(position, position + 2);
|
|
4266
|
-
if (["<=", ">=", "<>", "!="].includes(twoCharacters)) {
|
|
4267
|
-
tokens.push({ kind: "symbol", value: twoCharacters });
|
|
4268
|
-
position += 2;
|
|
4269
|
-
} else if ("(),;-=<>".includes(character)) {
|
|
4270
|
-
tokens.push({ kind: "symbol", value: character });
|
|
4271
|
-
position++;
|
|
4272
|
-
} else {
|
|
4273
|
-
throw new Error(`SQL predicate contains an unsupported token at character ${position}`);
|
|
4274
|
-
}
|
|
4275
|
-
}
|
|
4276
|
-
}
|
|
4277
|
-
if (tokens.length > MAXIMUM_SQL_TOKENS) {
|
|
4278
|
-
throw new Error("SQL predicate exceeds its safe token limit");
|
|
4279
|
-
}
|
|
4280
|
-
}
|
|
4281
|
-
return tokens;
|
|
4282
|
-
}
|
|
4283
|
-
function readQuotedToken(source, start, quote, escapedQuote) {
|
|
4284
|
-
let value = "";
|
|
4285
|
-
let position = start + 1;
|
|
4286
|
-
while (position < source.length) {
|
|
4287
|
-
if (source[position] !== quote) {
|
|
4288
|
-
value += source[position++];
|
|
4289
|
-
continue;
|
|
4290
|
-
}
|
|
4291
|
-
if (source[position + 1] === escapedQuote) {
|
|
4292
|
-
value += quote;
|
|
4293
|
-
position += 2;
|
|
4294
|
-
continue;
|
|
4295
|
-
}
|
|
4296
|
-
return { value, position: position + 1 };
|
|
4297
|
-
}
|
|
4298
|
-
throw new Error(`SQL predicate contains an unterminated quoted value at character ${start}`);
|
|
4299
|
-
}
|
|
4300
4049
|
|
|
4301
4050
|
// ../core/src/scan/bind-sql-predicate.ts
|
|
4302
4051
|
function bindSQLPredicate(predicate, parameters) {
|