@query-farm/vgi 0.35.0 → 0.36.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/dist/filter-pushdown/evaluate.d.ts +6 -0
- package/dist/index.js +21 -4
- package/dist/index.js.map +4 -4
- package/dist/worker-cf-entry.js +21 -4
- package/dist/worker-cf-entry.js.map +4 -4
- package/package.json +1 -1
- package/src/filter-pushdown/deserialize.ts +19 -1
- package/src/filter-pushdown/evaluate.ts +51 -2
package/dist/worker-cf-entry.js
CHANGED
|
@@ -2923,7 +2923,19 @@ function expressionColumns(expression, output = new Map) {
|
|
|
2923
2923
|
}
|
|
2924
2924
|
return output;
|
|
2925
2925
|
}
|
|
2926
|
+
function booleanColumnLeaf(expression) {
|
|
2927
|
+
const column = (node) => node.node === "column_ref" && node.dataType !== undefined && isBool(node.dataType) ? node.columnName : undefined;
|
|
2928
|
+
if (expression.node === "not") {
|
|
2929
|
+
const name = column(expression.expression);
|
|
2930
|
+
return name === undefined ? undefined : { columnName: name, value: false };
|
|
2931
|
+
}
|
|
2932
|
+
const name = column(expression);
|
|
2933
|
+
return name === undefined ? undefined : { columnName: name, value: true };
|
|
2934
|
+
}
|
|
2926
2935
|
function discreteValues(expression, columnName) {
|
|
2936
|
+
const leaf = booleanColumnLeaf(expression);
|
|
2937
|
+
if (leaf && leaf.columnName === columnName)
|
|
2938
|
+
return [leaf.value];
|
|
2927
2939
|
if (expression.node === "comparison" && expression.op === "eq" /* EQ */) {
|
|
2928
2940
|
if (expression.left.node === "column_ref" && expression.left.columnName === columnName && expression.right.node === "literal")
|
|
2929
2941
|
return [expression.right.value];
|
|
@@ -3029,7 +3041,7 @@ class PushdownFilters {
|
|
|
3029
3041
|
return null;
|
|
3030
3042
|
}
|
|
3031
3043
|
toSql() {
|
|
3032
|
-
return this.predicates.map((predicate) =>
|
|
3044
|
+
return this.predicates.map((predicate) => predicateToSql(predicate.expression)).join(" AND ");
|
|
3033
3045
|
}
|
|
3034
3046
|
}
|
|
3035
3047
|
function quote(value) {
|
|
@@ -3043,6 +3055,10 @@ function quote(value) {
|
|
|
3043
3055
|
return `[${value.map(quote).join(", ")}]`;
|
|
3044
3056
|
return String(value);
|
|
3045
3057
|
}
|
|
3058
|
+
function predicateToSql(expression) {
|
|
3059
|
+
const leaf = booleanColumnLeaf(expression);
|
|
3060
|
+
return leaf ? `${leaf.columnName} = ${quote(leaf.value)}` : expressionToSql(expression);
|
|
3061
|
+
}
|
|
3046
3062
|
function expressionToSql(expression) {
|
|
3047
3063
|
switch (expression.node) {
|
|
3048
3064
|
case "column_ref":
|
|
@@ -3066,7 +3082,7 @@ function expressionToSql(expression) {
|
|
|
3066
3082
|
}
|
|
3067
3083
|
case "and":
|
|
3068
3084
|
case "or":
|
|
3069
|
-
return `(${expression.children.map(
|
|
3085
|
+
return `(${expression.children.map(predicateToSql).join(` ${expression.node.toUpperCase()} `)})`;
|
|
3070
3086
|
case "not":
|
|
3071
3087
|
return `(NOT ${expressionToSql(expression.expression)})`;
|
|
3072
3088
|
case "is_null":
|
|
@@ -3739,7 +3755,8 @@ function isBooleanExpression(expression) {
|
|
|
3739
3755
|
if (["comparison", "and", "or", "not", "is_null", "in", "runtime_filter", "call"].includes(expression.node)) {
|
|
3740
3756
|
return true;
|
|
3741
3757
|
}
|
|
3742
|
-
|
|
3758
|
+
const type = expressionType(expression);
|
|
3759
|
+
return type !== undefined && isBool(type);
|
|
3743
3760
|
}
|
|
3744
3761
|
function requiresSessionContext(expression) {
|
|
3745
3762
|
switch (expression.node) {
|
|
@@ -11175,4 +11192,4 @@ export {
|
|
|
11175
11192
|
utf82 as utf8
|
|
11176
11193
|
};
|
|
11177
11194
|
|
|
11178
|
-
//# debugId=
|
|
11195
|
+
//# debugId=3ED975BB3E61A27764756E2164756E21
|