@quereus/quereus 4.5.0 → 4.7.0
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 +5 -4
- package/dist/src/common/errors.d.ts +17 -0
- package/dist/src/common/errors.d.ts.map +1 -1
- package/dist/src/common/errors.js +21 -0
- package/dist/src/common/errors.js.map +1 -1
- package/dist/src/core/database-assertions.d.ts +4 -3
- package/dist/src/core/database-assertions.d.ts.map +1 -1
- package/dist/src/core/database-assertions.js +44 -14
- package/dist/src/core/database-assertions.js.map +1 -1
- package/dist/src/core/database-events.d.ts +161 -1
- package/dist/src/core/database-events.d.ts.map +1 -1
- package/dist/src/core/database-events.js +307 -5
- package/dist/src/core/database-events.js.map +1 -1
- package/dist/src/core/database-internal.d.ts +5 -2
- package/dist/src/core/database-internal.d.ts.map +1 -1
- package/dist/src/core/database-materialized-views-plan-builders.d.ts.map +1 -1
- package/dist/src/core/database-materialized-views-plan-builders.js +33 -4
- package/dist/src/core/database-materialized-views-plan-builders.js.map +1 -1
- package/dist/src/core/database-materialized-views-plans.d.ts +12 -2
- package/dist/src/core/database-materialized-views-plans.d.ts.map +1 -1
- package/dist/src/core/database-materialized-views.d.ts +46 -0
- package/dist/src/core/database-materialized-views.d.ts.map +1 -1
- package/dist/src/core/database-materialized-views.js +75 -4
- package/dist/src/core/database-materialized-views.js.map +1 -1
- package/dist/src/core/database-transaction.d.ts +9 -0
- package/dist/src/core/database-transaction.d.ts.map +1 -1
- package/dist/src/core/database-transaction.js +9 -0
- package/dist/src/core/database-transaction.js.map +1 -1
- package/dist/src/core/database.d.ts +16 -2
- package/dist/src/core/database.d.ts.map +1 -1
- package/dist/src/core/database.js +56 -15
- package/dist/src/core/database.js.map +1 -1
- package/dist/src/core/derived-row-validator.d.ts.map +1 -1
- package/dist/src/core/derived-row-validator.js +7 -1
- package/dist/src/core/derived-row-validator.js.map +1 -1
- package/dist/src/core/statement.d.ts.map +1 -1
- package/dist/src/core/statement.js +15 -5
- package/dist/src/core/statement.js.map +1 -1
- package/dist/src/emit/ast-stringify.d.ts +18 -2
- package/dist/src/emit/ast-stringify.d.ts.map +1 -1
- package/dist/src/emit/ast-stringify.js +22 -4
- package/dist/src/emit/ast-stringify.js.map +1 -1
- package/dist/src/func/builtins/aggregate.js +11 -11
- package/dist/src/func/builtins/aggregate.js.map +1 -1
- package/dist/src/func/builtins/builtin-window-functions.d.ts.map +1 -1
- package/dist/src/func/builtins/builtin-window-functions.js +15 -85
- package/dist/src/func/builtins/builtin-window-functions.js.map +1 -1
- package/dist/src/func/builtins/conversion.d.ts.map +1 -1
- package/dist/src/func/builtins/conversion.js +10 -9
- package/dist/src/func/builtins/conversion.js.map +1 -1
- package/dist/src/func/builtins/datetime.d.ts.map +1 -1
- package/dist/src/func/builtins/datetime.js +28 -10
- package/dist/src/func/builtins/datetime.js.map +1 -1
- package/dist/src/func/builtins/explain.d.ts.map +1 -1
- package/dist/src/func/builtins/explain.js +19 -5
- package/dist/src/func/builtins/explain.js.map +1 -1
- package/dist/src/func/builtins/json.d.ts.map +1 -1
- package/dist/src/func/builtins/json.js +23 -17
- package/dist/src/func/builtins/json.js.map +1 -1
- package/dist/src/func/builtins/mutation.js +2 -2
- package/dist/src/func/builtins/mutation.js.map +1 -1
- package/dist/src/func/builtins/return-types.d.ts +327 -0
- package/dist/src/func/builtins/return-types.d.ts.map +1 -0
- package/dist/src/func/builtins/return-types.js +43 -0
- package/dist/src/func/builtins/return-types.js.map +1 -0
- package/dist/src/func/builtins/scalar.d.ts.map +1 -1
- package/dist/src/func/builtins/scalar.js +150 -79
- package/dist/src/func/builtins/scalar.js.map +1 -1
- package/dist/src/func/builtins/schema.d.ts.map +1 -1
- package/dist/src/func/builtins/schema.js +43 -8
- package/dist/src/func/builtins/schema.js.map +1 -1
- package/dist/src/func/builtins/string.d.ts.map +1 -1
- package/dist/src/func/builtins/string.js +4 -2
- package/dist/src/func/builtins/string.js.map +1 -1
- package/dist/src/func/builtins/timespan.d.ts +3 -0
- package/dist/src/func/builtins/timespan.d.ts.map +1 -1
- package/dist/src/func/builtins/timespan.js +15 -11
- package/dist/src/func/builtins/timespan.js.map +1 -1
- package/dist/src/func/registration.d.ts +35 -1
- package/dist/src/func/registration.d.ts.map +1 -1
- package/dist/src/func/registration.js +235 -41
- package/dist/src/func/registration.js.map +1 -1
- package/dist/src/index.d.ts +14 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +15 -6
- package/dist/src/index.js.map +1 -1
- package/dist/src/parser/ast.d.ts +58 -1
- package/dist/src/parser/ast.d.ts.map +1 -1
- package/dist/src/parser/parser.d.ts +46 -0
- package/dist/src/parser/parser.d.ts.map +1 -1
- package/dist/src/parser/parser.js +161 -45
- package/dist/src/parser/parser.js.map +1 -1
- package/dist/src/parser/utils.d.ts +13 -1
- package/dist/src/parser/utils.d.ts.map +1 -1
- package/dist/src/parser/utils.js +14 -0
- package/dist/src/parser/utils.js.map +1 -1
- package/dist/src/planner/analysis/assertion-classifier.d.ts.map +1 -1
- package/dist/src/planner/analysis/assertion-classifier.js +7 -2
- package/dist/src/planner/analysis/assertion-classifier.js.map +1 -1
- package/dist/src/planner/analysis/assertion-hoist-cache.d.ts.map +1 -1
- package/dist/src/planner/analysis/assertion-hoist-cache.js +5 -0
- package/dist/src/planner/analysis/assertion-hoist-cache.js.map +1 -1
- package/dist/src/planner/analysis/change-scope.d.ts +11 -3
- package/dist/src/planner/analysis/change-scope.d.ts.map +1 -1
- package/dist/src/planner/analysis/change-scope.js +5 -4
- package/dist/src/planner/analysis/change-scope.js.map +1 -1
- package/dist/src/planner/analysis/check-extraction.d.ts.map +1 -1
- package/dist/src/planner/analysis/check-extraction.js +37 -4
- package/dist/src/planner/analysis/check-extraction.js.map +1 -1
- package/dist/src/planner/analysis/comparison-collation.d.ts +20 -22
- package/dist/src/planner/analysis/comparison-collation.d.ts.map +1 -1
- package/dist/src/planner/analysis/comparison-collation.js +29 -26
- package/dist/src/planner/analysis/comparison-collation.js.map +1 -1
- package/dist/src/planner/analysis/constraint-extractor.d.ts +0 -7
- package/dist/src/planner/analysis/constraint-extractor.d.ts.map +1 -1
- package/dist/src/planner/analysis/constraint-extractor.js +59 -59
- package/dist/src/planner/analysis/constraint-extractor.js.map +1 -1
- package/dist/src/planner/analysis/coverage-prover.d.ts.map +1 -1
- package/dist/src/planner/analysis/coverage-prover.js +13 -5
- package/dist/src/planner/analysis/coverage-prover.js.map +1 -1
- package/dist/src/planner/analysis/equi-correlation.d.ts +6 -1
- package/dist/src/planner/analysis/equi-correlation.d.ts.map +1 -1
- package/dist/src/planner/analysis/equi-correlation.js +8 -1
- package/dist/src/planner/analysis/equi-correlation.js.map +1 -1
- package/dist/src/planner/analysis/predicate-dependencies.d.ts +34 -0
- package/dist/src/planner/analysis/predicate-dependencies.d.ts.map +1 -0
- package/dist/src/planner/analysis/predicate-dependencies.js +60 -0
- package/dist/src/planner/analysis/predicate-dependencies.js.map +1 -0
- package/dist/src/planner/analysis/query-rewrite-matcher.d.ts +1 -1
- package/dist/src/planner/analysis/query-rewrite-matcher.d.ts.map +1 -1
- package/dist/src/planner/analysis/query-rewrite-matcher.js +0 -26
- package/dist/src/planner/analysis/query-rewrite-matcher.js.map +1 -1
- package/dist/src/planner/building/alter-table.d.ts.map +1 -1
- package/dist/src/planner/building/alter-table.js +117 -43
- package/dist/src/planner/building/alter-table.js.map +1 -1
- package/dist/src/planner/building/coercion.d.ts +21 -45
- package/dist/src/planner/building/coercion.d.ts.map +1 -1
- package/dist/src/planner/building/coercion.js +42 -91
- package/dist/src/planner/building/coercion.js.map +1 -1
- package/dist/src/planner/building/constraint-builder.d.ts.map +1 -1
- package/dist/src/planner/building/constraint-builder.js +9 -5
- package/dist/src/planner/building/constraint-builder.js.map +1 -1
- package/dist/src/planner/building/create-assertion.d.ts.map +1 -1
- package/dist/src/planner/building/create-assertion.js +72 -1
- package/dist/src/planner/building/create-assertion.js.map +1 -1
- package/dist/src/planner/building/create-view.d.ts +6 -1
- package/dist/src/planner/building/create-view.d.ts.map +1 -1
- package/dist/src/planner/building/create-view.js +12 -3
- package/dist/src/planner/building/create-view.js.map +1 -1
- package/dist/src/planner/building/ddl.d.ts.map +1 -1
- package/dist/src/planner/building/ddl.js +6 -2
- package/dist/src/planner/building/ddl.js.map +1 -1
- package/dist/src/planner/building/delete.d.ts.map +1 -1
- package/dist/src/planner/building/delete.js +23 -10
- package/dist/src/planner/building/delete.js.map +1 -1
- package/dist/src/planner/building/dml-target.d.ts.map +1 -1
- package/dist/src/planner/building/dml-target.js +4 -0
- package/dist/src/planner/building/dml-target.js.map +1 -1
- package/dist/src/planner/building/drop-assertion.d.ts.map +1 -1
- package/dist/src/planner/building/drop-assertion.js +3 -1
- package/dist/src/planner/building/drop-assertion.js.map +1 -1
- package/dist/src/planner/building/expression.d.ts +17 -0
- package/dist/src/planner/building/expression.d.ts.map +1 -1
- package/dist/src/planner/building/expression.js +28 -17
- package/dist/src/planner/building/expression.js.map +1 -1
- package/dist/src/planner/building/foreign-key-builder.d.ts.map +1 -1
- package/dist/src/planner/building/foreign-key-builder.js +7 -5
- package/dist/src/planner/building/foreign-key-builder.js.map +1 -1
- package/dist/src/planner/building/function-call.d.ts +35 -0
- package/dist/src/planner/building/function-call.d.ts.map +1 -1
- package/dist/src/planner/building/function-call.js +60 -42
- package/dist/src/planner/building/function-call.js.map +1 -1
- package/dist/src/planner/building/insert.d.ts.map +1 -1
- package/dist/src/planner/building/insert.js +185 -48
- package/dist/src/planner/building/insert.js.map +1 -1
- package/dist/src/planner/building/materialized-view.d.ts.map +1 -1
- package/dist/src/planner/building/materialized-view.js +3 -1
- package/dist/src/planner/building/materialized-view.js.map +1 -1
- package/dist/src/planner/building/schema-authored-context.d.ts +69 -0
- package/dist/src/planner/building/schema-authored-context.d.ts.map +1 -0
- package/dist/src/planner/building/schema-authored-context.js +75 -0
- package/dist/src/planner/building/schema-authored-context.js.map +1 -0
- package/dist/src/planner/building/schema-resolution.d.ts.map +1 -1
- package/dist/src/planner/building/schema-resolution.js +7 -4
- package/dist/src/planner/building/schema-resolution.js.map +1 -1
- package/dist/src/planner/building/select-aggregates.d.ts +188 -3
- package/dist/src/planner/building/select-aggregates.d.ts.map +1 -1
- package/dist/src/planner/building/select-aggregates.js +449 -65
- package/dist/src/planner/building/select-aggregates.js.map +1 -1
- package/dist/src/planner/building/select-compound.js +2 -2
- package/dist/src/planner/building/select-compound.js.map +1 -1
- package/dist/src/planner/building/select-context.d.ts +98 -0
- package/dist/src/planner/building/select-context.d.ts.map +1 -1
- package/dist/src/planner/building/select-context.js +120 -37
- package/dist/src/planner/building/select-context.js.map +1 -1
- package/dist/src/planner/building/select-modifiers.d.ts +10 -3
- package/dist/src/planner/building/select-modifiers.d.ts.map +1 -1
- package/dist/src/planner/building/select-modifiers.js +29 -8
- package/dist/src/planner/building/select-modifiers.js.map +1 -1
- package/dist/src/planner/building/select-ordinal.d.ts +64 -19
- package/dist/src/planner/building/select-ordinal.d.ts.map +1 -1
- package/dist/src/planner/building/select-ordinal.js +79 -30
- package/dist/src/planner/building/select-ordinal.js.map +1 -1
- package/dist/src/planner/building/select-projections.d.ts +1 -1
- package/dist/src/planner/building/select-projections.d.ts.map +1 -1
- package/dist/src/planner/building/select-projections.js +18 -11
- package/dist/src/planner/building/select-projections.js.map +1 -1
- package/dist/src/planner/building/select-window.d.ts +13 -3
- package/dist/src/planner/building/select-window.d.ts.map +1 -1
- package/dist/src/planner/building/select-window.js +142 -37
- package/dist/src/planner/building/select-window.js.map +1 -1
- package/dist/src/planner/building/select.d.ts +37 -1
- package/dist/src/planner/building/select.d.ts.map +1 -1
- package/dist/src/planner/building/select.js +240 -109
- package/dist/src/planner/building/select.js.map +1 -1
- package/dist/src/planner/building/update.d.ts.map +1 -1
- package/dist/src/planner/building/update.js +27 -13
- package/dist/src/planner/building/update.js.map +1 -1
- package/dist/src/planner/building/view-mutation-builder.d.ts +1 -1
- package/dist/src/planner/building/view-mutation-builder.d.ts.map +1 -1
- package/dist/src/planner/building/view-mutation-builder.js +102 -8
- package/dist/src/planner/building/view-mutation-builder.js.map +1 -1
- package/dist/src/planner/building/with.d.ts.map +1 -1
- package/dist/src/planner/building/with.js +34 -4
- package/dist/src/planner/building/with.js.map +1 -1
- package/dist/src/planner/cache/correlation-detector.d.ts +15 -0
- package/dist/src/planner/cache/correlation-detector.d.ts.map +1 -1
- package/dist/src/planner/cache/correlation-detector.js +26 -0
- package/dist/src/planner/cache/correlation-detector.js.map +1 -1
- package/dist/src/planner/cache/materialization-advisory.d.ts +7 -0
- package/dist/src/planner/cache/materialization-advisory.d.ts.map +1 -1
- package/dist/src/planner/cache/materialization-advisory.js +12 -3
- package/dist/src/planner/cache/materialization-advisory.js.map +1 -1
- package/dist/src/planner/cost/conjunct-cost.d.ts +40 -0
- package/dist/src/planner/cost/conjunct-cost.d.ts.map +1 -1
- package/dist/src/planner/cost/conjunct-cost.js +45 -0
- package/dist/src/planner/cost/conjunct-cost.js.map +1 -1
- package/dist/src/planner/cost/index.d.ts +10 -0
- package/dist/src/planner/cost/index.d.ts.map +1 -1
- package/dist/src/planner/cost/index.js +15 -0
- package/dist/src/planner/cost/index.js.map +1 -1
- package/dist/src/planner/framework/characteristics.d.ts +9 -0
- package/dist/src/planner/framework/characteristics.d.ts.map +1 -1
- package/dist/src/planner/framework/characteristics.js.map +1 -1
- package/dist/src/planner/framework/pass.d.ts +2 -0
- package/dist/src/planner/framework/pass.d.ts.map +1 -1
- package/dist/src/planner/framework/pass.js +15 -0
- package/dist/src/planner/framework/pass.js.map +1 -1
- package/dist/src/planner/mutation/backward-body.d.ts.map +1 -1
- package/dist/src/planner/mutation/backward-body.js +4 -1
- package/dist/src/planner/mutation/backward-body.js.map +1 -1
- package/dist/src/planner/mutation/body-context.d.ts +23 -0
- package/dist/src/planner/mutation/body-context.d.ts.map +1 -0
- package/dist/src/planner/mutation/body-context.js +26 -0
- package/dist/src/planner/mutation/body-context.js.map +1 -0
- package/dist/src/planner/mutation/cte-flatten.js +15 -2
- package/dist/src/planner/mutation/cte-flatten.js.map +1 -1
- package/dist/src/planner/mutation/decomposition.d.ts +8 -0
- package/dist/src/planner/mutation/decomposition.d.ts.map +1 -1
- package/dist/src/planner/mutation/decomposition.js +8 -3
- package/dist/src/planner/mutation/decomposition.js.map +1 -1
- package/dist/src/planner/mutation/lens-enforcement.js +1 -1
- package/dist/src/planner/mutation/multi-source.d.ts +7 -0
- package/dist/src/planner/mutation/multi-source.d.ts.map +1 -1
- package/dist/src/planner/mutation/multi-source.js +5 -0
- package/dist/src/planner/mutation/multi-source.js.map +1 -1
- package/dist/src/planner/mutation/mutation-diagnostic.d.ts +1 -1
- package/dist/src/planner/mutation/mutation-diagnostic.d.ts.map +1 -1
- package/dist/src/planner/mutation/mutation-diagnostic.js.map +1 -1
- package/dist/src/planner/mutation/scope-transform.d.ts +32 -0
- package/dist/src/planner/mutation/scope-transform.d.ts.map +1 -1
- package/dist/src/planner/mutation/scope-transform.js +181 -33
- package/dist/src/planner/mutation/scope-transform.js.map +1 -1
- package/dist/src/planner/mutation/set-op.d.ts.map +1 -1
- package/dist/src/planner/mutation/set-op.js +66 -16
- package/dist/src/planner/mutation/set-op.js.map +1 -1
- package/dist/src/planner/mutation/single-source.d.ts.map +1 -1
- package/dist/src/planner/mutation/single-source.js +100 -24
- package/dist/src/planner/mutation/single-source.js.map +1 -1
- package/dist/src/planner/nodes/add-constraint-node.d.ts +15 -1
- package/dist/src/planner/nodes/add-constraint-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/add-constraint-node.js +10 -1
- package/dist/src/planner/nodes/add-constraint-node.js.map +1 -1
- package/dist/src/planner/nodes/aggregate-node.d.ts +15 -0
- package/dist/src/planner/nodes/aggregate-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/aggregate-node.js +32 -17
- package/dist/src/planner/nodes/aggregate-node.js.map +1 -1
- package/dist/src/planner/nodes/alias-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/alias-node.js +2 -1
- package/dist/src/planner/nodes/alias-node.js.map +1 -1
- package/dist/src/planner/nodes/alter-table-node.d.ts +51 -10
- package/dist/src/planner/nodes/alter-table-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/alter-table-node.js +49 -2
- package/dist/src/planner/nodes/alter-table-node.js.map +1 -1
- package/dist/src/planner/nodes/asof-scan-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/asof-scan-node.js +4 -1
- package/dist/src/planner/nodes/asof-scan-node.js.map +1 -1
- package/dist/src/planner/nodes/asserted-keys-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/asserted-keys-node.js +2 -1
- package/dist/src/planner/nodes/asserted-keys-node.js.map +1 -1
- package/dist/src/planner/nodes/bloom-join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/bloom-join-node.js +8 -3
- package/dist/src/planner/nodes/bloom-join-node.js.map +1 -1
- package/dist/src/planner/nodes/cache-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/cache-node.js +2 -1
- package/dist/src/planner/nodes/cache-node.js.map +1 -1
- package/dist/src/planner/nodes/constraint-check-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/constraint-check-node.js +17 -19
- package/dist/src/planner/nodes/constraint-check-node.js.map +1 -1
- package/dist/src/planner/nodes/create-assertion-node.d.ts +2 -1
- package/dist/src/planner/nodes/create-assertion-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/create-assertion-node.js +5 -2
- package/dist/src/planner/nodes/create-assertion-node.js.map +1 -1
- package/dist/src/planner/nodes/cte-node.d.ts +19 -9
- package/dist/src/planner/nodes/cte-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/cte-node.js +25 -9
- package/dist/src/planner/nodes/cte-node.js.map +1 -1
- package/dist/src/planner/nodes/delete-node.d.ts +20 -2
- package/dist/src/planner/nodes/delete-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/delete-node.js +11 -2
- package/dist/src/planner/nodes/delete-node.js.map +1 -1
- package/dist/src/planner/nodes/distinct-node.d.ts +6 -0
- package/dist/src/planner/nodes/distinct-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/distinct-node.js +10 -2
- package/dist/src/planner/nodes/distinct-node.js.map +1 -1
- package/dist/src/planner/nodes/dml-executor-node.d.ts +58 -1
- package/dist/src/planner/nodes/dml-executor-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/dml-executor-node.js +107 -15
- package/dist/src/planner/nodes/dml-executor-node.js.map +1 -1
- package/dist/src/planner/nodes/drop-assertion-node.d.ts +2 -1
- package/dist/src/planner/nodes/drop-assertion-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/drop-assertion-node.js +5 -2
- package/dist/src/planner/nodes/drop-assertion-node.js.map +1 -1
- package/dist/src/planner/nodes/eager-prefetch-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/eager-prefetch-node.js +2 -1
- package/dist/src/planner/nodes/eager-prefetch-node.js.map +1 -1
- package/dist/src/planner/nodes/fanout-lookup-join-node.d.ts +5 -0
- package/dist/src/planner/nodes/fanout-lookup-join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/fanout-lookup-join-node.js +13 -6
- package/dist/src/planner/nodes/fanout-lookup-join-node.js.map +1 -1
- package/dist/src/planner/nodes/filter.d.ts.map +1 -1
- package/dist/src/planner/nodes/filter.js +18 -5
- package/dist/src/planner/nodes/filter.js.map +1 -1
- package/dist/src/planner/nodes/hash-aggregate.d.ts +1 -0
- package/dist/src/planner/nodes/hash-aggregate.d.ts.map +1 -1
- package/dist/src/planner/nodes/hash-aggregate.js +21 -16
- package/dist/src/planner/nodes/hash-aggregate.js.map +1 -1
- package/dist/src/planner/nodes/insert-node.d.ts +19 -2
- package/dist/src/planner/nodes/insert-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/insert-node.js +10 -2
- package/dist/src/planner/nodes/insert-node.js.map +1 -1
- package/dist/src/planner/nodes/join-node.d.ts +20 -1
- package/dist/src/planner/nodes/join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/join-node.js +30 -9
- package/dist/src/planner/nodes/join-node.js.map +1 -1
- package/dist/src/planner/nodes/join-utils.d.ts +21 -0
- package/dist/src/planner/nodes/join-utils.d.ts.map +1 -1
- package/dist/src/planner/nodes/join-utils.js +26 -0
- package/dist/src/planner/nodes/join-utils.js.map +1 -1
- package/dist/src/planner/nodes/key-set-semi-join-node.d.ts +42 -10
- package/dist/src/planner/nodes/key-set-semi-join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/key-set-semi-join-node.js +90 -17
- package/dist/src/planner/nodes/key-set-semi-join-node.js.map +1 -1
- package/dist/src/planner/nodes/lens-auxiliary-access-node.d.ts +5 -0
- package/dist/src/planner/nodes/lens-auxiliary-access-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/lens-auxiliary-access-node.js +2 -1
- package/dist/src/planner/nodes/lens-auxiliary-access-node.js.map +1 -1
- package/dist/src/planner/nodes/limit-offset.d.ts +6 -0
- package/dist/src/planner/nodes/limit-offset.d.ts.map +1 -1
- package/dist/src/planner/nodes/limit-offset.js +10 -2
- package/dist/src/planner/nodes/limit-offset.js.map +1 -1
- package/dist/src/planner/nodes/merge-join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/merge-join-node.js +8 -3
- package/dist/src/planner/nodes/merge-join-node.js.map +1 -1
- package/dist/src/planner/nodes/ordinal-slice-node.d.ts +5 -0
- package/dist/src/planner/nodes/ordinal-slice-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/ordinal-slice-node.js +9 -2
- package/dist/src/planner/nodes/ordinal-slice-node.js.map +1 -1
- package/dist/src/planner/nodes/plan-node.d.ts +29 -0
- package/dist/src/planner/nodes/plan-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/plan-node.js +12 -0
- package/dist/src/planner/nodes/plan-node.js.map +1 -1
- package/dist/src/planner/nodes/project-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/project-node.js +18 -36
- package/dist/src/planner/nodes/project-node.js.map +1 -1
- package/dist/src/planner/nodes/reference.d.ts.map +1 -1
- package/dist/src/planner/nodes/reference.js +3 -2
- package/dist/src/planner/nodes/reference.js.map +1 -1
- package/dist/src/planner/nodes/retrieve-node.d.ts +16 -2
- package/dist/src/planner/nodes/retrieve-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/retrieve-node.js +10 -2
- package/dist/src/planner/nodes/retrieve-node.js.map +1 -1
- package/dist/src/planner/nodes/returning-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/returning-node.js +13 -32
- package/dist/src/planner/nodes/returning-node.js.map +1 -1
- package/dist/src/planner/nodes/scalar.d.ts.map +1 -1
- package/dist/src/planner/nodes/scalar.js +5 -18
- package/dist/src/planner/nodes/scalar.js.map +1 -1
- package/dist/src/planner/nodes/sort.d.ts.map +1 -1
- package/dist/src/planner/nodes/sort.js +3 -1
- package/dist/src/planner/nodes/sort.js.map +1 -1
- package/dist/src/planner/nodes/stream-aggregate.d.ts +1 -0
- package/dist/src/planner/nodes/stream-aggregate.d.ts.map +1 -1
- package/dist/src/planner/nodes/stream-aggregate.js +22 -20
- package/dist/src/planner/nodes/stream-aggregate.js.map +1 -1
- package/dist/src/planner/nodes/table-access-nodes.d.ts +89 -1
- package/dist/src/planner/nodes/table-access-nodes.d.ts.map +1 -1
- package/dist/src/planner/nodes/table-access-nodes.js +69 -2
- package/dist/src/planner/nodes/table-access-nodes.js.map +1 -1
- package/dist/src/planner/nodes/update-node.d.ts +19 -2
- package/dist/src/planner/nodes/update-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/update-node.js +10 -2
- package/dist/src/planner/nodes/update-node.js.map +1 -1
- package/dist/src/planner/nodes/window-function.d.ts.map +1 -1
- package/dist/src/planner/nodes/window-function.js +8 -0
- package/dist/src/planner/nodes/window-function.js.map +1 -1
- package/dist/src/planner/nodes/window-node.d.ts +1 -1
- package/dist/src/planner/nodes/window-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/window-node.js +3 -1
- package/dist/src/planner/nodes/window-node.js.map +1 -1
- package/dist/src/planner/optimizer.d.ts +27 -1
- package/dist/src/planner/optimizer.d.ts.map +1 -1
- package/dist/src/planner/optimizer.js +130 -10
- package/dist/src/planner/optimizer.js.map +1 -1
- package/dist/src/planner/planning-context.d.ts +24 -0
- package/dist/src/planner/planning-context.d.ts.map +1 -1
- package/dist/src/planner/planning-context.js.map +1 -1
- package/dist/src/planner/rules/access/rule-key-set-seek.d.ts +78 -20
- package/dist/src/planner/rules/access/rule-key-set-seek.d.ts.map +1 -1
- package/dist/src/planner/rules/access/rule-key-set-seek.js +296 -135
- package/dist/src/planner/rules/access/rule-key-set-seek.js.map +1 -1
- package/dist/src/planner/rules/access/rule-monotonic-range-access.d.ts.map +1 -1
- package/dist/src/planner/rules/access/rule-monotonic-range-access.js +2 -2
- package/dist/src/planner/rules/access/rule-monotonic-range-access.js.map +1 -1
- package/dist/src/planner/rules/access/rule-select-access-path.d.ts +30 -1
- package/dist/src/planner/rules/access/rule-select-access-path.d.ts.map +1 -1
- package/dist/src/planner/rules/access/rule-select-access-path.js +70 -5
- package/dist/src/planner/rules/access/rule-select-access-path.js.map +1 -1
- package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.d.ts +7 -4
- package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.d.ts.map +1 -1
- package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.js +39 -5
- package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.js.map +1 -1
- package/dist/src/planner/rules/cache/rule-cte-optimization.d.ts.map +1 -1
- package/dist/src/planner/rules/cache/rule-cte-optimization.js +15 -2
- package/dist/src/planner/rules/cache/rule-cte-optimization.js.map +1 -1
- package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.js +10 -3
- package/dist/src/planner/rules/cache/rule-materialized-view-rewrite.js.map +1 -1
- package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.d.ts.map +1 -1
- package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.js +6 -4
- package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.js.map +1 -1
- package/dist/src/planner/rules/join/equi-pair-extractor.d.ts +5 -31
- package/dist/src/planner/rules/join/equi-pair-extractor.d.ts.map +1 -1
- package/dist/src/planner/rules/join/equi-pair-extractor.js +4 -44
- package/dist/src/planner/rules/join/equi-pair-extractor.js.map +1 -1
- package/dist/src/planner/rules/join/index-nested-loop.d.ts +49 -0
- package/dist/src/planner/rules/join/index-nested-loop.d.ts.map +1 -0
- package/dist/src/planner/rules/join/index-nested-loop.js +291 -0
- package/dist/src/planner/rules/join/index-nested-loop.js.map +1 -0
- package/dist/src/planner/rules/join/rule-fanout-batched-outer.js +8 -8
- package/dist/src/planner/rules/join/rule-fanout-lookup-join.d.ts +4 -0
- package/dist/src/planner/rules/join/rule-fanout-lookup-join.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-fanout-lookup-join.js +50 -15
- package/dist/src/planner/rules/join/rule-fanout-lookup-join.js.map +1 -1
- package/dist/src/planner/rules/join/rule-join-elimination.d.ts +6 -0
- package/dist/src/planner/rules/join/rule-join-elimination.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-join-elimination.js +25 -9
- package/dist/src/planner/rules/join/rule-join-elimination.js.map +1 -1
- package/dist/src/planner/rules/join/rule-join-key-inference.d.ts +7 -0
- package/dist/src/planner/rules/join/rule-join-key-inference.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-join-key-inference.js +23 -11
- package/dist/src/planner/rules/join/rule-join-key-inference.js.map +1 -1
- package/dist/src/planner/rules/join/rule-join-physical-selection.d.ts +10 -4
- package/dist/src/planner/rules/join/rule-join-physical-selection.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-join-physical-selection.js +115 -29
- package/dist/src/planner/rules/join/rule-join-physical-selection.js.map +1 -1
- package/dist/src/planner/rules/join/rule-monotonic-merge-join.d.ts +2 -0
- package/dist/src/planner/rules/join/rule-monotonic-merge-join.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-monotonic-merge-join.js +18 -4
- package/dist/src/planner/rules/join/rule-monotonic-merge-join.js.map +1 -1
- package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.d.ts +2 -2
- package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.d.ts.map +1 -1
- package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.js +19 -22
- package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.js.map +1 -1
- package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.d.ts +21 -8
- package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.d.ts.map +1 -1
- package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.js +70 -14
- package/dist/src/planner/rules/predicate/rule-filter-conjunct-ordering.js.map +1 -1
- package/dist/src/planner/rules/predicate/rule-filter-selectivity.d.ts +56 -17
- package/dist/src/planner/rules/predicate/rule-filter-selectivity.d.ts.map +1 -1
- package/dist/src/planner/rules/predicate/rule-filter-selectivity.js +103 -154
- package/dist/src/planner/rules/predicate/rule-filter-selectivity.js.map +1 -1
- package/dist/src/planner/rules/predicate/rule-join-predicate-pushdown.d.ts +76 -0
- package/dist/src/planner/rules/predicate/rule-join-predicate-pushdown.d.ts.map +1 -0
- package/dist/src/planner/rules/predicate/rule-join-predicate-pushdown.js +208 -0
- package/dist/src/planner/rules/predicate/rule-join-predicate-pushdown.js.map +1 -0
- package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.d.ts +14 -11
- package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.d.ts.map +1 -1
- package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.js +21 -85
- package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.js.map +1 -1
- package/dist/src/planner/rules/predicate/rule-predicate-pushdown.d.ts +7 -1
- package/dist/src/planner/rules/predicate/rule-predicate-pushdown.d.ts.map +1 -1
- package/dist/src/planner/rules/predicate/rule-predicate-pushdown.js +18 -22
- package/dist/src/planner/rules/predicate/rule-predicate-pushdown.js.map +1 -1
- package/dist/src/planner/rules/shared/access-leaf.d.ts +52 -0
- package/dist/src/planner/rules/shared/access-leaf.d.ts.map +1 -0
- package/dist/src/planner/rules/shared/access-leaf.js +95 -0
- package/dist/src/planner/rules/shared/access-leaf.js.map +1 -0
- package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.d.ts.map +1 -1
- package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.js +17 -7
- package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.js.map +1 -1
- package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.d.ts +3 -1
- package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.d.ts.map +1 -1
- package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.js +26 -9
- package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.js.map +1 -1
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.d.ts.map +1 -1
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js +69 -11
- package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js.map +1 -1
- package/dist/src/planner/rules/window/rule-monotonic-window.d.ts +17 -7
- package/dist/src/planner/rules/window/rule-monotonic-window.d.ts.map +1 -1
- package/dist/src/planner/rules/window/rule-monotonic-window.js +124 -87
- package/dist/src/planner/rules/window/rule-monotonic-window.js.map +1 -1
- package/dist/src/planner/scopes/aliased.d.ts.map +1 -1
- package/dist/src/planner/scopes/aliased.js +6 -0
- package/dist/src/planner/scopes/aliased.js.map +1 -1
- package/dist/src/planner/stats/catalog-stats.d.ts +44 -13
- package/dist/src/planner/stats/catalog-stats.d.ts.map +1 -1
- package/dist/src/planner/stats/catalog-stats.js +137 -61
- package/dist/src/planner/stats/catalog-stats.js.map +1 -1
- package/dist/src/planner/stats/conjunct-selectivity.d.ts +48 -0
- package/dist/src/planner/stats/conjunct-selectivity.d.ts.map +1 -0
- package/dist/src/planner/stats/conjunct-selectivity.js +168 -0
- package/dist/src/planner/stats/conjunct-selectivity.js.map +1 -0
- package/dist/src/planner/stats/index.d.ts +22 -3
- package/dist/src/planner/stats/index.d.ts.map +1 -1
- package/dist/src/planner/stats/index.js.map +1 -1
- package/dist/src/planner/stats/table-cardinality.d.ts +28 -0
- package/dist/src/planner/stats/table-cardinality.d.ts.map +1 -0
- package/dist/src/planner/stats/table-cardinality.js +29 -0
- package/dist/src/planner/stats/table-cardinality.js.map +1 -0
- package/dist/src/planner/stored-body-context.d.ts +57 -0
- package/dist/src/planner/stored-body-context.d.ts.map +1 -0
- package/dist/src/planner/stored-body-context.js +64 -0
- package/dist/src/planner/stored-body-context.js.map +1 -0
- package/dist/src/planner/util/column-origins.d.ts +29 -8
- package/dist/src/planner/util/column-origins.d.ts.map +1 -1
- package/dist/src/planner/util/column-origins.js +74 -14
- package/dist/src/planner/util/column-origins.js.map +1 -1
- package/dist/src/planner/util/fd-utils.d.ts +32 -8
- package/dist/src/planner/util/fd-utils.d.ts.map +1 -1
- package/dist/src/planner/util/fd-utils.js +46 -9
- package/dist/src/planner/util/fd-utils.js.map +1 -1
- package/dist/src/planner/util/ind-utils.d.ts +66 -19
- package/dist/src/planner/util/ind-utils.d.ts.map +1 -1
- package/dist/src/planner/util/ind-utils.js +91 -21
- package/dist/src/planner/util/ind-utils.js.map +1 -1
- package/dist/src/planner/util/key-utils.d.ts +36 -3
- package/dist/src/planner/util/key-utils.d.ts.map +1 -1
- package/dist/src/planner/util/key-utils.js +57 -7
- package/dist/src/planner/util/key-utils.js.map +1 -1
- package/dist/src/planner/util/output-names.d.ts +12 -0
- package/dist/src/planner/util/output-names.d.ts.map +1 -0
- package/dist/src/planner/util/output-names.js +20 -0
- package/dist/src/planner/util/output-names.js.map +1 -0
- package/dist/src/planner/util/row-estimates.d.ts +39 -0
- package/dist/src/planner/util/row-estimates.d.ts.map +1 -0
- package/dist/src/planner/util/row-estimates.js +68 -0
- package/dist/src/planner/util/row-estimates.js.map +1 -0
- package/dist/src/planner/util/row-population.d.ts +42 -0
- package/dist/src/planner/util/row-population.d.ts.map +1 -0
- package/dist/src/planner/util/row-population.js +71 -0
- package/dist/src/planner/util/row-population.js.map +1 -0
- package/dist/src/runtime/deferred-constraint-queue.d.ts.map +1 -1
- package/dist/src/runtime/deferred-constraint-queue.js +3 -2
- package/dist/src/runtime/deferred-constraint-queue.js.map +1 -1
- package/dist/src/runtime/emit/add-constraint.d.ts.map +1 -1
- package/dist/src/runtime/emit/add-constraint.js +60 -6
- package/dist/src/runtime/emit/add-constraint.js.map +1 -1
- package/dist/src/runtime/emit/aggregate.d.ts.map +1 -1
- package/dist/src/runtime/emit/aggregate.js +4 -4
- package/dist/src/runtime/emit/aggregate.js.map +1 -1
- package/dist/src/runtime/emit/alter-schema-event.d.ts +97 -0
- package/dist/src/runtime/emit/alter-schema-event.d.ts.map +1 -0
- package/dist/src/runtime/emit/alter-schema-event.js +87 -0
- package/dist/src/runtime/emit/alter-schema-event.js.map +1 -0
- package/dist/src/runtime/emit/alter-table.d.ts.map +1 -1
- package/dist/src/runtime/emit/alter-table.js +582 -236
- package/dist/src/runtime/emit/alter-table.js.map +1 -1
- package/dist/src/runtime/emit/analyze.d.ts.map +1 -1
- package/dist/src/runtime/emit/analyze.js +50 -7
- package/dist/src/runtime/emit/analyze.js.map +1 -1
- package/dist/src/runtime/emit/assertion-drop-guard.d.ts +37 -0
- package/dist/src/runtime/emit/assertion-drop-guard.d.ts.map +1 -0
- package/dist/src/runtime/emit/assertion-drop-guard.js +59 -0
- package/dist/src/runtime/emit/assertion-drop-guard.js.map +1 -0
- package/dist/src/runtime/emit/assertion-rename-helpers.d.ts +33 -0
- package/dist/src/runtime/emit/assertion-rename-helpers.d.ts.map +1 -0
- package/dist/src/runtime/emit/assertion-rename-helpers.js +124 -0
- package/dist/src/runtime/emit/assertion-rename-helpers.js.map +1 -0
- package/dist/src/runtime/emit/cast.d.ts.map +1 -1
- package/dist/src/runtime/emit/cast.js +4 -19
- package/dist/src/runtime/emit/cast.js.map +1 -1
- package/dist/src/runtime/emit/constraint-check.d.ts.map +1 -1
- package/dist/src/runtime/emit/constraint-check.js +10 -227
- package/dist/src/runtime/emit/constraint-check.js.map +1 -1
- package/dist/src/runtime/emit/create-assertion.d.ts.map +1 -1
- package/dist/src/runtime/emit/create-assertion.js +31 -14
- package/dist/src/runtime/emit/create-assertion.js.map +1 -1
- package/dist/src/runtime/emit/cte.d.ts.map +1 -1
- package/dist/src/runtime/emit/cte.js +11 -6
- package/dist/src/runtime/emit/cte.js.map +1 -1
- package/dist/src/runtime/emit/dml-executor.d.ts.map +1 -1
- package/dist/src/runtime/emit/dml-executor.js +233 -28
- package/dist/src/runtime/emit/dml-executor.js.map +1 -1
- package/dist/src/runtime/emit/drop-assertion.js +8 -8
- package/dist/src/runtime/emit/drop-assertion.js.map +1 -1
- package/dist/src/runtime/emit/drop-column-guards.d.ts +151 -0
- package/dist/src/runtime/emit/drop-column-guards.d.ts.map +1 -0
- package/dist/src/runtime/emit/drop-column-guards.js +230 -0
- package/dist/src/runtime/emit/drop-column-guards.js.map +1 -0
- package/dist/src/runtime/emit/drop-index.d.ts.map +1 -1
- package/dist/src/runtime/emit/drop-index.js +4 -3
- package/dist/src/runtime/emit/drop-index.js.map +1 -1
- package/dist/src/runtime/emit/drop-table.d.ts.map +1 -1
- package/dist/src/runtime/emit/drop-table.js +6 -0
- package/dist/src/runtime/emit/drop-table.js.map +1 -1
- package/dist/src/runtime/emit/drop-view.d.ts.map +1 -1
- package/dist/src/runtime/emit/drop-view.js +4 -0
- package/dist/src/runtime/emit/drop-view.js.map +1 -1
- package/dist/src/runtime/emit/hash-aggregate.d.ts.map +1 -1
- package/dist/src/runtime/emit/hash-aggregate.js +2 -2
- package/dist/src/runtime/emit/hash-aggregate.js.map +1 -1
- package/dist/src/runtime/emit/join.d.ts.map +1 -1
- package/dist/src/runtime/emit/join.js +8 -67
- package/dist/src/runtime/emit/join.js.map +1 -1
- package/dist/src/runtime/emit/key-set-semi-join.d.ts.map +1 -1
- package/dist/src/runtime/emit/key-set-semi-join.js +11 -3
- package/dist/src/runtime/emit/key-set-semi-join.js.map +1 -1
- package/dist/src/runtime/emit/materialized-view-helpers.d.ts +4 -4
- package/dist/src/runtime/emit/materialized-view-helpers.d.ts.map +1 -1
- package/dist/src/runtime/emit/materialized-view-helpers.js +34 -22
- package/dist/src/runtime/emit/materialized-view-helpers.js.map +1 -1
- package/dist/src/runtime/emit/materialized-view.d.ts.map +1 -1
- package/dist/src/runtime/emit/materialized-view.js +7 -2
- package/dist/src/runtime/emit/materialized-view.js.map +1 -1
- package/dist/src/runtime/emit/operand-comparator.d.ts +30 -0
- package/dist/src/runtime/emit/operand-comparator.d.ts.map +1 -1
- package/dist/src/runtime/emit/operand-comparator.js +34 -0
- package/dist/src/runtime/emit/operand-comparator.js.map +1 -1
- package/dist/src/runtime/emit/recursive-cte.d.ts.map +1 -1
- package/dist/src/runtime/emit/recursive-cte.js +4 -5
- package/dist/src/runtime/emit/recursive-cte.js.map +1 -1
- package/dist/src/runtime/emit/schema-declarative.d.ts.map +1 -1
- package/dist/src/runtime/emit/schema-declarative.js +30 -0
- package/dist/src/runtime/emit/schema-declarative.js.map +1 -1
- package/dist/src/runtime/emit/subquery.d.ts.map +1 -1
- package/dist/src/runtime/emit/subquery.js +153 -52
- package/dist/src/runtime/emit/subquery.js.map +1 -1
- package/dist/src/runtime/emit/update.d.ts.map +1 -1
- package/dist/src/runtime/emit/update.js +18 -6
- package/dist/src/runtime/emit/update.js.map +1 -1
- package/dist/src/runtime/emit/window.js +36 -23
- package/dist/src/runtime/emit/window.js.map +1 -1
- package/dist/src/runtime/row-constraints.d.ts +85 -0
- package/dist/src/runtime/row-constraints.d.ts.map +1 -0
- package/dist/src/runtime/row-constraints.js +239 -0
- package/dist/src/runtime/row-constraints.js.map +1 -0
- package/dist/src/runtime/types.d.ts +8 -11
- package/dist/src/runtime/types.d.ts.map +1 -1
- package/dist/src/runtime/types.js.map +1 -1
- package/dist/src/schema/assertion.d.ts +14 -1
- package/dist/src/schema/assertion.d.ts.map +1 -1
- package/dist/src/schema/assertion.js +14 -1
- package/dist/src/schema/assertion.js.map +1 -1
- package/dist/src/schema/catalog-persistability.d.ts +19 -16
- package/dist/src/schema/catalog-persistability.d.ts.map +1 -1
- package/dist/src/schema/catalog-persistability.js +92 -20
- package/dist/src/schema/catalog-persistability.js.map +1 -1
- package/dist/src/schema/catalog.d.ts +73 -2
- package/dist/src/schema/catalog.d.ts.map +1 -1
- package/dist/src/schema/catalog.js +220 -39
- package/dist/src/schema/catalog.js.map +1 -1
- package/dist/src/schema/column-source-resolver.d.ts +18 -0
- package/dist/src/schema/column-source-resolver.d.ts.map +1 -0
- package/dist/src/schema/column-source-resolver.js +22 -0
- package/dist/src/schema/column-source-resolver.js.map +1 -0
- package/dist/src/schema/column.d.ts +26 -3
- package/dist/src/schema/column.d.ts.map +1 -1
- package/dist/src/schema/column.js.map +1 -1
- package/dist/src/schema/constraint-builder.d.ts.map +1 -1
- package/dist/src/schema/constraint-builder.js +7 -1
- package/dist/src/schema/constraint-builder.js.map +1 -1
- package/dist/src/schema/ddl-generator.d.ts.map +1 -1
- package/dist/src/schema/ddl-generator.js +27 -6
- package/dist/src/schema/ddl-generator.js.map +1 -1
- package/dist/src/schema/function.d.ts +32 -1
- package/dist/src/schema/function.d.ts.map +1 -1
- package/dist/src/schema/function.js +10 -2
- package/dist/src/schema/function.js.map +1 -1
- package/dist/src/schema/lens-compiler.d.ts.map +1 -1
- package/dist/src/schema/lens-compiler.js +203 -51
- package/dist/src/schema/lens-compiler.js.map +1 -1
- package/dist/src/schema/lens-prover.d.ts +2 -3
- package/dist/src/schema/lens-prover.d.ts.map +1 -1
- package/dist/src/schema/lens-prover.js +19 -11
- package/dist/src/schema/lens-prover.js.map +1 -1
- package/dist/src/schema/manager.d.ts +115 -20
- package/dist/src/schema/manager.d.ts.map +1 -1
- package/dist/src/schema/manager.js +202 -70
- package/dist/src/schema/manager.js.map +1 -1
- package/dist/src/schema/rename-rewriter.d.ts +142 -0
- package/dist/src/schema/rename-rewriter.d.ts.map +1 -1
- package/dist/src/schema/rename-rewriter.js +254 -9
- package/dist/src/schema/rename-rewriter.js.map +1 -1
- package/dist/src/schema/reserved-tags.d.ts +1 -1
- package/dist/src/schema/reserved-tags.d.ts.map +1 -1
- package/dist/src/schema/reserved-tags.js +4 -3
- package/dist/src/schema/reserved-tags.js.map +1 -1
- package/dist/src/schema/schema-differ.d.ts +16 -0
- package/dist/src/schema/schema-differ.d.ts.map +1 -1
- package/dist/src/schema/schema-differ.js +225 -38
- package/dist/src/schema/schema-differ.js.map +1 -1
- package/dist/src/schema/table.d.ts +149 -1
- package/dist/src/schema/table.d.ts.map +1 -1
- package/dist/src/schema/table.js +248 -1
- package/dist/src/schema/table.js.map +1 -1
- package/dist/src/schema/unique-enforcement.d.ts +5 -3
- package/dist/src/schema/unique-enforcement.d.ts.map +1 -1
- package/dist/src/schema/unique-enforcement.js +5 -3
- package/dist/src/schema/unique-enforcement.js.map +1 -1
- package/dist/src/schema/view.d.ts +11 -0
- package/dist/src/schema/view.d.ts.map +1 -1
- package/dist/src/schema/view.js +12 -0
- package/dist/src/schema/view.js.map +1 -1
- package/dist/src/types/builtin-types.d.ts +54 -0
- package/dist/src/types/builtin-types.d.ts.map +1 -1
- package/dist/src/types/builtin-types.js +123 -34
- package/dist/src/types/builtin-types.js.map +1 -1
- package/dist/src/types/cast-semantics.d.ts +42 -0
- package/dist/src/types/cast-semantics.d.ts.map +1 -1
- package/dist/src/types/cast-semantics.js +64 -0
- package/dist/src/types/cast-semantics.js.map +1 -1
- package/dist/src/types/comparison-coercion.d.ts +101 -0
- package/dist/src/types/comparison-coercion.d.ts.map +1 -0
- package/dist/src/types/comparison-coercion.js +162 -0
- package/dist/src/types/comparison-coercion.js.map +1 -0
- package/dist/src/types/index.d.ts +2 -2
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js +2 -2
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/logical-type.d.ts +7 -0
- package/dist/src/types/logical-type.d.ts.map +1 -1
- package/dist/src/types/logical-type.js.map +1 -1
- package/dist/src/types/validation.d.ts +56 -0
- package/dist/src/types/validation.d.ts.map +1 -1
- package/dist/src/types/validation.js +68 -0
- package/dist/src/types/validation.js.map +1 -1
- package/dist/src/util/{working-table-iterable.d.ts → array-row-iterable.d.ts} +6 -6
- package/dist/src/util/array-row-iterable.d.ts.map +1 -0
- package/dist/src/util/{working-table-iterable.js → array-row-iterable.js} +6 -6
- package/dist/src/util/array-row-iterable.js.map +1 -0
- package/dist/src/util/coercion.d.ts +8 -0
- package/dist/src/util/coercion.d.ts.map +1 -1
- package/dist/src/util/coercion.js +8 -0
- package/dist/src/util/coercion.js.map +1 -1
- package/dist/src/util/comparison.d.ts +16 -3
- package/dist/src/util/comparison.d.ts.map +1 -1
- package/dist/src/util/comparison.js +21 -5
- package/dist/src/util/comparison.js.map +1 -1
- package/dist/src/util/key-serializer.d.ts +46 -0
- package/dist/src/util/key-serializer.d.ts.map +1 -1
- package/dist/src/util/key-serializer.js +47 -0
- package/dist/src/util/key-serializer.js.map +1 -1
- package/dist/src/util/value-set.d.ts +21 -0
- package/dist/src/util/value-set.d.ts.map +1 -0
- package/dist/src/util/value-set.js +22 -0
- package/dist/src/util/value-set.js.map +1 -0
- package/dist/src/vtab/capabilities.d.ts +1 -1
- package/dist/src/vtab/events.d.ts +8 -1
- package/dist/src/vtab/events.d.ts.map +1 -1
- package/dist/src/vtab/events.js.map +1 -1
- package/dist/src/vtab/manifest.d.ts +15 -0
- package/dist/src/vtab/manifest.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/alter-column.d.ts +147 -0
- package/dist/src/vtab/memory/layer/alter-column.d.ts.map +1 -0
- package/dist/src/vtab/memory/layer/alter-column.js +214 -0
- package/dist/src/vtab/memory/layer/alter-column.js.map +1 -0
- package/dist/src/vtab/memory/layer/base.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/base.js +4 -3
- package/dist/src/vtab/memory/layer/base.js.map +1 -1
- package/dist/src/vtab/memory/layer/interface.d.ts +2 -2
- package/dist/src/vtab/memory/layer/interface.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/manager.d.ts +176 -25
- package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/manager.js +569 -558
- package/dist/src/vtab/memory/layer/manager.js.map +1 -1
- package/dist/src/vtab/memory/layer/scan-layer.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/scan-layer.js +32 -5
- package/dist/src/vtab/memory/layer/scan-layer.js.map +1 -1
- package/dist/src/vtab/memory/layer/transaction.d.ts +101 -15
- package/dist/src/vtab/memory/layer/transaction.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/transaction.js +133 -45
- package/dist/src/vtab/memory/layer/transaction.js.map +1 -1
- package/dist/src/vtab/memory/module.d.ts +16 -1
- package/dist/src/vtab/memory/module.d.ts.map +1 -1
- package/dist/src/vtab/memory/module.js +64 -3
- package/dist/src/vtab/memory/module.js.map +1 -1
- package/dist/src/vtab/memory/table.d.ts.map +1 -1
- package/dist/src/vtab/memory/table.js +11 -6
- package/dist/src/vtab/memory/table.js.map +1 -1
- package/dist/src/vtab/module.d.ts +77 -23
- package/dist/src/vtab/module.d.ts.map +1 -1
- package/dist/src/vtab/table.d.ts +9 -2
- package/dist/src/vtab/table.d.ts.map +1 -1
- package/dist/src/vtab/table.js +1 -1
- package/dist/src/vtab/table.js.map +1 -1
- package/package.json +3 -3
- package/dist/src/util/working-table-iterable.d.ts.map +0 -1
- package/dist/src/util/working-table-iterable.js.map +0 -1
|
@@ -4,10 +4,39 @@
|
|
|
4
4
|
* Stamps a stats-derived selectivity onto a FilterNode so its `estimatedRows`
|
|
5
5
|
* reflects real column statistics instead of the flat DEFAULT_FILTER_SELECTIVITY.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Registered THREE times, all bottom-up. Only the first derives an estimate the plan
|
|
8
|
+
* did not have; the other two recover one that a later pass dropped, because
|
|
9
|
+
* `FilterNode.withChildren` carries `selectivity` forward only when the predicate
|
|
10
|
+
* child is the same object, and several passes rewrite inside a predicate:
|
|
11
|
+
*
|
|
12
|
+
* - `filter-selectivity` (Physical pass), the primary stamp. Fires AFTER the
|
|
13
|
+
* Structural pass — predicate-pushdown / grow-retrieve have already put the Filter
|
|
14
|
+
* in its final position over its final source, so the source subtree is settled
|
|
15
|
+
* (and may carry physical access nodes between the join and its table references).
|
|
16
|
+
* This stamp is what the physical and PostOptimization cost readers consult.
|
|
17
|
+
* - `filter-selectivity-restamp` (PostOptimization pass, registered FIRST in that
|
|
18
|
+
* pass so it precedes `filter-conjunct-ordering`, which copies the stamp forward).
|
|
19
|
+
* Recovers the estimate for a Filter whose predicate PostOptimization itself
|
|
20
|
+
* rewrote — `scalar-subquery-cache` wrapping an uncorrelated scalar subquery's
|
|
21
|
+
* inner re-mints every scalar ancestor up to the predicate. It has to run inside
|
|
22
|
+
* that pass, not merely after it, because the cost readers later in the pass
|
|
23
|
+
* (join-physical-selection, key-set-seek, the materialization advisory) consult
|
|
24
|
+
* the stamp.
|
|
25
|
+
* - `filter-selectivity-final` (FinalEstimates pass, order 37), the backstop behind
|
|
26
|
+
* every plan-mutating pass. Recovers the estimate for a Filter re-minted by the
|
|
27
|
+
* Materialization advisory (order 35) — which rebuilds every path on which it
|
|
28
|
+
* marks a `with` clause for shared materialization or injects a `CacheNode` — and
|
|
29
|
+
* for any future pass ordered before it. Its stamp is read only at emission, so
|
|
30
|
+
* it cannot substitute for the PostOptimization registration.
|
|
31
|
+
*
|
|
32
|
+
* The `selectivity !== undefined` guard below makes the second and third registrations
|
|
33
|
+
* a no-op on every Filter whose stamp survived, so they only ever fill in, never
|
|
34
|
+
* overwrite. All three firings read a physical source subtree (`select-access-path` has
|
|
35
|
+
* already replaced Retrieve with an access node by the Physical pass's own bottom-up
|
|
36
|
+
* order); later sources are the same shape or further lowered — a `CacheNode` the
|
|
37
|
+
* advisory newly slid under the Filter is a generic single-relation wrapper that both
|
|
38
|
+
* `extractRowSourceTableSchema` and `collectColumnOrigins` descend, so the re-derived
|
|
39
|
+
* number matches what the Physical pass produced.
|
|
11
40
|
*
|
|
12
41
|
* Node-level accessors (`estimatedRows` / `computePhysical`) carry no OptContext,
|
|
13
42
|
* so a Filter cannot consult `context.stats` from inside itself. This rule holds
|
|
@@ -15,29 +44,38 @@
|
|
|
15
44
|
* flows through `estimatedRows` automatically.
|
|
16
45
|
*
|
|
17
46
|
* Two paths:
|
|
18
|
-
* - **single-table** — `
|
|
19
|
-
* Filter
|
|
20
|
-
* boolean structure itself.
|
|
21
|
-
* - **multi-relation** — the source spans several tables (a join)
|
|
22
|
-
* predicate into conjuncts, attribute each to the base
|
|
23
|
-
* come from, estimate per conjunct, and combine.
|
|
47
|
+
* - **single-table** — `extractRowSourceTableSchema` finds one base table under
|
|
48
|
+
* the Filter *whose rows are the ones arriving at it*; hand the whole predicate
|
|
49
|
+
* to the provider, which decomposes its boolean structure itself.
|
|
50
|
+
* - **multi-relation** — the source spans several tables (a join), or the strict
|
|
51
|
+
* walk declined. Split the predicate into conjuncts, attribute each to the base
|
|
52
|
+
* table(s) its columns come from, estimate per conjunct, and combine.
|
|
53
|
+
*
|
|
54
|
+
* The strict walk matters because an aggregate's output rows are a different
|
|
55
|
+
* population from its source's, so no fraction of the base table describes them at
|
|
56
|
+
* all: over `select cat, count(*) as ct from o group by cat having ct > 2` the
|
|
57
|
+
* permissive `extractTableSchema` reaches `o` through the aggregate, but `o`'s row
|
|
58
|
+
* count and column distributions say nothing about how many GROUPS survive `ct > 2`.
|
|
59
|
+
*
|
|
60
|
+
* Both paths hand the provider a {@link ColumnStatsResolver} built from
|
|
61
|
+
* `collectColumnOrigins`, so a column in the predicate is matched to statistics by
|
|
62
|
+
* ATTRIBUTE IDENTITY rather than by the name in its AST. `ProjectNode` forwards the
|
|
63
|
+
* source attribute id for a bare column reference and mints a fresh one for a
|
|
64
|
+
* computed expression, which is exactly the distinction wanted: `select cat as qty`
|
|
65
|
+
* still reads `o.cat`'s statistics, while `select id * 7 as qty` reads none rather
|
|
66
|
+
* than borrowing `o.qty`'s because the alias happens to collide. A CTE reference
|
|
67
|
+
* republishes its body's columns under per-reference relation instances, so a `with`
|
|
68
|
+
* clause estimates like the equivalent subquery while the two arms of a CTE self-join
|
|
69
|
+
* still count as two relations — see `column-origins.ts`.
|
|
24
70
|
*/
|
|
25
71
|
import { createLogger } from '../../../common/logger.js';
|
|
26
72
|
import { FilterNode } from '../../nodes/filter.js';
|
|
27
|
-
import {
|
|
28
|
-
import { ColumnReferenceNode } from '../../nodes/reference.js';
|
|
29
|
-
import { extractTableSchema } from '../../util/key-utils.js';
|
|
73
|
+
import { extractRowSourceTableSchema } from '../../util/key-utils.js';
|
|
30
74
|
import { collectColumnOrigins } from '../../util/column-origins.js';
|
|
31
75
|
import { splitConjuncts } from '../../analysis/predicate-conjuncts.js';
|
|
32
76
|
import { combineConjunctive } from '../../stats/selectivity-combine.js';
|
|
77
|
+
import { estimateConjunctSelectivity, makeColumnStatsResolver } from '../../stats/conjunct-selectivity.js';
|
|
33
78
|
const log = createLogger('optimizer:rule:filter-selectivity');
|
|
34
|
-
/**
|
|
35
|
-
* Selectivity of an inequality (`<` `<=` `>` `>=`) comparing a column of one table
|
|
36
|
-
* to a column of another. The standard uniform-distribution estimate for a
|
|
37
|
-
* two-sided inequality is 1/3: there is no cross-table histogram, so nothing
|
|
38
|
-
* better than the uniform assumption is available here.
|
|
39
|
-
*/
|
|
40
|
-
export const CROSS_RELATION_INEQUALITY_SELECTIVITY = 1 / 3;
|
|
41
79
|
export function ruleFilterSelectivity(node, context) {
|
|
42
80
|
const filter = node;
|
|
43
81
|
// Idempotent: a prior fire already stamped this Filter → decline. (The pass
|
|
@@ -45,13 +83,34 @@ export function ruleFilterSelectivity(node, context) {
|
|
|
45
83
|
// makes the rule safe on any already-stamped node regardless.)
|
|
46
84
|
if (filter.selectivity !== undefined)
|
|
47
85
|
return null;
|
|
48
|
-
//
|
|
49
|
-
// TableReference) to the base table
|
|
50
|
-
//
|
|
51
|
-
|
|
86
|
+
// extractRowSourceTableSchema walks single-child wrappers (Filter/Project/Sort/
|
|
87
|
+
// Retrieve/TableReference) to the base table, but stops at any operator whose
|
|
88
|
+
// output rows are not its source's rows (aggregate, recursive CTE, set operation).
|
|
89
|
+
// It returns undefined for those and for a join / other multi-relation source,
|
|
90
|
+
// which is what the second path handles.
|
|
91
|
+
const tableSchema = extractRowSourceTableSchema(filter.source);
|
|
92
|
+
// Attribute id → base-table column, for every base column under the Filter. Both
|
|
93
|
+
// paths need it: the multi-relation path to route a conjunct to a relation, and
|
|
94
|
+
// both paths to identify a predicate's columns by identity rather than by name.
|
|
95
|
+
//
|
|
96
|
+
// NOTE: this walk covers the whole source subtree and this rule fires per
|
|
97
|
+
// FilterNode, so a stack of N filters over one large subtree costs O(N·subtree) —
|
|
98
|
+
// and unlike before, it now runs for EVERY Filter, not only filters over joins.
|
|
99
|
+
// `rule-filter-conjunct-ordering` (PostOptimization) runs the SAME walk again on
|
|
100
|
+
// each Filter it ranks, so the walk now happens twice per Filter. A Filter that is
|
|
101
|
+
// permanently unstampable (computed projection, set-operation output, un-analyzed
|
|
102
|
+
// table) also pays it a third and fourth time, because neither the
|
|
103
|
+
// `filter-selectivity-restamp` nor the `filter-selectivity-final` registration can
|
|
104
|
+
// short-circuit on a stamp that will never exist — measured only as "extra walks",
|
|
105
|
+
// not profiled. The walk is
|
|
106
|
+
// cheap per node and filter stacks are shallow; if it ever shows up in an
|
|
107
|
+
// optimizer profile, memoize the map per pass on OptContext keyed by the source
|
|
108
|
+
// node (or — for the single-table path only — build the resolver from the one
|
|
109
|
+
// TableReferenceNode the strict walk already found, O(columns) not O(subtree)).
|
|
110
|
+
const origins = collectColumnOrigins(filter.source);
|
|
52
111
|
const sel = tableSchema
|
|
53
|
-
? singleTableSelectivity(tableSchema, filter, context)
|
|
54
|
-
: multiRelationSelectivity(filter, context);
|
|
112
|
+
? singleTableSelectivity(tableSchema, filter, origins, context)
|
|
113
|
+
: multiRelationSelectivity(filter, origins, context);
|
|
55
114
|
if (sel === undefined)
|
|
56
115
|
return null;
|
|
57
116
|
const clamped = Math.min(1, Math.max(0, sel));
|
|
@@ -60,7 +119,7 @@ export function ruleFilterSelectivity(node, context) {
|
|
|
60
119
|
return new FilterNode(filter.scope, filter.source, filter.predicate, undefined, clamped);
|
|
61
120
|
}
|
|
62
121
|
// ── Single-table path ───────────────────────────────────────────────────
|
|
63
|
-
function singleTableSelectivity(tableSchema, filter, context) {
|
|
122
|
+
function singleTableSelectivity(tableSchema, filter, origins, context) {
|
|
64
123
|
// CatalogStatsProvider recurses over the predicate's boolean structure, so
|
|
65
124
|
// `a = 1 and b = 2` combines the two per-column estimates rather than falling
|
|
66
125
|
// back to a flat per-nodeType guess. It still returns undefined when it can say
|
|
@@ -69,7 +128,12 @@ function singleTableSelectivity(tableSchema, filter, context) {
|
|
|
69
128
|
// NOTE: this path is deliberately NOT gated on real statistics existing — it may
|
|
70
129
|
// still stamp a NaiveStatsProvider number, as it always has. The multi-relation
|
|
71
130
|
// path below IS gated; see the comment there for why the asymmetry is on purpose.
|
|
72
|
-
|
|
131
|
+
//
|
|
132
|
+
// Schema equality is the right narrowing here: the strict walk established that
|
|
133
|
+
// exactly this table's rows arrive at the Filter, so any origin under it belongs
|
|
134
|
+
// to that one reference anyway.
|
|
135
|
+
const resolve = makeColumnStatsResolver(origins, origin => origin.table === tableSchema);
|
|
136
|
+
const sel = context.stats.selectivity(tableSchema, filter.predicate, resolve);
|
|
73
137
|
if (sel === undefined)
|
|
74
138
|
return undefined;
|
|
75
139
|
log('Filter over %s: stamping selectivity %f', tableSchema.name, sel);
|
|
@@ -91,26 +155,20 @@ function singleTableSelectivity(tableSchema, filter, context) {
|
|
|
91
155
|
* the base-table fraction is applied to post-aggregate cardinality. Imprecise but
|
|
92
156
|
* not unsound; deliberately not special-cased.
|
|
93
157
|
*
|
|
94
|
-
* NOTE: the stamped number
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* `debt-
|
|
100
|
-
*
|
|
101
|
-
* NOTE: `collectColumnOrigins` walks the whole source subtree and this rule fires
|
|
102
|
-
* per FilterNode, so a stack of N filters over one large subtree costs O(N·subtree).
|
|
103
|
-
* Filters over joins are few and the walk is cheap per node; if this ever shows up
|
|
104
|
-
* in optimizer profiles, compute the map once per pass and cache it on OptContext.
|
|
158
|
+
* NOTE: the stamped number does move `estimatedRows` above a join — the join family
|
|
159
|
+
* derives its physical cardinality from its children's PHYSICAL counts
|
|
160
|
+
* (`physicalSourceRows` / `joinPhysicalRows`), so a Filter over a join has a real
|
|
161
|
+
* number to multiply. It still has nothing to multiply above a `union`/`union all`,
|
|
162
|
+
* where `SetOperationNode` stamps no count at all (backlog
|
|
163
|
+
* `debt-row-estimates-die-at-set-operations`).
|
|
105
164
|
*/
|
|
106
|
-
function multiRelationSelectivity(filter, context) {
|
|
107
|
-
const origins = collectColumnOrigins(filter.source);
|
|
165
|
+
function multiRelationSelectivity(filter, origins, context) {
|
|
108
166
|
if (origins.size === 0)
|
|
109
167
|
return undefined;
|
|
110
168
|
const conjuncts = splitConjuncts(filter.predicate);
|
|
111
169
|
const known = [];
|
|
112
170
|
for (const conjunct of conjuncts) {
|
|
113
|
-
const sel =
|
|
171
|
+
const sel = estimateConjunctSelectivity(conjunct, origins, context);
|
|
114
172
|
if (sel !== undefined)
|
|
115
173
|
known.push(sel);
|
|
116
174
|
}
|
|
@@ -125,118 +183,9 @@ function multiRelationSelectivity(filter, context) {
|
|
|
125
183
|
return combined;
|
|
126
184
|
}
|
|
127
185
|
function countRelations(origins) {
|
|
128
|
-
const
|
|
186
|
+
const relations = new Set();
|
|
129
187
|
for (const origin of origins.values())
|
|
130
|
-
|
|
131
|
-
return
|
|
132
|
-
}
|
|
133
|
-
/** Estimate one conjunct, or undefined when it cannot be attributed / estimated. */
|
|
134
|
-
function estimateConjunct(conjunct, origins, context) {
|
|
135
|
-
const refs = conjunctRelations(conjunct, origins);
|
|
136
|
-
if (refs === undefined)
|
|
137
|
-
return undefined;
|
|
138
|
-
if (refs.size === 1) {
|
|
139
|
-
const [ref] = refs;
|
|
140
|
-
return singleRelationConjunct(ref.tableSchema, conjunct, context);
|
|
141
|
-
}
|
|
142
|
-
if (refs.size === 2) {
|
|
143
|
-
return crossRelationConjunct(conjunct, origins, context);
|
|
144
|
-
}
|
|
145
|
-
// Three or more relations in one conjunct: no model for it here.
|
|
146
|
-
return undefined;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* The distinct relations a conjunct's column references come from.
|
|
150
|
-
*
|
|
151
|
-
* Returns undefined when the conjunct references no column at all, or references
|
|
152
|
-
* any attribute that is not a base-table column (a computed projection, an
|
|
153
|
-
* aggregate output, a join existence flag, a set-operation output, a column of a
|
|
154
|
-
* table inside a scalar subquery) — in either case there are no statistics to
|
|
155
|
-
* consult.
|
|
156
|
-
*/
|
|
157
|
-
function conjunctRelations(conjunct, origins) {
|
|
158
|
-
const refs = new Set();
|
|
159
|
-
const stack = [conjunct];
|
|
160
|
-
while (stack.length > 0) {
|
|
161
|
-
const n = stack.pop();
|
|
162
|
-
if (n instanceof ColumnReferenceNode) {
|
|
163
|
-
const origin = origins.get(n.attributeId);
|
|
164
|
-
if (!origin)
|
|
165
|
-
return undefined;
|
|
166
|
-
refs.add(origin.ref);
|
|
167
|
-
continue;
|
|
168
|
-
}
|
|
169
|
-
for (const child of n.getChildren())
|
|
170
|
-
stack.push(child);
|
|
171
|
-
}
|
|
172
|
-
return refs.size > 0 ? refs : undefined;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* A conjunct over exactly one relation: hand it to the provider as if it were a
|
|
176
|
-
* single-table predicate.
|
|
177
|
-
*
|
|
178
|
-
* `statsOnlySelectivity` — not `selectivity` — IS the statistics gate. `selectivity`
|
|
179
|
-
* always returns a number (CatalogStatsProvider falls through to NaiveStatsProvider,
|
|
180
|
-
* which answers a flat 0.1 for any BinaryOp), so using it here would replace 0.5 with
|
|
181
|
-
* 0.1 on essentially every filter-over-join in the codebase — including the many tests
|
|
182
|
-
* that never run ANALYZE — churning plan shapes with no information behind the change.
|
|
183
|
-
* It also covers the subtler case of an analyzed table with a predicate the catalog
|
|
184
|
-
* cannot read (`lower(o.cat) = 'x'`), which a column-stats-presence check would let
|
|
185
|
-
* through. A provider that does not implement it is treated as having no statistics.
|
|
186
|
-
*/
|
|
187
|
-
function singleRelationConjunct(table, conjunct, context) {
|
|
188
|
-
return context.stats.statsOnlySelectivity?.(table, conjunct);
|
|
189
|
-
}
|
|
190
|
-
function hasColumnStats(origin) {
|
|
191
|
-
return origin.table.statistics?.columnStats.has(origin.columnName.toLowerCase()) ?? false;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* A conjunct comparing a column of one relation to a column of another
|
|
195
|
-
* (`o.qty > l.qty`, `a.id = b.id`). Only a plain binary comparison with a bare
|
|
196
|
-
* column reference on each side is modelled; anything else is unknown.
|
|
197
|
-
*
|
|
198
|
-
* Gated on real column statistics for BOTH compared columns, for the same reason as
|
|
199
|
-
* {@link singleRelationConjunct}: `joinSelectivity` falls back to
|
|
200
|
-
* `NaiveStatsProvider`'s `1/max(rowCount)` whenever it cannot read a distinct count,
|
|
201
|
-
* so table-level `statistics` being present is not enough on its own.
|
|
202
|
-
*/
|
|
203
|
-
function crossRelationConjunct(conjunct, origins, context) {
|
|
204
|
-
if (!(conjunct instanceof BinaryOpNode))
|
|
205
|
-
return undefined;
|
|
206
|
-
if (!(conjunct.left instanceof ColumnReferenceNode))
|
|
207
|
-
return undefined;
|
|
208
|
-
if (!(conjunct.right instanceof ColumnReferenceNode))
|
|
209
|
-
return undefined;
|
|
210
|
-
const leftOrigin = origins.get(conjunct.left.attributeId);
|
|
211
|
-
const rightOrigin = origins.get(conjunct.right.attributeId);
|
|
212
|
-
if (!leftOrigin || !rightOrigin)
|
|
213
|
-
return undefined;
|
|
214
|
-
if (!hasColumnStats(leftOrigin) || !hasColumnStats(rightOrigin))
|
|
215
|
-
return undefined;
|
|
216
|
-
const op = conjunct.expression.operator;
|
|
217
|
-
if (op === '=' || op === '==')
|
|
218
|
-
return equiJoinSelectivity(conjunct, leftOrigin, rightOrigin, context);
|
|
219
|
-
// `extractEquiJoinColumns` accepts only `=`, so the catalog declines a `<>` and
|
|
220
|
-
// `joinSelectivity` answers from NaiveStatsProvider, which is capped at 0.5. The
|
|
221
|
-
// complement is therefore bounded to [0.5, 1] — it can only ever relax the
|
|
222
|
-
// estimate relative to DEFAULT_FILTER_SELECTIVITY, and the true value for a
|
|
223
|
-
// cross-relation `<>` is near 1, so the bound errs in the right direction.
|
|
224
|
-
if (op === '!=' || op === '<>') {
|
|
225
|
-
const eq = equiJoinSelectivity(conjunct, leftOrigin, rightOrigin, context);
|
|
226
|
-
return eq === undefined ? undefined : 1 - eq;
|
|
227
|
-
}
|
|
228
|
-
if (op === '<' || op === '<=' || op === '>' || op === '>=') {
|
|
229
|
-
return CROSS_RELATION_INEQUALITY_SELECTIVITY;
|
|
230
|
-
}
|
|
231
|
-
return undefined;
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Argument order matters: `CatalogStatsProvider.joinSelectivity` reads the column
|
|
235
|
-
* pair off the condition's own child order (`extractEquiJoinColumns`) and
|
|
236
|
-
* `fkPkSelectivity` interprets left/right against the tables it was handed. So the
|
|
237
|
-
* table owning the conjunct's LEFT child must be passed first.
|
|
238
|
-
*/
|
|
239
|
-
function equiJoinSelectivity(conjunct, leftOrigin, rightOrigin, context) {
|
|
240
|
-
return context.stats.joinSelectivity?.(leftOrigin.table, rightOrigin.table, conjunct);
|
|
188
|
+
relations.add(origin.relation);
|
|
189
|
+
return relations.size;
|
|
241
190
|
}
|
|
242
191
|
//# sourceMappingURL=rule-filter-selectivity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-filter-selectivity.js","sourceRoot":"","sources":["../../../../../src/planner/rules/predicate/rule-filter-selectivity.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"rule-filter-selectivity.js","sourceRoot":"","sources":["../../../../../src/planner/rules/predicate/rule-filter-selectivity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAIzD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAA4C,MAAM,8BAA8B,CAAC;AAC9G,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAE3G,MAAM,GAAG,GAAG,YAAY,CAAC,mCAAmC,CAAC,CAAC;AAE9D,MAAM,UAAU,qBAAqB,CAAC,IAAc,EAAE,OAAmB;IACxE,MAAM,MAAM,GAAG,IAAkB,CAAC;IAElC,4EAA4E;IAC5E,2EAA2E;IAC3E,+DAA+D;IAC/D,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAElD,gFAAgF;IAChF,8EAA8E;IAC9E,mFAAmF;IACnF,+EAA+E;IAC/E,yCAAyC;IACzC,MAAM,WAAW,GAAG,2BAA2B,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE/D,iFAAiF;IACjF,gFAAgF;IAChF,gFAAgF;IAChF,EAAE;IACF,0EAA0E;IAC1E,kFAAkF;IAClF,gFAAgF;IAChF,iFAAiF;IACjF,mFAAmF;IACnF,kFAAkF;I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E,OAAO,SAAS,CAAC,IAAI,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule: Join Predicate Pushdown
|
|
3
|
+
*
|
|
4
|
+
* For a `FilterNode(predicate, JoinNode)`, each conjunct of `predicate` whose
|
|
5
|
+
* column references all land on ONE side of the join is MOVED onto that side's
|
|
6
|
+
* branch (wrapped as a `FilterNode` around `join.left` / `join.right`).
|
|
7
|
+
* Cross-side conjuncts, and anything the refusals below reject, stay in a
|
|
8
|
+
* residual Filter above the rebuilt join.
|
|
9
|
+
*
|
|
10
|
+
* Why this is sound — the null-extension argument. A side may receive a
|
|
11
|
+
* conjunct exactly when that side's columns are NEVER null-extended in the
|
|
12
|
+
* join's output (read straight off `buildJoinAttributes` in
|
|
13
|
+
* `nodes/join-utils.ts`). For such a side, every output row carries that side's
|
|
14
|
+
* genuine input values, so rejecting an input row before the join removes
|
|
15
|
+
* precisely the output rows the conjunct would have removed after it. On a
|
|
16
|
+
* null-extended side the two differ: `left join r … where r.date > 'x'` drops
|
|
17
|
+
* the NULL-padded rows after the join, but pushing `r.date > 'x'` below would
|
|
18
|
+
* KEEP them (the left row simply finds no match and is padded again).
|
|
19
|
+
*
|
|
20
|
+
* | joinType | null-extended side | conjuncts pushable to |
|
|
21
|
+
* |----------|--------------------|-----------------------|
|
|
22
|
+
* | `inner` | neither | left and right |
|
|
23
|
+
* | `cross` | neither | left and right |
|
|
24
|
+
* | `left` | right | left only |
|
|
25
|
+
* | `right` | left | right only |
|
|
26
|
+
* | `full` | both | neither — rule declines |
|
|
27
|
+
* | `semi` | n/a (output is left columns) | left only |
|
|
28
|
+
* | `anti` | n/a (output is left columns) | left only |
|
|
29
|
+
*
|
|
30
|
+
* For `semi`/`anti` the left-only restriction is moot in practice —
|
|
31
|
+
* `buildJoinAttributes` returns only the left attributes, so a Filter above such
|
|
32
|
+
* a join cannot reference a right column at all — but it is encoded anyway so
|
|
33
|
+
* the table is exhaustive and the reasoning stays local.
|
|
34
|
+
*
|
|
35
|
+
* Attribution is a plain attribute-id set test: ids are minted per node instance
|
|
36
|
+
* and are stable across this pass's rewrites, so a self-join's two branches
|
|
37
|
+
* carry distinct ids, and a join's `exists … as` flag ids are in neither side's
|
|
38
|
+
* set (a conjunct over a flag falls out as un-pushable with no special case).
|
|
39
|
+
*
|
|
40
|
+
* Refusals:
|
|
41
|
+
* - A conjunct whose subtree references a RELATIONAL child (any subquery) is
|
|
42
|
+
* left above. The id collector descends through relational children too, so
|
|
43
|
+
* `exists (select 1 from x where x.a = e.id and x.b = t.id)` contributes `x`'s
|
|
44
|
+
* own ids — which belong to neither side — and the conjunct is declined. That
|
|
45
|
+
* descent is load-bearing: a scalar-only walk would see only `e.id` and push a
|
|
46
|
+
* conjunct onto the left branch where `t.id` does not resolve.
|
|
47
|
+
* - Symmetrically, a conjunct naming a column from OUTSIDE the join — an outer
|
|
48
|
+
* reference, when this `Filter(Join)` is itself the body of a correlated
|
|
49
|
+
* subquery — sees an id in neither side's set and is declined.
|
|
50
|
+
* NOTE: sound but pessimistic — `x.a = <outer>.b` would be safe on the `x`
|
|
51
|
+
* branch. Ignoring "in neither side" ids instead of refusing on them would
|
|
52
|
+
* recover that. {@link collectSubtreeAttributeIds} does not distinguish a
|
|
53
|
+
* genuinely-outer id from a subquery-internal one, but
|
|
54
|
+
* `analysis/predicate-dependencies.ts` does — its `correlated` set is exactly
|
|
55
|
+
* the outer ids, and swapping this walk for it is the whole change. Left alone
|
|
56
|
+
* until a real correlated body is measured losing a seek to it; the swap also
|
|
57
|
+
* makes more conjuncts pushable, which needs its own plan-shape coverage.
|
|
58
|
+
* - A conjunct with NO column references (`where 1 = 1`, `where :p > 0`) stays
|
|
59
|
+
* above; pushing it buys nothing and would make the rule fire on plans it
|
|
60
|
+
* should leave alone.
|
|
61
|
+
* - A non-functional conjunct (`random() < e.amount`) stays above — moving it
|
|
62
|
+
* below the join changes how many times it is evaluated.
|
|
63
|
+
* - A branch whose subtree carries a write keeps ITS conjuncts above while the
|
|
64
|
+
* other branch still receives its own (per-branch refusal, unlike
|
|
65
|
+
* `rule-predicate-inference-equivalence`'s outright one).
|
|
66
|
+
*
|
|
67
|
+
* A pushed conjunct is MOVED, not copied. A redundant copy above would
|
|
68
|
+
* re-evaluate per output row for no gain and, worse, make the rule
|
|
69
|
+
* non-idempotent — it would find the same pushable conjunct on every visit.
|
|
70
|
+
* With a move, a re-visit of the residual Filter finds nothing pushable and
|
|
71
|
+
* returns null, which is the termination argument.
|
|
72
|
+
*/
|
|
73
|
+
import type { PlanNode } from '../../nodes/plan-node.js';
|
|
74
|
+
import type { OptContext } from '../../framework/context.js';
|
|
75
|
+
export declare function ruleJoinPredicatePushdown(node: PlanNode, _context: OptContext): PlanNode | null;
|
|
76
|
+
//# sourceMappingURL=rule-join-predicate-pushdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-join-predicate-pushdown.d.ts","sourceRoot":"","sources":["../../../../../src/planner/rules/predicate/rule-join-predicate-pushdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAsC,MAAM,0BAA0B,CAAC;AAC7F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAyE7D,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,GAAG,QAAQ,GAAG,IAAI,CA0E/F"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule: Join Predicate Pushdown
|
|
3
|
+
*
|
|
4
|
+
* For a `FilterNode(predicate, JoinNode)`, each conjunct of `predicate` whose
|
|
5
|
+
* column references all land on ONE side of the join is MOVED onto that side's
|
|
6
|
+
* branch (wrapped as a `FilterNode` around `join.left` / `join.right`).
|
|
7
|
+
* Cross-side conjuncts, and anything the refusals below reject, stay in a
|
|
8
|
+
* residual Filter above the rebuilt join.
|
|
9
|
+
*
|
|
10
|
+
* Why this is sound — the null-extension argument. A side may receive a
|
|
11
|
+
* conjunct exactly when that side's columns are NEVER null-extended in the
|
|
12
|
+
* join's output (read straight off `buildJoinAttributes` in
|
|
13
|
+
* `nodes/join-utils.ts`). For such a side, every output row carries that side's
|
|
14
|
+
* genuine input values, so rejecting an input row before the join removes
|
|
15
|
+
* precisely the output rows the conjunct would have removed after it. On a
|
|
16
|
+
* null-extended side the two differ: `left join r … where r.date > 'x'` drops
|
|
17
|
+
* the NULL-padded rows after the join, but pushing `r.date > 'x'` below would
|
|
18
|
+
* KEEP them (the left row simply finds no match and is padded again).
|
|
19
|
+
*
|
|
20
|
+
* | joinType | null-extended side | conjuncts pushable to |
|
|
21
|
+
* |----------|--------------------|-----------------------|
|
|
22
|
+
* | `inner` | neither | left and right |
|
|
23
|
+
* | `cross` | neither | left and right |
|
|
24
|
+
* | `left` | right | left only |
|
|
25
|
+
* | `right` | left | right only |
|
|
26
|
+
* | `full` | both | neither — rule declines |
|
|
27
|
+
* | `semi` | n/a (output is left columns) | left only |
|
|
28
|
+
* | `anti` | n/a (output is left columns) | left only |
|
|
29
|
+
*
|
|
30
|
+
* For `semi`/`anti` the left-only restriction is moot in practice —
|
|
31
|
+
* `buildJoinAttributes` returns only the left attributes, so a Filter above such
|
|
32
|
+
* a join cannot reference a right column at all — but it is encoded anyway so
|
|
33
|
+
* the table is exhaustive and the reasoning stays local.
|
|
34
|
+
*
|
|
35
|
+
* Attribution is a plain attribute-id set test: ids are minted per node instance
|
|
36
|
+
* and are stable across this pass's rewrites, so a self-join's two branches
|
|
37
|
+
* carry distinct ids, and a join's `exists … as` flag ids are in neither side's
|
|
38
|
+
* set (a conjunct over a flag falls out as un-pushable with no special case).
|
|
39
|
+
*
|
|
40
|
+
* Refusals:
|
|
41
|
+
* - A conjunct whose subtree references a RELATIONAL child (any subquery) is
|
|
42
|
+
* left above. The id collector descends through relational children too, so
|
|
43
|
+
* `exists (select 1 from x where x.a = e.id and x.b = t.id)` contributes `x`'s
|
|
44
|
+
* own ids — which belong to neither side — and the conjunct is declined. That
|
|
45
|
+
* descent is load-bearing: a scalar-only walk would see only `e.id` and push a
|
|
46
|
+
* conjunct onto the left branch where `t.id` does not resolve.
|
|
47
|
+
* - Symmetrically, a conjunct naming a column from OUTSIDE the join — an outer
|
|
48
|
+
* reference, when this `Filter(Join)` is itself the body of a correlated
|
|
49
|
+
* subquery — sees an id in neither side's set and is declined.
|
|
50
|
+
* NOTE: sound but pessimistic — `x.a = <outer>.b` would be safe on the `x`
|
|
51
|
+
* branch. Ignoring "in neither side" ids instead of refusing on them would
|
|
52
|
+
* recover that. {@link collectSubtreeAttributeIds} does not distinguish a
|
|
53
|
+
* genuinely-outer id from a subquery-internal one, but
|
|
54
|
+
* `analysis/predicate-dependencies.ts` does — its `correlated` set is exactly
|
|
55
|
+
* the outer ids, and swapping this walk for it is the whole change. Left alone
|
|
56
|
+
* until a real correlated body is measured losing a seek to it; the swap also
|
|
57
|
+
* makes more conjuncts pushable, which needs its own plan-shape coverage.
|
|
58
|
+
* - A conjunct with NO column references (`where 1 = 1`, `where :p > 0`) stays
|
|
59
|
+
* above; pushing it buys nothing and would make the rule fire on plans it
|
|
60
|
+
* should leave alone.
|
|
61
|
+
* - A non-functional conjunct (`random() < e.amount`) stays above — moving it
|
|
62
|
+
* below the join changes how many times it is evaluated.
|
|
63
|
+
* - A branch whose subtree carries a write keeps ITS conjuncts above while the
|
|
64
|
+
* other branch still receives its own (per-branch refusal, unlike
|
|
65
|
+
* `rule-predicate-inference-equivalence`'s outright one).
|
|
66
|
+
*
|
|
67
|
+
* A pushed conjunct is MOVED, not copied. A redundant copy above would
|
|
68
|
+
* re-evaluate per output row for no gain and, worse, make the rule
|
|
69
|
+
* non-idempotent — it would find the same pushable conjunct on every visit.
|
|
70
|
+
* With a move, a re-visit of the residual Filter finds nothing pushable and
|
|
71
|
+
* returns null, which is the termination argument.
|
|
72
|
+
*/
|
|
73
|
+
import { createLogger } from '../../../common/logger.js';
|
|
74
|
+
import { PlanNodeType } from '../../nodes/plan-node-type.js';
|
|
75
|
+
import { FilterNode } from '../../nodes/filter.js';
|
|
76
|
+
import { JoinNode } from '../../nodes/join-node.js';
|
|
77
|
+
import { ColumnReferenceNode } from '../../nodes/reference.js';
|
|
78
|
+
import { normalizePredicate } from '../../analysis/predicate-normalizer.js';
|
|
79
|
+
import { splitConjuncts, combineConjuncts } from '../../analysis/predicate-conjuncts.js';
|
|
80
|
+
import { PlanNodeCharacteristics } from '../../framework/characteristics.js';
|
|
81
|
+
const log = createLogger('optimizer:rule:join-predicate-pushdown');
|
|
82
|
+
/** The sides of `joinType` that are never null-extended in the output — see the header table. */
|
|
83
|
+
function pushableSides(joinType) {
|
|
84
|
+
switch (joinType) {
|
|
85
|
+
case 'inner':
|
|
86
|
+
case 'cross':
|
|
87
|
+
return new Set(['left', 'right']);
|
|
88
|
+
case 'left':
|
|
89
|
+
case 'semi':
|
|
90
|
+
case 'anti':
|
|
91
|
+
return new Set(['left']);
|
|
92
|
+
case 'right':
|
|
93
|
+
return new Set(['right']);
|
|
94
|
+
case 'full':
|
|
95
|
+
return new Set();
|
|
96
|
+
default:
|
|
97
|
+
return new Set();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Every attribute id any `ColumnReferenceNode` in `expr`'s WHOLE subtree names —
|
|
102
|
+
* descending through relational children as well as scalar ones. See the
|
|
103
|
+
* file-header refusal notes for why the relational descent is required.
|
|
104
|
+
*/
|
|
105
|
+
function collectSubtreeAttributeIds(expr) {
|
|
106
|
+
const ids = new Set();
|
|
107
|
+
// Iterative worklist so a deep predicate cannot overflow the native stack.
|
|
108
|
+
const stack = [expr];
|
|
109
|
+
while (stack.length > 0) {
|
|
110
|
+
const current = stack.pop();
|
|
111
|
+
if (current instanceof ColumnReferenceNode) {
|
|
112
|
+
ids.add(current.attributeId);
|
|
113
|
+
}
|
|
114
|
+
for (const child of current.getChildren()) {
|
|
115
|
+
stack.push(child);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return ids;
|
|
119
|
+
}
|
|
120
|
+
/** The single side `ids` lands entirely on, or null when it spans / escapes both. */
|
|
121
|
+
function attributeSide(ids, leftIds, rightIds) {
|
|
122
|
+
let allLeft = true;
|
|
123
|
+
let allRight = true;
|
|
124
|
+
for (const id of ids) {
|
|
125
|
+
if (!leftIds.has(id))
|
|
126
|
+
allLeft = false;
|
|
127
|
+
if (!rightIds.has(id))
|
|
128
|
+
allRight = false;
|
|
129
|
+
if (!allLeft && !allRight)
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
// A self-join mints distinct ids per branch, so the two sets are disjoint and
|
|
133
|
+
// a non-empty `ids` can satisfy at most one of these.
|
|
134
|
+
if (allLeft)
|
|
135
|
+
return 'left';
|
|
136
|
+
if (allRight)
|
|
137
|
+
return 'right';
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
export function ruleJoinPredicatePushdown(node, _context) {
|
|
141
|
+
if (node.nodeType !== PlanNodeType.Filter)
|
|
142
|
+
return null;
|
|
143
|
+
const filter = node;
|
|
144
|
+
const join = filter.source;
|
|
145
|
+
if (!(join instanceof JoinNode))
|
|
146
|
+
return null;
|
|
147
|
+
const sides = pushableSides(join.joinType);
|
|
148
|
+
if (sides.size === 0)
|
|
149
|
+
return null;
|
|
150
|
+
const leftIds = new Set(join.left.getAttributes().map(a => a.id));
|
|
151
|
+
const rightIds = new Set(join.right.getAttributes().map(a => a.id));
|
|
152
|
+
const conjuncts = splitConjuncts(normalizePredicate(filter.predicate));
|
|
153
|
+
let leftPush = [];
|
|
154
|
+
let rightPush = [];
|
|
155
|
+
const residual = [];
|
|
156
|
+
for (const conj of conjuncts) {
|
|
157
|
+
const ids = collectSubtreeAttributeIds(conj);
|
|
158
|
+
// No column reference at all (`1 = 1`, `:p > 0`): nothing to gain below.
|
|
159
|
+
if (ids.size === 0) {
|
|
160
|
+
residual.push(conj);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
// Non-deterministic / write-bearing conjunct: moving it changes how many
|
|
164
|
+
// times it is evaluated.
|
|
165
|
+
if (!PlanNodeCharacteristics.isFunctional(conj)) {
|
|
166
|
+
residual.push(conj);
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
const side = attributeSide(ids, leftIds, rightIds);
|
|
170
|
+
if (side === null || !sides.has(side)) {
|
|
171
|
+
residual.push(conj);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
(side === 'left' ? leftPush : rightPush).push(conj);
|
|
175
|
+
}
|
|
176
|
+
// Per-branch side-effect refusal: a branch carrying a write keeps its own
|
|
177
|
+
// conjuncts above while the other branch still receives its.
|
|
178
|
+
if (leftPush.length > 0 && PlanNodeCharacteristics.subtreeHasSideEffects(join.left)) {
|
|
179
|
+
log('join-predicate-pushdown: left branch has side effects; keeping its conjuncts above');
|
|
180
|
+
residual.push(...leftPush);
|
|
181
|
+
leftPush = [];
|
|
182
|
+
}
|
|
183
|
+
if (rightPush.length > 0 && PlanNodeCharacteristics.subtreeHasSideEffects(join.right)) {
|
|
184
|
+
log('join-predicate-pushdown: right branch has side effects; keeping its conjuncts above');
|
|
185
|
+
residual.push(...rightPush);
|
|
186
|
+
rightPush = [];
|
|
187
|
+
}
|
|
188
|
+
if (leftPush.length === 0 && rightPush.length === 0)
|
|
189
|
+
return null;
|
|
190
|
+
const newLeft = leftPush.length > 0
|
|
191
|
+
? new FilterNode(join.left.scope, join.left, combineConjuncts(leftPush))
|
|
192
|
+
: join.left;
|
|
193
|
+
const newRight = rightPush.length > 0
|
|
194
|
+
? new FilterNode(join.right.scope, join.right, combineConjuncts(rightPush))
|
|
195
|
+
: join.right;
|
|
196
|
+
// `withChildren` (not `new JoinNode(...)`) so `existence` and `usingColumns`
|
|
197
|
+
// thread through — a dropped existence spec strands every upstream reference
|
|
198
|
+
// to the flag's attribute id.
|
|
199
|
+
const newChildren = join.condition
|
|
200
|
+
? [newLeft, newRight, join.condition]
|
|
201
|
+
: [newLeft, newRight];
|
|
202
|
+
const newJoin = join.withChildren(newChildren);
|
|
203
|
+
log('Pushed %d left + %d right conjunct(s) below %s join (%d residual)', leftPush.length, rightPush.length, join.joinType, residual.length);
|
|
204
|
+
if (residual.length === 0)
|
|
205
|
+
return newJoin;
|
|
206
|
+
return new FilterNode(filter.scope, newJoin, combineConjuncts(residual));
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=rule-join-predicate-pushdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-join-predicate-pushdown.js","sourceRoot":"","sources":["../../../../../src/planner/rules/predicate/rule-join-predicate-pushdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAiB,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAE7E,MAAM,GAAG,GAAG,YAAY,CAAC,wCAAwC,CAAC,CAAC;AAInE,iGAAiG;AACjG,SAAS,aAAa,CAAC,QAAkB;IACxC,QAAQ,QAAQ,EAAE,CAAC;QAClB,KAAK,OAAO,C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