@quereus/quereus 4.6.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 +2 -2
- 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 +62 -0
- package/dist/src/core/database-events.d.ts.map +1 -1
- package/dist/src/core/database-events.js +88 -2
- 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 +4 -2
- 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.d.ts +9 -1
- package/dist/src/core/database.d.ts.map +1 -1
- package/dist/src/core/database.js +36 -10
- 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/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/scalar.d.ts.map +1 -1
- package/dist/src/func/builtins/scalar.js +24 -20
- 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 +32 -5
- package/dist/src/func/builtins/schema.js.map +1 -1
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -4
- 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.js +1 -1
- 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/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 +53 -17
- package/dist/src/planner/building/alter-table.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/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 +53 -40
- 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 +187 -2
- package/dist/src/planner/building/select-aggregates.d.ts.map +1 -1
- package/dist/src/planner/building/select-aggregates.js +414 -81
- 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 +91 -0
- package/dist/src/planner/building/select-context.d.ts.map +1 -1
- package/dist/src/planner/building/select-context.js +113 -0
- 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.map +1 -1
- package/dist/src/planner/building/select.js +129 -59
- 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/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 +14 -5
- package/dist/src/planner/nodes/aggregate-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/aggregate-node.js +28 -21
- package/dist/src/planner/nodes/aggregate-node.js.map +1 -1
- package/dist/src/planner/nodes/alter-table-node.d.ts +27 -2
- 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/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/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/filter.d.ts.map +1 -1
- package/dist/src/planner/nodes/filter.js +12 -6
- package/dist/src/planner/nodes/filter.js.map +1 -1
- package/dist/src/planner/nodes/hash-aggregate.d.ts +0 -5
- package/dist/src/planner/nodes/hash-aggregate.d.ts.map +1 -1
- package/dist/src/planner/nodes/hash-aggregate.js +17 -20
- 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/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 +85 -16
- 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.map +1 -1
- package/dist/src/planner/nodes/plan-node.d.ts +5 -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 +16 -35
- package/dist/src/planner/nodes/project-node.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 +8 -1
- 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/stream-aggregate.d.ts +0 -5
- package/dist/src/planner/nodes/stream-aggregate.d.ts.map +1 -1
- package/dist/src/planner/nodes/stream-aggregate.js +18 -24
- 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 +64 -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/optimizer.d.ts +18 -0
- package/dist/src/planner/optimizer.d.ts.map +1 -1
- package/dist/src/planner/optimizer.js +59 -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 +297 -71
- 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 +11 -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 +46 -2
- 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 +6 -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/join/index-nested-loop.d.ts.map +1 -1
- package/dist/src/planner/rules/join/index-nested-loop.js +13 -7
- package/dist/src/planner/rules/join/index-nested-loop.js.map +1 -1
- 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 +2 -2
- 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 +46 -16
- 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 +14 -0
- 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-selectivity.d.ts +33 -19
- package/dist/src/planner/rules/predicate/rule-filter-selectivity.d.ts.map +1 -1
- package/dist/src/planner/rules/predicate/rule-filter-selectivity.js +37 -18
- 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 +6 -3
- package/dist/src/planner/rules/predicate/rule-join-predicate-pushdown.d.ts.map +1 -1
- package/dist/src/planner/rules/predicate/rule-join-predicate-pushdown.js +6 -3
- package/dist/src/planner/rules/predicate/rule-join-predicate-pushdown.js.map +1 -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 +11 -21
- package/dist/src/planner/rules/predicate/rule-predicate-pushdown.js.map +1 -1
- package/dist/src/planner/rules/shared/access-leaf.d.ts +16 -3
- package/dist/src/planner/rules/shared/access-leaf.d.ts.map +1 -1
- package/dist/src/planner/rules/shared/access-leaf.js +21 -5
- package/dist/src/planner/rules/shared/access-leaf.js.map +1 -1
- package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.js +1 -1
- 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.js +1 -1
- package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.js.map +1 -1
- 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/ind-utils.d.ts +28 -20
- package/dist/src/planner/util/ind-utils.d.ts.map +1 -1
- package/dist/src/planner/util/ind-utils.js +36 -27
- package/dist/src/planner/util/ind-utils.js.map +1 -1
- package/dist/src/planner/util/key-utils.d.ts +19 -4
- package/dist/src/planner/util/key-utils.d.ts.map +1 -1
- package/dist/src/planner/util/key-utils.js +23 -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 +11 -0
- package/dist/src/planner/util/row-estimates.d.ts.map +1 -1
- package/dist/src/planner/util/row-estimates.js +28 -0
- package/dist/src/planner/util/row-estimates.js.map +1 -1
- 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 +22 -6
- package/dist/src/runtime/emit/add-constraint.js.map +1 -1
- package/dist/src/runtime/emit/alter-schema-event.d.ts +59 -4
- package/dist/src/runtime/emit/alter-schema-event.d.ts.map +1 -1
- package/dist/src/runtime/emit/alter-schema-event.js +63 -4
- package/dist/src/runtime/emit/alter-schema-event.js.map +1 -1
- package/dist/src/runtime/emit/alter-table.d.ts.map +1 -1
- package/dist/src/runtime/emit/alter-table.js +212 -92
- 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 +15 -4
- 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/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 +169 -1
- 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-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/key-set-semi-join.d.ts.map +1 -1
- package/dist/src/runtime/emit/key-set-semi-join.js +5 -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/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/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/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.js +19 -3
- package/dist/src/schema/catalog-persistability.js.map +1 -1
- package/dist/src/schema/catalog.d.ts +6 -0
- package/dist/src/schema/catalog.d.ts.map +1 -1
- package/dist/src/schema/catalog.js +26 -36
- 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/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.js +8 -0
- package/dist/src/schema/ddl-generator.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 +30 -12
- package/dist/src/schema/manager.d.ts.map +1 -1
- package/dist/src/schema/manager.js +49 -17
- 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 +122 -11
- package/dist/src/schema/schema-differ.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 +38 -0
- package/dist/src/types/builtin-types.d.ts.map +1 -1
- package/dist/src/types/builtin-types.js +77 -26
- package/dist/src/types/builtin-types.js.map +1 -1
- package/dist/src/types/index.d.ts +1 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js +1 -1
- package/dist/src/types/index.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/vtab/events.d.ts +3 -0
- 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/manager.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/manager.js +3 -69
- package/dist/src/vtab/memory/layer/manager.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 +62 -2
- package/dist/src/vtab/memory/module.js.map +1 -1
- package/dist/src/vtab/module.d.ts +26 -2
- package/dist/src/vtab/module.d.ts.map +1 -1
- package/dist/src/vtab/table.d.ts +8 -1
- package/dist/src/vtab/table.d.ts.map +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
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { PlanningContext } from '../planning-context.js';
|
|
2
|
+
/**
|
|
3
|
+
* The planning context any SCHEMA-AUTHORED expression must be built on — a column
|
|
4
|
+
* `DEFAULT`, a generated-column expression, a `CHECK` constraint, or a synthesized
|
|
5
|
+
* foreign-key probe. All four are written in the TABLE's definition, not in the
|
|
6
|
+
* statement doing the write, so their unqualified relation names must always mean
|
|
7
|
+
* real schema objects, and must mean the SAME ones no matter where the writing
|
|
8
|
+
* statement happens to be pointed. `schemaName` is the OWNING table's schema (for the
|
|
9
|
+
* anchor key default on a view write-through, the anchor BASE table's schema — not
|
|
10
|
+
* the view's).
|
|
11
|
+
*
|
|
12
|
+
* Clears the two CTE-related fields so no statement's common table expressions — the
|
|
13
|
+
* writing statement's own leading `with` clause, or ones it inherited from an enclosing
|
|
14
|
+
* statement — can shadow a real table out from under someone else's DDL:
|
|
15
|
+
*
|
|
16
|
+
* - `cteNodes` → cleared, so `default (select count(*) from c)` keeps meaning the
|
|
17
|
+
* real table `c` even under `with c as (…) insert into t …`. Clearing on the
|
|
18
|
+
* CONTEXT is what closes it: `buildWithContext` seeds its map from `ctx.cteNodes`
|
|
19
|
+
* and prefers a non-empty explicit `parentCTEs` argument over it, so handing an
|
|
20
|
+
* empty map downstream is not sufficient.
|
|
21
|
+
* - `cteReferenceCache` → cleared for the same reason
|
|
22
|
+
* {@link import('../stored-body-context.js').storedBodyContext} clears it: the cache
|
|
23
|
+
* is keyed on bare `cteName:alias`, so a caller definition and one declared inside a
|
|
24
|
+
* `check` subquery's own `with` clause would collide on a single entry and the
|
|
25
|
+
* schema-authored SQL would read the caller's relation.
|
|
26
|
+
*
|
|
27
|
+
* And narrows the schema search path:
|
|
28
|
+
*
|
|
29
|
+
* - `schemaPath` → `[schemaName]` exactly, the owning schema ONLY with no fallback to
|
|
30
|
+
* the session default path. So `default (select count(*) from c)` on a `temp` table
|
|
31
|
+
* means `temp.c` whatever schema path the writing statement carries (the session
|
|
32
|
+
* `pragma schema_path`, or a per-statement `insert … with schema …`). This is the
|
|
33
|
+
* single place that decides it, for all four expression kinds — the constraint and
|
|
34
|
+
* foreign-key builders used to narrow themselves, which is exactly why a table's
|
|
35
|
+
* `check` and its column `default` could disagree about the same bare name. It is
|
|
36
|
+
* deliberately stricter than a stored view body's `Database._homeSchemaPath()` (home
|
|
37
|
+
* schema first, then the session default path): a schema-authored expression that
|
|
38
|
+
* names a relation in another schema must qualify it. See docs/schema.md.
|
|
39
|
+
*
|
|
40
|
+
* It deliberately does NOT touch:
|
|
41
|
+
*
|
|
42
|
+
* - `scope` — `buildWithContext` contributes CTE *definitions* only, never scope
|
|
43
|
+
* symbols, so the scope is not a leak channel. `building/update.ts` and
|
|
44
|
+
* `building/delete.ts` must keep their table scope for `new.` / `old.` resolution,
|
|
45
|
+
* so this is applied ON TOP of those contexts rather than instead of them.
|
|
46
|
+
* - `storedBodyOf` — these expressions are built INLINE in the caller's statement,
|
|
47
|
+
* not as a re-entered stored body. Setting it would wrongly make a
|
|
48
|
+
* {@link import('../../parser/ast.js').StoredBodyEnv} marker inert.
|
|
49
|
+
*
|
|
50
|
+
* Sibling of {@link import('../stored-body-context.js').storedBodyContext}, which does
|
|
51
|
+
* the same job for the other kind of stored, schema-authored SQL: view and
|
|
52
|
+
* materialized-view bodies. That one isolates the WHOLE naming environment (home
|
|
53
|
+
* schema path, stored-body marker) because a body is re-entered as its own plan; this
|
|
54
|
+
* one keeps the caller's scope because these expressions stay inline.
|
|
55
|
+
*
|
|
56
|
+
* NOTE: this helper covers every schema-authored expression that is BUILT — but two
|
|
57
|
+
* CHECK-enforcement paths re-prepare the constraint's own SQL text as a whole statement
|
|
58
|
+
* instead, so they never reach a planning context and pin the same `[schemaName]` path on
|
|
59
|
+
* the {@link import('../../core/statement.js').Statement} directly:
|
|
60
|
+
* `validateBackfillAgainstChecks` (`runtime/emit/alter-table.ts`, ADD COLUMN over existing
|
|
61
|
+
* rows) and `validateChecksOverExistingRows` (`schema/constraint-builder.ts`, maintained
|
|
62
|
+
* tables). Two spellings of one rule is tolerable at two sites; if a third appears, give
|
|
63
|
+
* the statement seam its own helper rather than a fourth copy.
|
|
64
|
+
*
|
|
65
|
+
* @param schemaName the owning table's schema name — REQUIRED, so no call site can
|
|
66
|
+
* silently inherit the writing statement's path.
|
|
67
|
+
*/
|
|
68
|
+
export declare function schemaAuthoredContext(ctx: PlanningContext, schemaName: string): PlanningContext;
|
|
69
|
+
//# sourceMappingURL=schema-authored-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-authored-context.d.ts","sourceRoot":"","sources":["../../../../src/planner/building/schema-authored-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,GAAG,eAAe,CAM/F"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The planning context any SCHEMA-AUTHORED expression must be built on — a column
|
|
3
|
+
* `DEFAULT`, a generated-column expression, a `CHECK` constraint, or a synthesized
|
|
4
|
+
* foreign-key probe. All four are written in the TABLE's definition, not in the
|
|
5
|
+
* statement doing the write, so their unqualified relation names must always mean
|
|
6
|
+
* real schema objects, and must mean the SAME ones no matter where the writing
|
|
7
|
+
* statement happens to be pointed. `schemaName` is the OWNING table's schema (for the
|
|
8
|
+
* anchor key default on a view write-through, the anchor BASE table's schema — not
|
|
9
|
+
* the view's).
|
|
10
|
+
*
|
|
11
|
+
* Clears the two CTE-related fields so no statement's common table expressions — the
|
|
12
|
+
* writing statement's own leading `with` clause, or ones it inherited from an enclosing
|
|
13
|
+
* statement — can shadow a real table out from under someone else's DDL:
|
|
14
|
+
*
|
|
15
|
+
* - `cteNodes` → cleared, so `default (select count(*) from c)` keeps meaning the
|
|
16
|
+
* real table `c` even under `with c as (…) insert into t …`. Clearing on the
|
|
17
|
+
* CONTEXT is what closes it: `buildWithContext` seeds its map from `ctx.cteNodes`
|
|
18
|
+
* and prefers a non-empty explicit `parentCTEs` argument over it, so handing an
|
|
19
|
+
* empty map downstream is not sufficient.
|
|
20
|
+
* - `cteReferenceCache` → cleared for the same reason
|
|
21
|
+
* {@link import('../stored-body-context.js').storedBodyContext} clears it: the cache
|
|
22
|
+
* is keyed on bare `cteName:alias`, so a caller definition and one declared inside a
|
|
23
|
+
* `check` subquery's own `with` clause would collide on a single entry and the
|
|
24
|
+
* schema-authored SQL would read the caller's relation.
|
|
25
|
+
*
|
|
26
|
+
* And narrows the schema search path:
|
|
27
|
+
*
|
|
28
|
+
* - `schemaPath` → `[schemaName]` exactly, the owning schema ONLY with no fallback to
|
|
29
|
+
* the session default path. So `default (select count(*) from c)` on a `temp` table
|
|
30
|
+
* means `temp.c` whatever schema path the writing statement carries (the session
|
|
31
|
+
* `pragma schema_path`, or a per-statement `insert … with schema …`). This is the
|
|
32
|
+
* single place that decides it, for all four expression kinds — the constraint and
|
|
33
|
+
* foreign-key builders used to narrow themselves, which is exactly why a table's
|
|
34
|
+
* `check` and its column `default` could disagree about the same bare name. It is
|
|
35
|
+
* deliberately stricter than a stored view body's `Database._homeSchemaPath()` (home
|
|
36
|
+
* schema first, then the session default path): a schema-authored expression that
|
|
37
|
+
* names a relation in another schema must qualify it. See docs/schema.md.
|
|
38
|
+
*
|
|
39
|
+
* It deliberately does NOT touch:
|
|
40
|
+
*
|
|
41
|
+
* - `scope` — `buildWithContext` contributes CTE *definitions* only, never scope
|
|
42
|
+
* symbols, so the scope is not a leak channel. `building/update.ts` and
|
|
43
|
+
* `building/delete.ts` must keep their table scope for `new.` / `old.` resolution,
|
|
44
|
+
* so this is applied ON TOP of those contexts rather than instead of them.
|
|
45
|
+
* - `storedBodyOf` — these expressions are built INLINE in the caller's statement,
|
|
46
|
+
* not as a re-entered stored body. Setting it would wrongly make a
|
|
47
|
+
* {@link import('../../parser/ast.js').StoredBodyEnv} marker inert.
|
|
48
|
+
*
|
|
49
|
+
* Sibling of {@link import('../stored-body-context.js').storedBodyContext}, which does
|
|
50
|
+
* the same job for the other kind of stored, schema-authored SQL: view and
|
|
51
|
+
* materialized-view bodies. That one isolates the WHOLE naming environment (home
|
|
52
|
+
* schema path, stored-body marker) because a body is re-entered as its own plan; this
|
|
53
|
+
* one keeps the caller's scope because these expressions stay inline.
|
|
54
|
+
*
|
|
55
|
+
* NOTE: this helper covers every schema-authored expression that is BUILT — but two
|
|
56
|
+
* CHECK-enforcement paths re-prepare the constraint's own SQL text as a whole statement
|
|
57
|
+
* instead, so they never reach a planning context and pin the same `[schemaName]` path on
|
|
58
|
+
* the {@link import('../../core/statement.js').Statement} directly:
|
|
59
|
+
* `validateBackfillAgainstChecks` (`runtime/emit/alter-table.ts`, ADD COLUMN over existing
|
|
60
|
+
* rows) and `validateChecksOverExistingRows` (`schema/constraint-builder.ts`, maintained
|
|
61
|
+
* tables). Two spellings of one rule is tolerable at two sites; if a third appears, give
|
|
62
|
+
* the statement seam its own helper rather than a fourth copy.
|
|
63
|
+
*
|
|
64
|
+
* @param schemaName the owning table's schema name — REQUIRED, so no call site can
|
|
65
|
+
* silently inherit the writing statement's path.
|
|
66
|
+
*/
|
|
67
|
+
export function schemaAuthoredContext(ctx, schemaName) {
|
|
68
|
+
// Identity fast-path only when nothing would actually change: the CTE namespace is
|
|
69
|
+
// already empty AND the path is already exactly the owning schema.
|
|
70
|
+
if (!ctx.cteNodes && !ctx.cteReferenceCache
|
|
71
|
+
&& ctx.schemaPath?.length === 1 && ctx.schemaPath[0] === schemaName)
|
|
72
|
+
return ctx;
|
|
73
|
+
return { ...ctx, cteNodes: undefined, cteReferenceCache: undefined, schemaPath: [schemaName] };
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=schema-authored-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-authored-context.js","sourceRoot":"","sources":["../../../../src/planner/building/schema-authored-context.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAoB,EAAE,UAAkB;IAC7E,mFAAmF;IACnF,mEAAmE;IACnE,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,iBAAiB;WACvC,GAAG,CAAC,UAAU,EAAE,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,UAAU;QAAE,OAAO,GAAG,CAAC;IACjF,OAAO,EAAE,GAAG,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC;AAChG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-resolution.d.ts","sourceRoot":"","sources":["../../../../src/planner/building/schema-resolution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAOlE,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAE5C,mEAAmE;AACnE,wBAAgB,oBAAoB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAEjE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,eAAe,EACpB,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,MAAM,GACjB,WAAW,
|
|
1
|
+
{"version":3,"file":"schema-resolution.d.ts","sourceRoot":"","sources":["../../../../src/planner/building/schema-resolution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAOlE,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAE5C,mEAAmE;AACnE,wBAAgB,oBAAoB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAEjE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,eAAe,EACpB,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,MAAM,GACjB,WAAW,CA+Fb;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,eAAe,EACpB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACb,cAAc,CAqChB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,eAAe,EACpB,UAAU,EAAE,MAAM,GAChB;IAAE,MAAM,EAAE,qBAAqB,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CA+BtD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC/B,GAAG,EAAE,eAAe,EACpB,aAAa,EAAE,MAAM,GACnB,iBAAiB,CAwBnB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { QuereusError } from '../../common/errors.js';
|
|
1
|
+
import { QuereusError, RelationNotFoundError } from '../../common/errors.js';
|
|
2
2
|
import { StatusCode } from '../../common/types.js';
|
|
3
3
|
import { createLogger } from '../../common/logger.js';
|
|
4
4
|
const log = createLogger('planner:schema-resolution');
|
|
@@ -29,7 +29,8 @@ export function resolveTableSchema(ctx, tableName, schemaName) {
|
|
|
29
29
|
// Resolve table schema with explicit schema name
|
|
30
30
|
const tableSchema = ctx.schemaManager.findTable(tableName, resolvedSchemaName);
|
|
31
31
|
if (!tableSchema) {
|
|
32
|
-
|
|
32
|
+
// Message text is asserted on by the sqllogic suites — keep it byte-identical.
|
|
33
|
+
throw new RelationNotFoundError(`Table not found: ${resolvedSchemaName}.${tableName}`);
|
|
33
34
|
}
|
|
34
35
|
// Record dependency
|
|
35
36
|
const dependency = {
|
|
@@ -60,7 +61,9 @@ export function resolveTableSchema(ctx, tableName, schemaName) {
|
|
|
60
61
|
if (!tableSchema) {
|
|
61
62
|
// Generate helpful error message
|
|
62
63
|
const searchedSchemas = schemaPath || ['main', 'temp'];
|
|
63
|
-
|
|
64
|
+
// Views count here: an unqualified name resolves through the path across
|
|
65
|
+
// tables and views alike, so an off-path VIEW is exactly as suggestible.
|
|
66
|
+
const existsIn = ctx.schemaManager.findSchemasContainingRelation(tableName);
|
|
64
67
|
let errorMsg = `Table '${tableName}' not found in schema path: ${searchedSchemas.join(', ')}`;
|
|
65
68
|
if (existsIn.length > 0) {
|
|
66
69
|
// Table exists in other schemas - suggest qualified name
|
|
@@ -74,7 +77,7 @@ export function resolveTableSchema(ctx, tableName, schemaName) {
|
|
|
74
77
|
errorMsg += `\n Or add '${existsIn[0]}' to your WITH SCHEMA clause`;
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
|
-
throw new
|
|
80
|
+
throw new RelationNotFoundError(errorMsg);
|
|
78
81
|
}
|
|
79
82
|
// Record dependency
|
|
80
83
|
const dependency = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-resolution.js","sourceRoot":"","sources":["../../../../src/planner/building/schema-resolution.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"schema-resolution.js","sourceRoot":"","sources":["../../../../src/planner/building/schema-resolution.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,GAAG,GAAG,YAAY,CAAC,2BAA2B,CAAC,CAAC;AAEtD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW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AAC,kBAAkB,CAAC,gBAAgB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IAE/D,eAAe;IACf,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAEzC,GAAG,CAAC,wBAAwB,EAAE,aAAa,CAAC,CAAC;IAC7C,OAAO,SAAS,CAAC;AAClB,CAAC"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import type * as AST from '../../parser/ast.js';
|
|
2
|
-
import { type RelationalPlanNode, type ScalarPlanNode } from '../nodes/plan-node.js';
|
|
2
|
+
import { type Attribute, type PlanNode, type RelationalPlanNode, type ScalarPlanNode } from '../nodes/plan-node.js';
|
|
3
3
|
import type { PlanningContext } from '../planning-context.js';
|
|
4
4
|
import { type Projection } from '../nodes/project-node.js';
|
|
5
5
|
import { RegisteredScope } from '../scopes/registered.js';
|
|
6
|
+
import type { Scope } from '../scopes/scope.js';
|
|
7
|
+
import { type SelectListEntry } from './select-ordinal.js';
|
|
6
8
|
/**
|
|
7
9
|
* Processes GROUP BY, aggregates, and HAVING clauses
|
|
8
10
|
*/
|
|
9
11
|
export declare function buildAggregatePhase(input: RelationalPlanNode, stmt: AST.SelectStmt, selectContext: PlanningContext, aggregates: {
|
|
10
12
|
expression: ScalarPlanNode;
|
|
11
13
|
alias: string;
|
|
12
|
-
}[], hasAggregates: boolean, projections: Projection[], hasWrappedAggregates?: boolean,
|
|
14
|
+
}[], hasAggregates: boolean, projections: Projection[], hasWrappedAggregates?: boolean, selectList?: readonly SelectListEntry[], starProjectionsByColumn?: ReadonlyMap<AST.ResultColumn, readonly Projection[]>): {
|
|
13
15
|
output: RelationalPlanNode;
|
|
14
16
|
aggregateScope?: RegisteredScope;
|
|
15
17
|
needsFinalProjection: boolean;
|
|
@@ -21,6 +23,189 @@ export declare function buildAggregatePhase(input: RelationalPlanNode, stmt: AST
|
|
|
21
23
|
orderByHasAggregates?: boolean;
|
|
22
24
|
aggregatesContext?: PlanningContext['aggregates'];
|
|
23
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* What a grouped query's rows are allowed to expose: the attribute ids reachable
|
|
28
|
+
* after aggregation, plus the canonical AST strings of the GROUP BY expressions
|
|
29
|
+
* themselves.
|
|
30
|
+
*
|
|
31
|
+
* Two flavours of attribute id are legal, and both matter depending on where the
|
|
32
|
+
* expression being checked was built. An expression built against the
|
|
33
|
+
* *pre-aggregate* scope (the SELECT list, before the final projection) names base
|
|
34
|
+
* source attributes, so the ids of the GROUP BY key expressions cover it. A HAVING
|
|
35
|
+
* predicate resolves through a hybrid scope and may name either the AggregateNode's
|
|
36
|
+
* own output attributes or, via the source-column fallback, base ones — so the
|
|
37
|
+
* output ids must be admitted too, passed in `groupedOutputAttributes`.
|
|
38
|
+
*
|
|
39
|
+
* The window phase of a grouped query has its own check
|
|
40
|
+
* ({@link assertGroupedWindowCoverage}); it needs to descend into subqueries and to
|
|
41
|
+
* tell a correlated reference from an ungrouped local one, neither of which this
|
|
42
|
+
* coverage set can express.
|
|
43
|
+
*
|
|
44
|
+
* The fingerprint set covers whole grouped subtrees (`select id+1 … group by
|
|
45
|
+
* id+1`) and, incidentally, the qualifier mismatch between `group by t.a` and a
|
|
46
|
+
* later bare `a`. Fingerprints fold identifier case (see
|
|
47
|
+
* {@link expressionToIdentityString}), so `group by A || '!'` covers a later
|
|
48
|
+
* `a || '!'`; quoted literals stay byte-exact, so `a || 'X'` does not.
|
|
49
|
+
*/
|
|
50
|
+
export interface GroupByCoverage {
|
|
51
|
+
readonly attrIds: ReadonlySet<number>;
|
|
52
|
+
readonly fingerprints: ReadonlySet<string>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Builds the coverage test for a grouped query. `groupedOutputAttributes` is the
|
|
56
|
+
* AggregateNode's output attributes (group keys followed by aggregate results),
|
|
57
|
+
* needed only when the expressions to be checked were built against the aggregate
|
|
58
|
+
* output scope.
|
|
59
|
+
*/
|
|
60
|
+
export declare function buildGroupByCoverage(groupByExpressions: readonly ScalarPlanNode[], groupedOutputAttributes?: readonly Attribute[]): GroupByCoverage;
|
|
61
|
+
/**
|
|
62
|
+
* Raises the standard GROUP BY coverage error when `node` reads a column the
|
|
63
|
+
* grouped rows do not carry. Used by the SELECT-list check below; the window
|
|
64
|
+
* phase raises the same message from {@link assertGroupedWindowCoverage}.
|
|
65
|
+
*/
|
|
66
|
+
export declare function assertGroupByCoverage(node: PlanNode, coverage: GroupByCoverage): void;
|
|
67
|
+
/**
|
|
68
|
+
* What the window phase of a GROUPED query needs in order to run its window
|
|
69
|
+
* specifications and function arguments over the AggregateNode's own rows.
|
|
70
|
+
*
|
|
71
|
+
* The WindowNode sits ABOVE the AggregateNode, so it can read only what the
|
|
72
|
+
* aggregate's output row carries: the grouping keys and the aggregate results.
|
|
73
|
+
* But the scope those expressions are built against falls through to the
|
|
74
|
+
* pre-aggregate select scope, so several perfectly legal spellings of a grouping
|
|
75
|
+
* key (`wg.a` against `group by a`, or the whole `a || '!'` against `group by a
|
|
76
|
+
* || '!'`) bind to a *base-table* attribute the aggregate row never had. This
|
|
77
|
+
* context supplies both halves of the answer: the two maps let
|
|
78
|
+
* {@link redirectToGroupKeys} rewrite such a subtree onto the aggregate's own
|
|
79
|
+
* output column, and the two attribute-id sets let
|
|
80
|
+
* {@link assertGroupedWindowCoverage} reject what survives.
|
|
81
|
+
*/
|
|
82
|
+
export interface GroupedWindowContext {
|
|
83
|
+
/** Where each GROUP BY key lives on the AggregateNode's output row. */
|
|
84
|
+
readonly groupKeys: GroupKeyIndex;
|
|
85
|
+
/** AggregateNode output attributes: group keys in GROUP BY order, then aggregate results. */
|
|
86
|
+
readonly outputAttributes: readonly Attribute[];
|
|
87
|
+
/**
|
|
88
|
+
* Every attribute id the AggregateNode's input subtree produces and this query can
|
|
89
|
+
* name — exactly "the columns this grouped query could have read before it grouped".
|
|
90
|
+
* CTE definition bodies are excluded; see {@link isCteDefinition}.
|
|
91
|
+
*
|
|
92
|
+
* This is what tells a reference belonging to THIS query apart from one that does
|
|
93
|
+
* not, at any nesting depth. A window specification may contain a subquery, and
|
|
94
|
+
* inside it live two unrelated kinds of column reference: the subquery's own
|
|
95
|
+
* columns and correlated references pointing back out. Attribute ids are minted
|
|
96
|
+
* per relation instance, so a subquery's own `wg t` scan and the outer `wg` scan
|
|
97
|
+
* never share one — membership here separates them exactly. A reference NOT in
|
|
98
|
+
* this set is the subquery's own column or a reference to an ENCLOSING query, and
|
|
99
|
+
* is none of the window phase's business either way.
|
|
100
|
+
*/
|
|
101
|
+
readonly aggregateInputAttrIds: ReadonlySet<number>;
|
|
102
|
+
/**
|
|
103
|
+
* Legal AFTER redirection: AggregateNode output attribute ids ONLY. Once
|
|
104
|
+
* {@link redirectToGroupKeys} has run, an aggregate-input attribute id still
|
|
105
|
+
* present anywhere in a window expression is an ungrouped reference.
|
|
106
|
+
*/
|
|
107
|
+
readonly outputAttrIds: ReadonlySet<number>;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Locates each GROUP BY key on the AggregateNode's output row, under both spellings a
|
|
111
|
+
* later expression may reach it by: the whole grouped expression written out again, or
|
|
112
|
+
* (for a bare-column key) the base column under any qualifier.
|
|
113
|
+
*
|
|
114
|
+
* Shared by the window phase's {@link redirectToGroupKeys} and by the select list's
|
|
115
|
+
* {@link buildFinalAggregateProjections}, which resolve the same question about
|
|
116
|
+
* different expressions.
|
|
117
|
+
*/
|
|
118
|
+
export interface GroupKeyIndex {
|
|
119
|
+
/** Identity fingerprint of each GROUP BY expression → its output column index. */
|
|
120
|
+
readonly byFingerprint: ReadonlyMap<string, number>;
|
|
121
|
+
/** Base attribute id of each bare-column GROUP BY key → its output column index. */
|
|
122
|
+
readonly byBaseAttrId: ReadonlyMap<number, number>;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Builds the {@link GroupKeyIndex} for a grouped query's GROUP BY list. The output
|
|
126
|
+
* column index is the key's position in that list, which is its position on the
|
|
127
|
+
* AggregateNode's output row.
|
|
128
|
+
*/
|
|
129
|
+
export declare function indexGroupKeys(groupByExpressions: readonly ScalarPlanNode[]): GroupKeyIndex;
|
|
130
|
+
/**
|
|
131
|
+
* Builds the {@link GroupedWindowContext} for a grouped, windowed query.
|
|
132
|
+
* `outputAttributes` is the AggregateNode's attribute list (group keys in GROUP BY
|
|
133
|
+
* order, then the aggregate results); `aggregateInput` is the AggregateNode's
|
|
134
|
+
* source relation, whose whole subtree defines
|
|
135
|
+
* {@link GroupedWindowContext.aggregateInputAttrIds}.
|
|
136
|
+
*/
|
|
137
|
+
export declare function buildGroupedWindowContext(groupByExpressions: readonly ScalarPlanNode[], outputAttributes: readonly Attribute[], aggregateInput: PlanNode): GroupedWindowContext;
|
|
138
|
+
/**
|
|
139
|
+
* Rewrites every subtree of a window specification / window-function argument that
|
|
140
|
+
* IS a grouping key into a reference to the AggregateNode's output column for that
|
|
141
|
+
* key, so the expression reads the grouped row instead of a base-table column that
|
|
142
|
+
* row does not carry.
|
|
143
|
+
*
|
|
144
|
+
* Two match rules, in order at each node:
|
|
145
|
+
*
|
|
146
|
+
* 1. The whole subtree's identity fingerprint equals a GROUP BY expression's — covers
|
|
147
|
+
* `group by a || '!'` + `over (order by a || '!')`, and nested occurrences such
|
|
148
|
+
* as `over (order by upper(a || '!'))` because the walk recurses. Identifier case
|
|
149
|
+
* is folded, so `group by A || '!'` matches too; quoted literals are byte-exact,
|
|
150
|
+
* so `a || 'X'` and `a || 'x'` remain different keys.
|
|
151
|
+
*
|
|
152
|
+
* Unconditional above any subquery, where the expression is written in this query's
|
|
153
|
+
* own scope. INSIDE a subquery it is guarded by {@link readsOnlyAggregateInput} —
|
|
154
|
+
* every column reference in the subtree must be a pre-grouping column of THIS query
|
|
155
|
+
* — because there the same text can name something else entirely: under `group by
|
|
156
|
+
* a`, a bare `a` written inside `over (order by (select … where t.a = a))` names the
|
|
157
|
+
* subquery's own `t.a` and yet fingerprints as `a`, so an unguarded rule 1 would
|
|
158
|
+
* silently rewrite it into the outer group column and change what the query means.
|
|
159
|
+
* The guard cannot replace the top-level case: `group by (select max(t.b) from wg t
|
|
160
|
+
* where t.a = wg.a)` repeated verbatim in the specification is a legal grouping key
|
|
161
|
+
* whose subtree also reads the subquery's own columns.
|
|
162
|
+
* 2. The node is a column reference whose attribute id is the *base* attribute id of
|
|
163
|
+
* a bare-column grouping key — covers `group by a` + `over (order by wg.a)` and
|
|
164
|
+
* `over (order by w.a)`. Both spellings fall through to the same base attribute
|
|
165
|
+
* the group key was built from, so the match is qualifier-independent. It needs no
|
|
166
|
+
* guard at any depth: attribute ids are minted per relation instance, so only a
|
|
167
|
+
* reference that genuinely resolves to this query's grouping column can match.
|
|
168
|
+
*
|
|
169
|
+
* Otherwise recurse into every child, relational ones included, rebuilding through
|
|
170
|
+
* `withChildren` — a correlated reference to a grouping key can live arbitrarily deep
|
|
171
|
+
* inside a subquery in the window specification, and it must be redirected there too
|
|
172
|
+
* or it reaches the runtime as a base-table attribute the grouped row never carried.
|
|
173
|
+
*
|
|
174
|
+
* NOTE: rule 1 matches by AST text, so a subtree that *reads* like a grouping key but
|
|
175
|
+
* resolves to something else could be redirected wrongly. Within one query the guard
|
|
176
|
+
* above closes that off; the residue is a subtree of ENCLOSING-query references that
|
|
177
|
+
* happens to spell a grouping key (`group by a` in an inner query whose window spec
|
|
178
|
+
* says `outer_alias.a`… only when that fingerprints identically). This is the same
|
|
179
|
+
* limitation the select list already carries through the shared {@link GroupKeyIndex};
|
|
180
|
+
* fixing it means comparing resolved attribute identity rather than text, for both
|
|
181
|
+
* callers at once.
|
|
182
|
+
*/
|
|
183
|
+
export declare function redirectToGroupKeys(node: ScalarPlanNode, context: GroupedWindowContext, scope: Scope): ScalarPlanNode;
|
|
184
|
+
/**
|
|
185
|
+
* Raises the GROUP BY coverage error for a window specification / window-function
|
|
186
|
+
* argument of a GROUPED query that still reads a pre-grouping column after
|
|
187
|
+
* {@link redirectToGroupKeys} has run.
|
|
188
|
+
*
|
|
189
|
+
* Distinct from {@link assertGroupByCoverage} in exactly two ways, both required by
|
|
190
|
+
* the fact that a window expression may contain a subquery:
|
|
191
|
+
*
|
|
192
|
+
* - it descends into relational children, so a correlated reference buried in a
|
|
193
|
+
* subquery is checked rather than skipped;
|
|
194
|
+
* - it flags a column reference only when the attribute id is one of THIS query's
|
|
195
|
+
* pre-grouping columns. A reference to anything else — the subquery's own columns,
|
|
196
|
+
* or a correlated reference to an enclosing query — is legal here and is left alone.
|
|
197
|
+
*
|
|
198
|
+
* The aggregate exemption is likewise narrowed to this query's OWN aggregates; see
|
|
199
|
+
* {@link findUngroupedWindowColumnRef}.
|
|
200
|
+
*/
|
|
201
|
+
export declare function assertGroupedWindowCoverage(node: PlanNode, context: GroupedWindowContext): void;
|
|
202
|
+
/**
|
|
203
|
+
* Every aggregate function call inside an AST expression, in source order.
|
|
204
|
+
* Does not descend into an aggregate's own arguments (nested aggregates are
|
|
205
|
+
* invalid SQL). Exported for callers that need to *inspect* the aggregates in a
|
|
206
|
+
* clause rather than collect them into the AggregateNode.
|
|
207
|
+
*/
|
|
208
|
+
export declare function collectAggregateFunctionExprs(expr: AST.Expression, ctx: PlanningContext): AST.FunctionExpr[];
|
|
24
209
|
/**
|
|
25
210
|
* Builds final projections for the complete SELECT list in aggregate context
|
|
26
211
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-aggregates.d.ts","sourceRoot":"","sources":["../../../../src/planner/building/select-aggregates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAChD,OAAO,
|
|
1
|
+
{"version":3,"file":"select-aggregates.d.ts","sourceRoot":"","sources":["../../../../src/planner/building/select-aggregates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAoB,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,kBAAkB,EAAE,KAAK,cAAc,EAAE,MAAM,u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