@math.gl/sql 5.0.0-beta.11 → 5.0.0-beta.12
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/dist/arrow/aggregates.js +1 -1
- package/dist/arrow/aggregates.js.map +1 -1
- package/dist/arrow/buffers.js.map +1 -1
- package/dist/arrow/cast.d.ts +1 -1
- package/dist/arrow/cast.js +1 -1
- package/dist/arrow/cast.js.map +1 -1
- package/dist/arrow/compiler.d.ts.map +1 -1
- package/dist/arrow/compiler.js +146 -29
- package/dist/arrow/compiler.js.map +1 -1
- package/dist/arrow/index.cjs +124 -23
- package/dist/arrow/index.cjs.map +1 -1
- package/dist/arrow/index.d.ts.map +1 -1
- package/dist/arrow/index.js.map +1 -1
- package/dist/arrow/list-values.d.ts.map +1 -1
- package/dist/arrow/list-values.js +27 -6
- package/dist/arrow/list-values.js.map +1 -1
- package/dist/arrow/predicate.d.ts.map +1 -1
- package/dist/arrow/predicate.js.map +1 -1
- package/dist/arrow/query-arrow-sql.d.ts +2 -2
- package/dist/arrow/query-arrow-sql.d.ts.map +1 -1
- package/dist/arrow/query-arrow-sql.js +40 -8
- package/dist/arrow/query-arrow-sql.js.map +1 -1
- package/dist/arrow/query-arrow-table.d.ts +1 -1
- package/dist/arrow/query-arrow-table.d.ts.map +1 -1
- package/dist/arrow/query-arrow-table.js +1 -1
- package/dist/arrow/query-arrow-table.js.map +1 -1
- package/dist/arrow/query-worker.d.ts +1 -1
- package/dist/arrow/query-worker.d.ts.map +1 -1
- package/dist/arrow/query-worker.js +1 -1
- package/dist/arrow/query-worker.js.map +1 -1
- package/dist/arrow/registry.d.ts.map +1 -1
- package/dist/arrow/registry.js +1 -0
- package/dist/arrow/registry.js.map +1 -1
- package/dist/arrow/relational-query.js +2 -2
- package/dist/arrow/relational-query.js.map +1 -1
- package/dist/arrow/temporal-cast.js.map +1 -1
- package/dist/arrow/types.d.ts.map +1 -1
- package/dist/arrow/unnest-arrow-column.d.ts +22 -0
- package/dist/arrow/unnest-arrow-column.d.ts.map +1 -0
- package/dist/arrow/unnest-arrow-column.js +112 -0
- package/dist/arrow/unnest-arrow-column.js.map +1 -0
- package/dist/arrow/worker.cjs +130 -29
- package/dist/arrow/worker.cjs.map +1 -1
- package/dist/arrow/worker.d.ts +1 -1
- package/dist/arrow/worker.d.ts.map +1 -1
- package/dist/arrow/worker.js +1 -1
- package/dist/arrow/worker.js.map +1 -1
- package/dist/{color → color-functions}/index.cjs +2 -2
- package/dist/{color → color-functions}/index.cjs.map +1 -1
- package/dist/color-functions/index.d.ts.map +1 -0
- package/dist/color-functions/index.js.map +1 -0
- package/dist/expressions/ast.js +3 -1
- package/dist/expressions/ast.js.map +1 -1
- package/dist/expressions/expression-eval.d.ts +10 -1
- package/dist/expressions/expression-eval.d.ts.map +1 -1
- package/dist/expressions/expression-eval.js.map +1 -1
- package/dist/expressions/index.cjs +1 -1
- package/dist/expressions/index.cjs.map +1 -1
- package/dist/index.cjs +2792 -2363
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/{math → math-functions}/index.cjs +2 -2
- package/dist/{math → math-functions}/index.cjs.map +1 -1
- package/dist/math-functions/index.d.ts.map +1 -0
- package/dist/math-functions/index.js.map +1 -0
- package/dist/parser/bind-sql-predicate.d.ts.map +1 -0
- package/dist/parser/bind-sql-predicate.js.map +1 -0
- package/dist/{sql → parser}/index.cjs +348 -129
- package/dist/parser/index.cjs.map +6 -0
- package/dist/{sql → parser}/index.d.ts +2 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/{sql → parser}/index.js +1 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/parameter-snapshots.d.ts +21 -0
- package/dist/parser/parameter-snapshots.d.ts.map +1 -0
- package/dist/parser/parameter-snapshots.js +85 -0
- package/dist/parser/parameter-snapshots.js.map +1 -0
- package/dist/{sql → parser}/parse-sql-expression.d.ts +8 -2
- package/dist/parser/parse-sql-expression.d.ts.map +1 -0
- package/dist/{sql → parser}/parse-sql-expression.js +51 -5
- package/dist/parser/parse-sql-expression.js.map +1 -0
- package/dist/parser/parse-sql-predicate.d.ts.map +1 -0
- package/dist/parser/parse-sql-predicate.js.map +1 -0
- package/dist/{sql → parser}/parse-sql-query.d.ts +2 -1
- package/dist/parser/parse-sql-query.d.ts.map +1 -0
- package/dist/{sql → parser}/parse-sql-query.js +21 -6
- package/dist/parser/parse-sql-query.js.map +1 -0
- package/dist/{sql → parser}/parse-sql-select.d.ts +4 -2
- package/dist/parser/parse-sql-select.d.ts.map +1 -0
- package/dist/{sql → parser}/parse-sql-select.js +6 -3
- package/dist/parser/parse-sql-select.js.map +1 -0
- package/dist/{sql → parser}/parse-sql-statement.d.ts +9 -5
- package/dist/parser/parse-sql-statement.d.ts.map +1 -0
- package/dist/{sql → parser}/parse-sql-statement.js +39 -14
- package/dist/parser/parse-sql-statement.js.map +1 -0
- package/dist/parser/query-types.d.ts.map +1 -0
- package/dist/parser/query-types.js.map +1 -0
- package/dist/parser/sql-parameters.d.ts +29 -0
- package/dist/parser/sql-parameters.d.ts.map +1 -0
- package/dist/parser/sql-parameters.js +110 -0
- package/dist/parser/sql-parameters.js.map +1 -0
- package/dist/parser/sql-parse-error.d.ts.map +1 -0
- package/dist/parser/sql-parse-error.js.map +1 -0
- package/dist/parser/sql-predicate-schema.d.ts.map +1 -0
- package/dist/parser/sql-predicate-schema.js.map +1 -0
- package/dist/parser/sql-predicate-types.d.ts.map +1 -0
- package/dist/parser/sql-predicate-types.js.map +1 -0
- package/dist/parser/sql-predicate.d.ts.map +1 -0
- package/dist/parser/sql-predicate.js.map +1 -0
- package/dist/scales/arrow-domains.d.ts +8 -1
- package/dist/scales/arrow-domains.d.ts.map +1 -1
- package/dist/scales/arrow-domains.js +48 -6
- package/dist/scales/arrow-domains.js.map +1 -1
- package/dist/scales/arrow-scales.d.ts +28 -4
- package/dist/scales/arrow-scales.d.ts.map +1 -1
- package/dist/scales/arrow-scales.js +158 -12
- package/dist/scales/arrow-scales.js.map +1 -1
- package/dist/scales/compile-scale.d.ts +1 -6
- package/dist/scales/compile-scale.d.ts.map +1 -1
- package/dist/scales/compile-scale.js +1 -191
- package/dist/scales/compile-scale.js.map +1 -1
- package/dist/scales/conformance.cjs +180 -0
- package/dist/scales/conformance.cjs.map +6 -0
- package/dist/scales/conformance.d.ts +26 -0
- package/dist/scales/conformance.d.ts.map +1 -0
- package/dist/scales/conformance.js +164 -0
- package/dist/scales/conformance.js.map +1 -0
- package/dist/scales/hdr-colors.d.ts +1 -12
- package/dist/scales/hdr-colors.d.ts.map +1 -1
- package/dist/scales/hdr-colors.js +1 -111
- package/dist/scales/hdr-colors.js.map +1 -1
- package/dist/scales/index.cjs +3738 -618
- package/dist/scales/index.cjs.map +3 -3
- package/dist/scales/index.d.ts +2 -1
- package/dist/scales/index.d.ts.map +1 -1
- package/dist/scales/index.js +2 -1
- package/dist/scales/index.js.map +1 -1
- package/dist/scales/palettes.d.ts +1 -4
- package/dist/scales/palettes.d.ts.map +1 -1
- package/dist/scales/palettes.js +1 -81
- package/dist/scales/palettes.js.map +1 -1
- package/dist/scales/parse-sql-scale.d.ts +14 -1
- package/dist/scales/parse-sql-scale.d.ts.map +1 -1
- package/dist/scales/parse-sql-scale.js +110 -18
- package/dist/scales/parse-sql-scale.js.map +1 -1
- package/dist/scales/quantile-sketch.d.ts +1 -21
- package/dist/scales/quantile-sketch.d.ts.map +1 -1
- package/dist/scales/quantile-sketch.js +1 -104
- package/dist/scales/quantile-sketch.js.map +1 -1
- package/dist/scales/scale-types.d.ts +1 -91
- package/dist/scales/scale-types.d.ts.map +1 -1
- package/dist/scales/scale-types.js +1 -115
- package/dist/scales/scale-types.js.map +1 -1
- package/dist/scales/streaming-domains.d.ts.map +1 -1
- package/dist/scales/streaming-domains.js +8 -2
- package/dist/scales/streaming-domains.js.map +1 -1
- package/package.json +19 -19
- package/src/arrow/aggregates.ts +1 -1
- package/src/arrow/buffers.ts +1 -1
- package/src/arrow/cast.ts +3 -3
- package/src/arrow/compiler.ts +155 -36
- package/src/arrow/index.ts +1 -1
- package/src/arrow/list-values.ts +28 -7
- package/src/arrow/predicate.ts +1 -1
- package/src/arrow/query-arrow-sql.ts +38 -10
- package/src/arrow/query-arrow-table.ts +3 -3
- package/src/arrow/query-worker.ts +5 -1
- package/src/arrow/registry.ts +1 -0
- package/src/arrow/relational-query.ts +2 -2
- package/src/arrow/temporal-cast.ts +1 -1
- package/src/arrow/types.ts +1 -1
- package/src/arrow/unnest-arrow-column.ts +145 -0
- package/src/arrow/worker.ts +6 -2
- package/src/expressions/ast.ts +3 -1
- package/src/expressions/expression-eval.ts +10 -1
- package/src/index.ts +14 -0
- package/src/{math → math-functions}/index.ts +2 -2
- package/src/{sql → parser}/index.ts +15 -0
- package/src/parser/parameter-snapshots.ts +103 -0
- package/src/{sql → parser}/parse-sql-expression.ts +49 -6
- package/src/{sql → parser}/parse-sql-query.ts +24 -6
- package/src/{sql → parser}/parse-sql-select.ts +14 -8
- package/src/{sql → parser}/parse-sql-statement.ts +42 -24
- package/src/{sql → parser}/query-types.ts +1 -1
- package/src/parser/sql-parameters.ts +174 -0
- package/src/scales/arrow-domains.ts +66 -7
- package/src/scales/arrow-scales.ts +221 -14
- package/src/scales/compile-scale.ts +1 -213
- package/src/scales/conformance.ts +186 -0
- package/src/scales/hdr-colors.ts +1 -122
- package/src/scales/index.ts +3 -1
- package/src/scales/palettes.ts +1 -82
- package/src/scales/parse-sql-scale.ts +126 -21
- package/src/scales/quantile-sketch.ts +1 -102
- package/src/scales/scale-types.ts +1 -220
- package/src/scales/streaming-domains.ts +8 -2
- package/dist/color/index.d.ts.map +0 -1
- package/dist/color/index.js.map +0 -1
- package/dist/math/index.d.ts.map +0 -1
- package/dist/math/index.js.map +0 -1
- package/dist/scales/arrow-scales.cjs +0 -3837
- package/dist/scales/arrow-scales.cjs.map +0 -6
- package/dist/sql/bind-sql-predicate.d.ts.map +0 -1
- package/dist/sql/bind-sql-predicate.js.map +0 -1
- package/dist/sql/index.cjs.map +0 -6
- package/dist/sql/index.d.ts.map +0 -1
- package/dist/sql/index.js.map +0 -1
- package/dist/sql/parse-sql-expression.d.ts.map +0 -1
- package/dist/sql/parse-sql-expression.js.map +0 -1
- package/dist/sql/parse-sql-predicate.d.ts.map +0 -1
- package/dist/sql/parse-sql-predicate.js.map +0 -1
- package/dist/sql/parse-sql-query.d.ts.map +0 -1
- package/dist/sql/parse-sql-query.js.map +0 -1
- package/dist/sql/parse-sql-select.d.ts.map +0 -1
- package/dist/sql/parse-sql-select.js.map +0 -1
- package/dist/sql/parse-sql-statement.d.ts.map +0 -1
- package/dist/sql/parse-sql-statement.js.map +0 -1
- package/dist/sql/query-types.d.ts.map +0 -1
- package/dist/sql/query-types.js.map +0 -1
- package/dist/sql/sql-parse-error.d.ts.map +0 -1
- package/dist/sql/sql-parse-error.js.map +0 -1
- package/dist/sql/sql-predicate-schema.d.ts.map +0 -1
- package/dist/sql/sql-predicate-schema.js.map +0 -1
- package/dist/sql/sql-predicate-types.d.ts.map +0 -1
- package/dist/sql/sql-predicate-types.js.map +0 -1
- package/dist/sql/sql-predicate.d.ts.map +0 -1
- package/dist/sql/sql-predicate.js.map +0 -1
- package/src/expressions/vendor/jsep/README.md +0 -22
- /package/dist/{color → color-functions}/index.d.ts +0 -0
- /package/dist/{color → color-functions}/index.js +0 -0
- /package/dist/{math → math-functions}/index.d.ts +0 -0
- /package/dist/{math → math-functions}/index.js +0 -0
- /package/dist/{sql → parser}/bind-sql-predicate.d.ts +0 -0
- /package/dist/{sql → parser}/bind-sql-predicate.js +0 -0
- /package/dist/{sql → parser}/parse-sql-predicate.d.ts +0 -0
- /package/dist/{sql → parser}/parse-sql-predicate.js +0 -0
- /package/dist/{sql → parser}/query-types.d.ts +0 -0
- /package/dist/{sql → parser}/query-types.js +0 -0
- /package/dist/{sql → parser}/sql-parse-error.d.ts +0 -0
- /package/dist/{sql → parser}/sql-parse-error.js +0 -0
- /package/dist/{sql → parser}/sql-predicate-schema.d.ts +0 -0
- /package/dist/{sql → parser}/sql-predicate-schema.js +0 -0
- /package/dist/{sql → parser}/sql-predicate-types.d.ts +0 -0
- /package/dist/{sql → parser}/sql-predicate-types.js +0 -0
- /package/dist/{sql → parser}/sql-predicate.d.ts +0 -0
- /package/dist/{sql → parser}/sql-predicate.js +0 -0
- /package/src/{color → color-functions}/index.ts +0 -0
- /package/src/{sql → parser}/bind-sql-predicate.ts +0 -0
- /package/src/{sql → parser}/parse-sql-predicate.ts +0 -0
- /package/src/{sql → parser}/sql-parse-error.ts +0 -0
- /package/src/{sql → parser}/sql-predicate-schema.ts +0 -0
- /package/src/{sql → parser}/sql-predicate-types.ts +0 -0
- /package/src/{sql → parser}/sql-predicate.ts +0 -0
package/dist/arrow/worker.cjs
CHANGED
|
@@ -28,11 +28,11 @@ __export(worker_exports, {
|
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(worker_exports);
|
|
30
30
|
var import_apache_arrow10 = require("apache-arrow");
|
|
31
|
-
var import_arrow4 = require("@math.gl/arrow");
|
|
31
|
+
var import_arrow4 = require("@math.gl/core/arrow");
|
|
32
32
|
|
|
33
33
|
// dist/arrow/compiler.js
|
|
34
34
|
var import_apache_arrow6 = require("apache-arrow");
|
|
35
|
-
var import_utf82 = require("@math.gl/
|
|
35
|
+
var import_utf82 = require("@math.gl/core/utf8");
|
|
36
36
|
|
|
37
37
|
// dist/diagnostic-log.js
|
|
38
38
|
function reportDiagnosticError(log, error) {
|
|
@@ -1175,7 +1175,7 @@ function visitExpressionAST(value, visit, options) {
|
|
|
1175
1175
|
throw new Error("Invalid expression identifier");
|
|
1176
1176
|
break;
|
|
1177
1177
|
case "Literal":
|
|
1178
|
-
if (node.value !== null && !["number", "bigint", "boolean", "string"].includes(typeof node.value))
|
|
1178
|
+
if (node.value !== null && !["number", "bigint", "boolean", "string"].includes(typeof node.value) && !(node.value instanceof Uint8Array) && !(node.value instanceof Date && Number.isFinite(node.value.getTime())))
|
|
1179
1179
|
throw new Error("Unsupported expression literal");
|
|
1180
1180
|
if (node.raw !== void 0 && typeof node.raw !== "string")
|
|
1181
1181
|
throw new Error("Invalid literal annotation");
|
|
@@ -1531,7 +1531,7 @@ function validateValue(value, type) {
|
|
|
1531
1531
|
|
|
1532
1532
|
// dist/arrow/cast.js
|
|
1533
1533
|
var import_apache_arrow3 = require("apache-arrow");
|
|
1534
|
-
var import_utf8 = require("@math.gl/
|
|
1534
|
+
var import_utf8 = require("@math.gl/core/utf8");
|
|
1535
1535
|
|
|
1536
1536
|
// dist/arrow/temporal-cast.js
|
|
1537
1537
|
var import_apache_arrow2 = require("apache-arrow");
|
|
@@ -1817,6 +1817,7 @@ function createFunctionLookup(declarations = []) {
|
|
|
1817
1817
|
"array_float64",
|
|
1818
1818
|
"array_uint8",
|
|
1819
1819
|
"PACK_UNORM8",
|
|
1820
|
+
"EPOCH_MS",
|
|
1820
1821
|
"LIST_EXTRACT",
|
|
1821
1822
|
"STRUCT_EXTRACT",
|
|
1822
1823
|
"cast",
|
|
@@ -1987,7 +1988,20 @@ function compileArrayLiteral(ast, type) {
|
|
|
1987
1988
|
}
|
|
1988
1989
|
return value;
|
|
1989
1990
|
});
|
|
1990
|
-
const
|
|
1991
|
+
const typed = ast.typedValues;
|
|
1992
|
+
const matchingStorage = typed && typed.constructor === child.type.ArrayType && typed.length === values.length && values.every((value, index) => Object.is(value, typed[index]));
|
|
1993
|
+
const literal = matchingStorage ? new import_apache_arrow5.Vector([
|
|
1994
|
+
import_apache_arrow5.DataType.isList(listType) ? (0, import_apache_arrow5.makeData)({
|
|
1995
|
+
type: listType,
|
|
1996
|
+
length: 1,
|
|
1997
|
+
valueOffsets: Int32Array.of(0, values.length),
|
|
1998
|
+
child: (0, import_apache_arrow5.makeData)({ type: child.type, length: values.length, data: typed.slice() })
|
|
1999
|
+
}) : (0, import_apache_arrow5.makeData)({
|
|
2000
|
+
type: listType,
|
|
2001
|
+
length: 1,
|
|
2002
|
+
child: (0, import_apache_arrow5.makeData)({ type: child.type, length: values.length, data: typed.slice() })
|
|
2003
|
+
})
|
|
2004
|
+
]) : (0, import_apache_arrow5.vectorFromArray)([values], listType);
|
|
1991
2005
|
const dictionaryType = new import_apache_arrow5.Dictionary(listType, new import_apache_arrow5.Uint8());
|
|
1992
2006
|
let cached;
|
|
1993
2007
|
return (length) => {
|
|
@@ -1997,11 +2011,10 @@ function compileArrayLiteral(ast, type) {
|
|
|
1997
2011
|
const result = nullTupleVector(listType, length);
|
|
1998
2012
|
const data = result.data[0];
|
|
1999
2013
|
const childData = data.children[0];
|
|
2000
|
-
const components =
|
|
2014
|
+
const components = literal.data[0].children[0].values.subarray(0, listType.listSize);
|
|
2001
2015
|
for (let row = 0; row < length; row++) {
|
|
2002
2016
|
data.setValid(row, true);
|
|
2003
|
-
|
|
2004
|
-
components[row * listType.listSize + component] = values[component];
|
|
2017
|
+
childData.values.set(components, row * listType.listSize);
|
|
2005
2018
|
}
|
|
2006
2019
|
cached = result;
|
|
2007
2020
|
} else {
|
|
@@ -2048,7 +2061,7 @@ function compileArrowExpression(expression, options) {
|
|
|
2048
2061
|
validateMask(evaluation.activeRows, batch.numRows);
|
|
2049
2062
|
const active = evaluation.activeRows ? evaluation.activeRows.slice() : new Uint8Array(batch.numRows).fill(1);
|
|
2050
2063
|
const prepared = root.prepare(batch, active, {});
|
|
2051
|
-
const result = isTupleType(root.field.type) ? maskTupleVector(prepared.vector, active) : isNestedType(root.field.type) ? nestedVector(prepared.vector, root.field.type, active) : prepared.vector && !import_apache_arrow6.DataType.isDictionary(prepared.vector.type) && !active.some((value) => !value) ? prepared.vector : output(root.field, active, prepared.get);
|
|
2064
|
+
const result = isTupleType(root.field.type) ? maskTupleVector(prepared.vector, active) : isNestedType(root.field.type) ? nestedVector(prepared.vector, root.field.type, active) : prepared.vector && (root.constant || !import_apache_arrow6.DataType.isDictionary(prepared.vector.type) && !active.some((value) => !value)) ? prepared.vector : output(root.field, active, prepared.get);
|
|
2052
2065
|
(_b = evaluation.signal) == null ? void 0 : _b.throwIfAborted();
|
|
2053
2066
|
return result;
|
|
2054
2067
|
};
|
|
@@ -2253,10 +2266,13 @@ function bindNode(ast, options, expected, vectorInput = false) {
|
|
|
2253
2266
|
if (ast.type === "Literal") {
|
|
2254
2267
|
if (vectorInput && expected && import_apache_arrow6.DataType.isDictionary(expected))
|
|
2255
2268
|
throw new Error("Dictionary function arguments require a dictionary-encoded source column");
|
|
2256
|
-
|
|
2269
|
+
const date = ast.value instanceof Date ? ast.value : void 0;
|
|
2270
|
+
let value = date ? expected && import_apache_arrow6.DataType.isDate(expected) ? Math.floor(date.getTime() / 864e5) : BigInt(date.getTime()) * 1000n : ast.value;
|
|
2271
|
+
if (value instanceof Uint8Array)
|
|
2272
|
+
value = new Uint8Array(value);
|
|
2257
2273
|
if (expected && import_apache_arrow6.DataType.isInt(expected) && expected.bitWidth === 64 && typeof value === "number" && Number.isSafeInteger(value))
|
|
2258
2274
|
value = BigInt(value);
|
|
2259
|
-
const type = expected ?? (value === null ? new import_apache_arrow6.Null() : typeof value === "boolean" ? bool : typeof value === "number" ? new import_apache_arrow6.Float64() : typeof value === "bigint" ? new import_apache_arrow6.Int64() : new import_apache_arrow6.Utf8());
|
|
2275
|
+
const type = expected ?? (date ? new import_apache_arrow6.TimestampMicrosecond("UTC") : value instanceof Uint8Array ? new import_apache_arrow6.Binary() : value === null ? new import_apache_arrow6.Null() : typeof value === "boolean" ? bool : typeof value === "number" ? new import_apache_arrow6.Float64() : typeof value === "bigint" ? new import_apache_arrow6.Int64() : new import_apache_arrow6.Utf8());
|
|
2260
2276
|
if (value === null && isTupleType(type))
|
|
2261
2277
|
return {
|
|
2262
2278
|
field: new import_apache_arrow6.Field("literal", type, true),
|
|
@@ -2286,16 +2302,32 @@ function bindNode(ast, options, expected, vectorInput = false) {
|
|
|
2286
2302
|
const rounded = roundToType(type)(value);
|
|
2287
2303
|
if (typeof value === "number" && Number.isFinite(value) && !Number.isFinite(rounded))
|
|
2288
2304
|
throw new Error(`Numeric literal overflow for ${type}`);
|
|
2289
|
-
const encoded = typeof value === "string" ? encoder.encode(value) : void 0;
|
|
2305
|
+
const encoded = typeof value === "string" ? ast.utf8 instanceof Uint8Array && new TextDecoder("utf-8", { ignoreBOM: true }).decode(ast.utf8) === value ? new Uint8Array(ast.utf8) : encoder.encode(value) : void 0;
|
|
2290
2306
|
const range = encoded ? [encoded, 0, encoded.length] : void 0;
|
|
2307
|
+
const constant = {
|
|
2308
|
+
get: () => rounded,
|
|
2309
|
+
isNull: () => value === null,
|
|
2310
|
+
bytes: range ? () => range : void 0
|
|
2311
|
+
};
|
|
2291
2312
|
return {
|
|
2292
2313
|
field: new import_apache_arrow6.Field("literal", type, value === null),
|
|
2293
2314
|
hasKernel: false,
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2315
|
+
constant,
|
|
2316
|
+
prepare: (_batch, active) => {
|
|
2317
|
+
if (!encoded)
|
|
2318
|
+
return constant;
|
|
2319
|
+
let vector;
|
|
2320
|
+
return {
|
|
2321
|
+
...constant,
|
|
2322
|
+
// Comparisons only read bytes. Materialize physical UTF-8 only when a
|
|
2323
|
+
// projection or vector function actually requests a batch-sized vector.
|
|
2324
|
+
get vector() {
|
|
2325
|
+
if (!vector)
|
|
2326
|
+
vector = repeatUTF8(encoded, active);
|
|
2327
|
+
return vector;
|
|
2328
|
+
}
|
|
2329
|
+
};
|
|
2330
|
+
}
|
|
2299
2331
|
};
|
|
2300
2332
|
}
|
|
2301
2333
|
if (ast.type === "CallExpression")
|
|
@@ -2619,23 +2651,28 @@ function bindMembership(arguments_, options) {
|
|
|
2619
2651
|
throw new Error("IN requires a value and 1 to 4096 scalar literals");
|
|
2620
2652
|
const argument = bind(arguments_[0], options);
|
|
2621
2653
|
const utf8 = typeKey(argument.field.type) === "utf8";
|
|
2654
|
+
const binary = import_apache_arrow6.DataType.isBinary(argument.field.type) || import_apache_arrow6.DataType.isFixedSizeBinary(argument.field.type);
|
|
2622
2655
|
const literals = arguments_.slice(1).map((value) => bind(value, options, argument.field.type));
|
|
2656
|
+
const prepared = literals.map((value) => value.constant);
|
|
2657
|
+
const values = new Set(prepared.map((value) => value.get(0)));
|
|
2658
|
+
const ranges = utf8 ? prepared.map((value) => bytes(value, 0)).filter((range) => range !== null) : binary ? prepared.flatMap((value) => {
|
|
2659
|
+
const data = value.get(0);
|
|
2660
|
+
return data === null ? [] : [[data, 0, data.length]];
|
|
2661
|
+
}) : [];
|
|
2662
|
+
ranges.sort((a, b) => (0, import_utf82.compareUTF8)(a[0], a[1], a[2], b[0], b[1], b[2]));
|
|
2623
2663
|
return {
|
|
2624
2664
|
field: new import_apache_arrow6.Field("in", bool, argument.field.nullable || literals.some((value) => value.field.nullable)),
|
|
2625
2665
|
hasKernel: argument.hasKernel,
|
|
2626
2666
|
prepare(batch, active, context) {
|
|
2627
2667
|
const source = argument.prepare(batch, active, context);
|
|
2628
|
-
const constantMask = Uint8Array.of(1);
|
|
2629
|
-
const prepared = literals.map((value) => value.prepare(batch, constantMask, {}));
|
|
2630
|
-
const values = new Set(prepared.map((value) => value.get(0)));
|
|
2631
|
-
const ranges = utf8 ? prepared.map((value) => bytes(value, 0)).filter((range) => range !== null) : [];
|
|
2632
2668
|
return {
|
|
2633
2669
|
get(row) {
|
|
2634
|
-
if (utf8) {
|
|
2635
|
-
const
|
|
2670
|
+
if (utf8 || binary) {
|
|
2671
|
+
const data = binary ? source.get(row) : null;
|
|
2672
|
+
const value = utf8 ? bytes(source, row) : data === null ? null : [data, 0, data.length];
|
|
2636
2673
|
if (!value)
|
|
2637
2674
|
return null;
|
|
2638
|
-
if (ranges
|
|
2675
|
+
if (containsByteRange(ranges, value))
|
|
2639
2676
|
return true;
|
|
2640
2677
|
} else {
|
|
2641
2678
|
const value = source.get(row);
|
|
@@ -2650,6 +2687,45 @@ function bindMembership(arguments_, options) {
|
|
|
2650
2687
|
}
|
|
2651
2688
|
};
|
|
2652
2689
|
}
|
|
2690
|
+
function repeatUTF8(encoded, active) {
|
|
2691
|
+
const count = active.reduce((sum, value) => sum + value, 0);
|
|
2692
|
+
const data = new Uint8Array(count * encoded.length);
|
|
2693
|
+
const offsets = new Int32Array(active.length + 1);
|
|
2694
|
+
const validity = new Uint8Array(Math.ceil(active.length / 8));
|
|
2695
|
+
let position = 0;
|
|
2696
|
+
for (let row = 0; row < active.length; row++) {
|
|
2697
|
+
if (active[row]) {
|
|
2698
|
+
data.set(encoded, position);
|
|
2699
|
+
position += encoded.length;
|
|
2700
|
+
validity[row >> 3] |= 1 << (row & 7);
|
|
2701
|
+
}
|
|
2702
|
+
offsets[row + 1] = position;
|
|
2703
|
+
}
|
|
2704
|
+
return (0, import_apache_arrow6.makeVector)((0, import_apache_arrow6.makeData)({
|
|
2705
|
+
type: new import_apache_arrow6.Utf8(),
|
|
2706
|
+
length: active.length,
|
|
2707
|
+
data,
|
|
2708
|
+
valueOffsets: offsets,
|
|
2709
|
+
nullBitmap: validity,
|
|
2710
|
+
nullCount: active.length - count
|
|
2711
|
+
}));
|
|
2712
|
+
}
|
|
2713
|
+
function containsByteRange(ranges, value) {
|
|
2714
|
+
let low = 0;
|
|
2715
|
+
let high = ranges.length - 1;
|
|
2716
|
+
while (low <= high) {
|
|
2717
|
+
const middle = low + high >>> 1;
|
|
2718
|
+
const candidate = ranges[middle];
|
|
2719
|
+
const order = (0, import_utf82.compareUTF8)(value[0], value[1], value[2], candidate[0], candidate[1], candidate[2]);
|
|
2720
|
+
if (order === 0)
|
|
2721
|
+
return true;
|
|
2722
|
+
if (order < 0)
|
|
2723
|
+
high = middle - 1;
|
|
2724
|
+
else
|
|
2725
|
+
low = middle + 1;
|
|
2726
|
+
}
|
|
2727
|
+
return false;
|
|
2728
|
+
}
|
|
2653
2729
|
function bindLike(args, options, insensitive) {
|
|
2654
2730
|
if (args.length < 2 || args.length > 3)
|
|
2655
2731
|
throw new Error("LIKE requires two or three arguments");
|
|
@@ -2837,6 +2913,7 @@ function bindCall(ast, options, expected) {
|
|
|
2837
2913
|
"array_float64",
|
|
2838
2914
|
"array_uint8",
|
|
2839
2915
|
"PACK_UNORM8",
|
|
2916
|
+
"EPOCH_MS",
|
|
2840
2917
|
"LIST_EXTRACT",
|
|
2841
2918
|
"STRUCT_EXTRACT",
|
|
2842
2919
|
"cast",
|
|
@@ -2966,6 +3043,30 @@ function bindCall(ast, options, expected) {
|
|
|
2966
3043
|
}
|
|
2967
3044
|
if (name === "in")
|
|
2968
3045
|
return bindMembership(ast.arguments, options);
|
|
3046
|
+
if (name === "EPOCH_MS") {
|
|
3047
|
+
if (ast.arguments.length !== 1)
|
|
3048
|
+
throw new Error("EPOCH_MS requires one argument");
|
|
3049
|
+
const argument = bind(ast.arguments[0], options);
|
|
3050
|
+
const key = typeKey(argument.field.type);
|
|
3051
|
+
if (key !== "date32" && !key.startsWith("timestamp_us:")) {
|
|
3052
|
+
throw new Error("EPOCH_MS requires DATE or microsecond TIMESTAMP");
|
|
3053
|
+
}
|
|
3054
|
+
return {
|
|
3055
|
+
field: new import_apache_arrow6.Field("epoch_ms", new import_apache_arrow6.Float64(), argument.field.nullable),
|
|
3056
|
+
hasKernel: argument.hasKernel,
|
|
3057
|
+
prepare(batch, active, context) {
|
|
3058
|
+
const input = argument.prepare(batch, active, context);
|
|
3059
|
+
return {
|
|
3060
|
+
get(row) {
|
|
3061
|
+
const value = input.get(row);
|
|
3062
|
+
if (value === null)
|
|
3063
|
+
return null;
|
|
3064
|
+
return key === "date32" ? Number(value) * 864e5 : Number(value / 1000n) + Number(value % 1000n) / 1e3;
|
|
3065
|
+
}
|
|
3066
|
+
};
|
|
3067
|
+
}
|
|
3068
|
+
};
|
|
3069
|
+
}
|
|
2969
3070
|
if (name === "cast") {
|
|
2970
3071
|
if (ast.arguments.length !== 2 || ((_a2 = ast.arguments[1]) == null ? void 0 : _a2.type) !== "Literal")
|
|
2971
3072
|
throw new Error("cast requires a value and a literal scalar target");
|
|
@@ -3214,20 +3315,20 @@ function compileArrowPredicate(predicate, options) {
|
|
|
3214
3315
|
}
|
|
3215
3316
|
|
|
3216
3317
|
// dist/arrow/query-worker.js
|
|
3217
|
-
var import_arrow3 = require("@math.gl/arrow");
|
|
3318
|
+
var import_arrow3 = require("@math.gl/core/arrow");
|
|
3218
3319
|
var import_tasks = require("@math.gl/tasks");
|
|
3219
3320
|
|
|
3220
3321
|
// dist/arrow/query-arrow-table.js
|
|
3221
3322
|
var import_apache_arrow9 = require("apache-arrow");
|
|
3222
|
-
var import_arrow2 = require("@math.gl/arrow");
|
|
3323
|
+
var import_arrow2 = require("@math.gl/core/arrow");
|
|
3223
3324
|
|
|
3224
3325
|
// dist/arrow/relational-query.js
|
|
3225
3326
|
var import_apache_arrow8 = require("apache-arrow");
|
|
3226
|
-
var import_arrow = require("@math.gl/arrow");
|
|
3327
|
+
var import_arrow = require("@math.gl/core/arrow");
|
|
3227
3328
|
|
|
3228
3329
|
// dist/arrow/aggregates.js
|
|
3229
3330
|
var import_apache_arrow7 = require("apache-arrow");
|
|
3230
|
-
var import_utf83 = require("@math.gl/
|
|
3331
|
+
var import_utf83 = require("@math.gl/core/utf8");
|
|
3231
3332
|
var reductions = /* @__PURE__ */ new Set([
|
|
3232
3333
|
"MIN",
|
|
3233
3334
|
"MAX",
|
|
@@ -3491,7 +3592,7 @@ function finish(operation, group, state) {
|
|
|
3491
3592
|
}
|
|
3492
3593
|
|
|
3493
3594
|
// dist/arrow/relational-query.js
|
|
3494
|
-
var import_utf84 = require("@math.gl/
|
|
3595
|
+
var import_utf84 = require("@math.gl/core/utf8");
|
|
3495
3596
|
function unionArrowTables(source, inputs) {
|
|
3496
3597
|
for (const table of inputs) {
|
|
3497
3598
|
(0, import_arrow.validateArrowTableSchema)(table, source.schema, {
|