@quereus/quereus 4.11.0 → 4.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/common/type-inference.d.ts +12 -6
- package/dist/src/common/type-inference.d.ts.map +1 -1
- package/dist/src/common/type-inference.js +12 -24
- package/dist/src/common/type-inference.js.map +1 -1
- package/dist/src/core/database-assertions.d.ts.map +1 -1
- package/dist/src/core/database-assertions.js +7 -5
- package/dist/src/core/database-assertions.js.map +1 -1
- package/dist/src/core/database-events.d.ts +4 -3
- package/dist/src/core/database-events.d.ts.map +1 -1
- package/dist/src/core/database-events.js +4 -3
- package/dist/src/core/database-events.js.map +1 -1
- package/dist/src/core/database-materialized-views-analysis.d.ts +1 -3
- package/dist/src/core/database-materialized-views-analysis.d.ts.map +1 -1
- package/dist/src/core/database-materialized-views-analysis.js +1 -11
- package/dist/src/core/database-materialized-views-analysis.js.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 +12 -10
- package/dist/src/core/database-materialized-views-plan-builders.js.map +1 -1
- package/dist/src/core/database.d.ts.map +1 -1
- package/dist/src/core/database.js +13 -2
- 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 +14 -2
- package/dist/src/core/derived-row-validator.js.map +1 -1
- package/dist/src/core/param.d.ts +9 -0
- package/dist/src/core/param.d.ts.map +1 -1
- package/dist/src/core/param.js +21 -1
- package/dist/src/core/param.js.map +1 -1
- package/dist/src/core/statement.d.ts.map +1 -1
- package/dist/src/core/statement.js +38 -15
- package/dist/src/core/statement.js.map +1 -1
- package/dist/src/func/builtins/aggregate.d.ts.map +1 -1
- package/dist/src/func/builtins/aggregate.js +7 -2
- 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 +27 -11
- package/dist/src/func/builtins/builtin-window-functions.js.map +1 -1
- package/dist/src/func/builtins/datetime.d.ts.map +1 -1
- package/dist/src/func/builtins/datetime.js +8 -3
- 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 +9 -29
- package/dist/src/func/builtins/explain.js.map +1 -1
- package/dist/src/func/builtins/json-tvf.d.ts.map +1 -1
- package/dist/src/func/builtins/json-tvf.js +14 -7
- package/dist/src/func/builtins/json-tvf.js.map +1 -1
- package/dist/src/func/builtins/return-types.d.ts +29 -0
- package/dist/src/func/builtins/return-types.d.ts.map +1 -1
- package/dist/src/func/builtins/return-types.js +4 -1
- package/dist/src/func/builtins/return-types.js.map +1 -1
- package/dist/src/func/builtins/scalar.d.ts.map +1 -1
- package/dist/src/func/builtins/scalar.js +22 -67
- 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 +26 -16
- package/dist/src/func/builtins/schema.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/parser/parser.d.ts.map +1 -1
- package/dist/src/parser/parser.js +8 -5
- package/dist/src/parser/parser.js.map +1 -1
- package/dist/src/parser/visitor.d.ts +16 -0
- package/dist/src/parser/visitor.d.ts.map +1 -1
- package/dist/src/parser/visitor.js +16 -0
- package/dist/src/parser/visitor.js.map +1 -1
- package/dist/src/planner/analysis/assertion-plan.d.ts +33 -0
- package/dist/src/planner/analysis/assertion-plan.d.ts.map +1 -0
- package/dist/src/planner/analysis/assertion-plan.js +39 -0
- package/dist/src/planner/analysis/assertion-plan.js.map +1 -0
- package/dist/src/planner/analysis/binary-operator-class.d.ts +55 -0
- package/dist/src/planner/analysis/binary-operator-class.d.ts.map +1 -0
- package/dist/src/planner/analysis/binary-operator-class.js +57 -0
- package/dist/src/planner/analysis/binary-operator-class.js.map +1 -0
- package/dist/src/planner/analysis/binding-extractor.d.ts +9 -3
- package/dist/src/planner/analysis/binding-extractor.d.ts.map +1 -1
- package/dist/src/planner/analysis/binding-extractor.js +11 -16
- package/dist/src/planner/analysis/binding-extractor.js.map +1 -1
- package/dist/src/planner/analysis/change-scope.d.ts.map +1 -1
- package/dist/src/planner/analysis/change-scope.js +19 -6
- package/dist/src/planner/analysis/change-scope.js.map +1 -1
- package/dist/src/planner/analysis/check-extraction.d.ts +1 -7
- package/dist/src/planner/analysis/check-extraction.d.ts.map +1 -1
- package/dist/src/planner/analysis/check-extraction.js.map +1 -1
- package/dist/src/planner/analysis/comparison-collation.d.ts +17 -0
- package/dist/src/planner/analysis/comparison-collation.d.ts.map +1 -1
- package/dist/src/planner/analysis/comparison-collation.js +17 -5
- package/dist/src/planner/analysis/comparison-collation.js.map +1 -1
- package/dist/src/planner/analysis/constraint-extractor.d.ts.map +1 -1
- package/dist/src/planner/analysis/constraint-extractor.js +18 -18
- package/dist/src/planner/analysis/constraint-extractor.js.map +1 -1
- package/dist/src/planner/analysis/coverage-prover.d.ts +11 -7
- package/dist/src/planner/analysis/coverage-prover.d.ts.map +1 -1
- package/dist/src/planner/analysis/coverage-prover.js +11 -7
- package/dist/src/planner/analysis/coverage-prover.js.map +1 -1
- package/dist/src/planner/analysis/equi-correlation.d.ts +1 -1
- package/dist/src/planner/analysis/equi-correlation.js +1 -1
- package/dist/src/planner/analysis/expression-fingerprint.d.ts.map +1 -1
- package/dist/src/planner/analysis/expression-fingerprint.js +0 -2
- package/dist/src/planner/analysis/expression-fingerprint.js.map +1 -1
- package/dist/src/planner/analysis/key-filter.d.ts.map +1 -1
- package/dist/src/planner/analysis/key-filter.js +2 -3
- package/dist/src/planner/analysis/key-filter.js.map +1 -1
- package/dist/src/planner/analysis/relation-key.d.ts +104 -0
- package/dist/src/planner/analysis/relation-key.d.ts.map +1 -0
- package/dist/src/planner/analysis/relation-key.js +121 -0
- package/dist/src/planner/analysis/relation-key.js.map +1 -0
- package/dist/src/planner/analysis/scalar-param-usage.d.ts.map +1 -1
- package/dist/src/planner/analysis/scalar-param-usage.js +12 -4
- package/dist/src/planner/analysis/scalar-param-usage.js.map +1 -1
- package/dist/src/planner/analysis/set-op-type-merge.d.ts +9 -3
- package/dist/src/planner/analysis/set-op-type-merge.d.ts.map +1 -1
- package/dist/src/planner/analysis/set-op-type-merge.js +22 -8
- package/dist/src/planner/analysis/set-op-type-merge.js.map +1 -1
- package/dist/src/planner/building/alter-table.d.ts.map +1 -1
- package/dist/src/planner/building/alter-table.js +31 -23
- package/dist/src/planner/building/alter-table.js.map +1 -1
- package/dist/src/planner/building/analyze.d.ts.map +1 -1
- package/dist/src/planner/building/analyze.js +21 -0
- package/dist/src/planner/building/analyze.js.map +1 -1
- package/dist/src/planner/building/block.d.ts.map +1 -1
- package/dist/src/planner/building/block.js +222 -82
- package/dist/src/planner/building/block.js.map +1 -1
- package/dist/src/planner/building/constraint-builder.d.ts.map +1 -1
- package/dist/src/planner/building/constraint-builder.js +5 -3
- package/dist/src/planner/building/constraint-builder.js.map +1 -1
- package/dist/src/planner/building/delete.js +1 -1
- package/dist/src/planner/building/delete.js.map +1 -1
- package/dist/src/planner/building/expression.d.ts.map +1 -1
- package/dist/src/planner/building/expression.js +11 -3
- package/dist/src/planner/building/expression.js.map +1 -1
- package/dist/src/planner/building/foreign-key-builder.d.ts +16 -6
- package/dist/src/planner/building/foreign-key-builder.d.ts.map +1 -1
- package/dist/src/planner/building/foreign-key-builder.js +43 -20
- package/dist/src/planner/building/foreign-key-builder.js.map +1 -1
- package/dist/src/planner/building/generated-column-scope.d.ts +58 -0
- package/dist/src/planner/building/generated-column-scope.d.ts.map +1 -0
- package/dist/src/planner/building/generated-column-scope.js +117 -0
- package/dist/src/planner/building/generated-column-scope.js.map +1 -0
- package/dist/src/planner/building/insert.d.ts.map +1 -1
- package/dist/src/planner/building/insert.js +20 -28
- package/dist/src/planner/building/insert.js.map +1 -1
- package/dist/src/planner/building/select-aggregates.d.ts +73 -132
- package/dist/src/planner/building/select-aggregates.d.ts.map +1 -1
- package/dist/src/planner/building/select-aggregates.js +405 -81
- package/dist/src/planner/building/select-aggregates.js.map +1 -1
- package/dist/src/planner/building/select-modifiers.d.ts +37 -8
- package/dist/src/planner/building/select-modifiers.d.ts.map +1 -1
- package/dist/src/planner/building/select-modifiers.js +8 -9
- package/dist/src/planner/building/select-modifiers.js.map +1 -1
- package/dist/src/planner/building/select-ordinal.d.ts +6 -0
- package/dist/src/planner/building/select-ordinal.d.ts.map +1 -1
- package/dist/src/planner/building/select-ordinal.js +1 -1
- package/dist/src/planner/building/select-ordinal.js.map +1 -1
- package/dist/src/planner/building/select-window.d.ts +2 -2
- package/dist/src/planner/building/select-window.d.ts.map +1 -1
- package/dist/src/planner/building/select-window.js +82 -101
- 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 +78 -33
- 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 +14 -8
- package/dist/src/planner/building/update.js.map +1 -1
- package/dist/src/planner/building/view-mutation-builder.d.ts.map +1 -1
- package/dist/src/planner/building/view-mutation-builder.js +329 -14
- package/dist/src/planner/building/view-mutation-builder.js.map +1 -1
- package/dist/src/planner/building/with.d.ts +6 -0
- package/dist/src/planner/building/with.d.ts.map +1 -1
- package/dist/src/planner/building/with.js +52 -3
- package/dist/src/planner/building/with.js.map +1 -1
- package/dist/src/planner/cache/correlation-detector.d.ts.map +1 -1
- package/dist/src/planner/cache/correlation-detector.js +44 -17
- package/dist/src/planner/cache/correlation-detector.js.map +1 -1
- package/dist/src/planner/framework/physical-utils.d.ts +6 -0
- package/dist/src/planner/framework/physical-utils.d.ts.map +1 -1
- package/dist/src/planner/framework/physical-utils.js +6 -0
- package/dist/src/planner/framework/physical-utils.js.map +1 -1
- package/dist/src/planner/mutation/lens-enforcement.d.ts +123 -0
- package/dist/src/planner/mutation/lens-enforcement.d.ts.map +1 -1
- package/dist/src/planner/mutation/lens-enforcement.js +362 -5
- package/dist/src/planner/mutation/lens-enforcement.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/nodes/alter-table-node.d.ts +15 -11
- package/dist/src/planner/nodes/alter-table-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/alter-table-node.js +5 -0
- package/dist/src/planner/nodes/alter-table-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 +7 -0
- package/dist/src/planner/nodes/bloom-join-node.js.map +1 -1
- package/dist/src/planner/nodes/constraint-check-node.d.ts +16 -0
- package/dist/src/planner/nodes/constraint-check-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/constraint-check-node.js.map +1 -1
- package/dist/src/planner/nodes/plan-node-type.d.ts +1 -1
- package/dist/src/planner/nodes/plan-node-type.d.ts.map +1 -1
- package/dist/src/planner/nodes/plan-node-type.js +1 -1
- package/dist/src/planner/nodes/plan-node-type.js.map +1 -1
- package/dist/src/planner/nodes/pragma.d.ts.map +1 -1
- package/dist/src/planner/nodes/pragma.js +5 -2
- package/dist/src/planner/nodes/pragma.js.map +1 -1
- package/dist/src/planner/nodes/reference.d.ts.map +1 -1
- package/dist/src/planner/nodes/reference.js +9 -1
- package/dist/src/planner/nodes/reference.js.map +1 -1
- package/dist/src/planner/nodes/scalar.d.ts.map +1 -1
- package/dist/src/planner/nodes/scalar.js +117 -91
- package/dist/src/planner/nodes/scalar.js.map +1 -1
- package/dist/src/planner/nodes/sequence-node.d.ts +50 -0
- package/dist/src/planner/nodes/sequence-node.d.ts.map +1 -0
- package/dist/src/planner/nodes/sequence-node.js +96 -0
- package/dist/src/planner/nodes/sequence-node.js.map +1 -0
- package/dist/src/planner/nodes/values-node.d.ts +8 -0
- package/dist/src/planner/nodes/values-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/values-node.js +29 -6
- package/dist/src/planner/nodes/values-node.js.map +1 -1
- package/dist/src/planner/nodes/view-mutation-node.d.ts +43 -1
- package/dist/src/planner/nodes/view-mutation-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/view-mutation-node.js +27 -6
- package/dist/src/planner/nodes/view-mutation-node.js.map +1 -1
- package/dist/src/planner/nodes/window-node.d.ts +33 -4
- package/dist/src/planner/nodes/window-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/window-node.js +80 -36
- package/dist/src/planner/nodes/window-node.js.map +1 -1
- package/dist/src/planner/planning-context.d.ts +38 -1
- package/dist/src/planner/planning-context.d.ts.map +1 -1
- 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 +8 -3
- package/dist/src/planner/rules/access/rule-key-set-seek.js.map +1 -1
- package/dist/src/planner/rules/join/rule-fanout-lookup-join.js +18 -12
- package/dist/src/planner/rules/join/rule-fanout-lookup-join.js.map +1 -1
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js +4 -3
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js.map +1 -1
- package/dist/src/planner/rules/window/rule-monotonic-window.d.ts.map +1 -1
- package/dist/src/planner/rules/window/rule-monotonic-window.js +6 -0
- package/dist/src/planner/rules/window/rule-monotonic-window.js.map +1 -1
- package/dist/src/planner/scopes/param.d.ts.map +1 -1
- package/dist/src/planner/scopes/param.js +10 -5
- package/dist/src/planner/scopes/param.js.map +1 -1
- package/dist/src/planner/util/ind-utils.d.ts +25 -8
- package/dist/src/planner/util/ind-utils.d.ts.map +1 -1
- package/dist/src/planner/util/ind-utils.js +53 -10
- package/dist/src/planner/util/ind-utils.js.map +1 -1
- package/dist/src/planner/util/key-utils.d.ts +7 -7
- package/dist/src/planner/util/key-utils.js +9 -9
- package/dist/src/planner/util/key-utils.js.map +1 -1
- package/dist/src/runtime/delta-executor.d.ts.map +1 -1
- package/dist/src/runtime/delta-executor.js +7 -2
- package/dist/src/runtime/delta-executor.js.map +1 -1
- package/dist/src/runtime/emit/add-constraint.d.ts.map +1 -1
- package/dist/src/runtime/emit/add-constraint.js +50 -15
- package/dist/src/runtime/emit/add-constraint.js.map +1 -1
- package/dist/src/runtime/emit/alter-schema-event.d.ts +2 -43
- package/dist/src/runtime/emit/alter-schema-event.d.ts.map +1 -1
- package/dist/src/runtime/emit/alter-schema-event.js +2 -53
- 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 +59 -24
- 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 +7 -0
- package/dist/src/runtime/emit/analyze.js.map +1 -1
- package/dist/src/runtime/emit/assertion-rename-helpers.d.ts.map +1 -1
- package/dist/src/runtime/emit/assertion-rename-helpers.js +2 -3
- package/dist/src/runtime/emit/assertion-rename-helpers.js.map +1 -1
- package/dist/src/runtime/emit/binary.d.ts +5 -0
- package/dist/src/runtime/emit/binary.d.ts.map +1 -1
- package/dist/src/runtime/emit/binary.js +22 -22
- package/dist/src/runtime/emit/binary.js.map +1 -1
- package/dist/src/runtime/emit/block.d.ts.map +1 -1
- package/dist/src/runtime/emit/block.js +9 -3
- package/dist/src/runtime/emit/block.js.map +1 -1
- package/dist/src/runtime/emit/constraint-check.d.ts.map +1 -1
- package/dist/src/runtime/emit/constraint-check.js +5 -6
- 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 +71 -70
- package/dist/src/runtime/emit/create-assertion.js.map +1 -1
- package/dist/src/runtime/emit/create-index.d.ts.map +1 -1
- package/dist/src/runtime/emit/create-index.js +8 -3
- package/dist/src/runtime/emit/create-index.js.map +1 -1
- package/dist/src/runtime/emit/create-table.d.ts.map +1 -1
- package/dist/src/runtime/emit/create-table.js +20 -10
- package/dist/src/runtime/emit/create-table.js.map +1 -1
- package/dist/src/runtime/emit/create-view.d.ts.map +1 -1
- package/dist/src/runtime/emit/create-view.js +51 -44
- package/dist/src/runtime/emit/create-view.js.map +1 -1
- package/dist/src/runtime/emit/ddl-event-scope.d.ts +71 -0
- package/dist/src/runtime/emit/ddl-event-scope.d.ts.map +1 -0
- package/dist/src/runtime/emit/ddl-event-scope.js +80 -0
- package/dist/src/runtime/emit/ddl-event-scope.js.map +1 -0
- package/dist/src/runtime/emit/dml-executor.d.ts.map +1 -1
- package/dist/src/runtime/emit/dml-executor.js +23 -23
- package/dist/src/runtime/emit/dml-executor.js.map +1 -1
- package/dist/src/runtime/emit/drop-assertion.d.ts.map +1 -1
- package/dist/src/runtime/emit/drop-assertion.js +23 -17
- package/dist/src/runtime/emit/drop-assertion.js.map +1 -1
- package/dist/src/runtime/emit/drop-index.d.ts.map +1 -1
- package/dist/src/runtime/emit/drop-index.js +7 -2
- 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 +16 -10
- 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 +50 -43
- package/dist/src/runtime/emit/drop-view.js.map +1 -1
- package/dist/src/runtime/emit/insert.d.ts.map +1 -1
- package/dist/src/runtime/emit/insert.js +2 -1
- package/dist/src/runtime/emit/insert.js.map +1 -1
- package/dist/src/runtime/emit/materialized-view.d.ts.map +1 -1
- package/dist/src/runtime/emit/materialized-view.js +87 -67
- package/dist/src/runtime/emit/materialized-view.js.map +1 -1
- package/dist/src/runtime/emit/schema-declarative.d.ts +8 -0
- package/dist/src/runtime/emit/schema-declarative.d.ts.map +1 -1
- package/dist/src/runtime/emit/schema-declarative.js +128 -25
- package/dist/src/runtime/emit/schema-declarative.js.map +1 -1
- package/dist/src/runtime/emit/sequence.d.ts +17 -0
- package/dist/src/runtime/emit/sequence.d.ts.map +1 -0
- package/dist/src/runtime/emit/sequence.js +40 -0
- package/dist/src/runtime/emit/sequence.js.map +1 -0
- package/dist/src/runtime/emit/set-object-tags.d.ts.map +1 -1
- package/dist/src/runtime/emit/set-object-tags.js +40 -32
- package/dist/src/runtime/emit/set-object-tags.js.map +1 -1
- package/dist/src/runtime/emit/table-valued-function.d.ts.map +1 -1
- package/dist/src/runtime/emit/table-valued-function.js +3 -2
- package/dist/src/runtime/emit/table-valued-function.js.map +1 -1
- package/dist/src/runtime/emit/update.js +3 -3
- package/dist/src/runtime/emit/update.js.map +1 -1
- package/dist/src/runtime/emit/view-mutation.d.ts.map +1 -1
- package/dist/src/runtime/emit/view-mutation.js +45 -3
- package/dist/src/runtime/emit/view-mutation.js.map +1 -1
- package/dist/src/runtime/foreign-key-actions.d.ts.map +1 -1
- package/dist/src/runtime/foreign-key-actions.js +9 -10
- package/dist/src/runtime/foreign-key-actions.js.map +1 -1
- package/dist/src/runtime/register.d.ts.map +1 -1
- package/dist/src/runtime/register.js +3 -2
- package/dist/src/runtime/register.js.map +1 -1
- package/dist/src/runtime/row-constraints.d.ts +14 -8
- package/dist/src/runtime/row-constraints.d.ts.map +1 -1
- package/dist/src/runtime/row-constraints.js +41 -15
- package/dist/src/runtime/row-constraints.js.map +1 -1
- package/dist/src/runtime/strict-representation.d.ts +11 -6
- package/dist/src/runtime/strict-representation.d.ts.map +1 -1
- package/dist/src/runtime/strict-representation.js +1 -44
- package/dist/src/runtime/strict-representation.js.map +1 -1
- package/dist/src/schema/assertion.d.ts +25 -2
- package/dist/src/schema/assertion.d.ts.map +1 -1
- package/dist/src/schema/assertion.js.map +1 -1
- package/dist/src/schema/catalog-rendering.d.ts +38 -0
- package/dist/src/schema/catalog-rendering.d.ts.map +1 -0
- package/dist/src/schema/catalog-rendering.js +171 -0
- package/dist/src/schema/catalog-rendering.js.map +1 -0
- package/dist/src/schema/catalog.d.ts +69 -3
- package/dist/src/schema/catalog.d.ts.map +1 -1
- package/dist/src/schema/catalog.js +124 -19
- package/dist/src/schema/catalog.js.map +1 -1
- package/dist/src/schema/column-source-resolver.d.ts +9 -5
- package/dist/src/schema/column-source-resolver.d.ts.map +1 -1
- package/dist/src/schema/column-source-resolver.js +9 -5
- package/dist/src/schema/column-source-resolver.js.map +1 -1
- package/dist/src/schema/constraint-builder.d.ts +13 -10
- package/dist/src/schema/constraint-builder.d.ts.map +1 -1
- package/dist/src/schema/constraint-builder.js +45 -17
- package/dist/src/schema/constraint-builder.js.map +1 -1
- package/dist/src/schema/declared-schema-manager.d.ts +50 -0
- package/dist/src/schema/declared-schema-manager.d.ts.map +1 -1
- package/dist/src/schema/declared-schema-manager.js +52 -0
- package/dist/src/schema/declared-schema-manager.js.map +1 -1
- package/dist/src/schema/expr-scope/frame.d.ts +65 -0
- package/dist/src/schema/expr-scope/frame.d.ts.map +1 -0
- package/dist/src/schema/expr-scope/frame.js +104 -0
- package/dist/src/schema/expr-scope/frame.js.map +1 -0
- package/dist/src/schema/expr-scope/walk.d.ts +40 -0
- package/dist/src/schema/expr-scope/walk.d.ts.map +1 -0
- package/dist/src/schema/expr-scope/walk.js +260 -0
- package/dist/src/schema/expr-scope/walk.js.map +1 -0
- package/dist/src/schema/generated-column-refs.d.ts +41 -0
- package/dist/src/schema/generated-column-refs.d.ts.map +1 -0
- package/dist/src/schema/generated-column-refs.js +124 -0
- package/dist/src/schema/generated-column-refs.js.map +1 -0
- package/dist/src/schema/lens-ack.d.ts.map +1 -1
- package/dist/src/schema/lens-ack.js +5 -2
- package/dist/src/schema/lens-ack.js.map +1 -1
- package/dist/src/schema/lens-compiler.d.ts.map +1 -1
- package/dist/src/schema/lens-compiler.js +9 -1
- package/dist/src/schema/lens-compiler.js.map +1 -1
- package/dist/src/schema/lens-prover.d.ts +7 -2
- package/dist/src/schema/lens-prover.d.ts.map +1 -1
- package/dist/src/schema/lens-prover.js +105 -11
- package/dist/src/schema/lens-prover.js.map +1 -1
- package/dist/src/schema/lens.d.ts +12 -0
- package/dist/src/schema/lens.d.ts.map +1 -1
- package/dist/src/schema/lens.js +10 -0
- package/dist/src/schema/lens.js.map +1 -1
- package/dist/src/schema/manager.d.ts +35 -1
- package/dist/src/schema/manager.d.ts.map +1 -1
- package/dist/src/schema/manager.js +125 -26
- package/dist/src/schema/manager.js.map +1 -1
- package/dist/src/schema/rename/self-qualifier-strip.d.ts +16 -10
- package/dist/src/schema/rename/self-qualifier-strip.d.ts.map +1 -1
- package/dist/src/schema/rename/self-qualifier-strip.js +30 -213
- package/dist/src/schema/rename/self-qualifier-strip.js.map +1 -1
- package/dist/src/schema/rename-rewriter.d.ts +4 -3
- package/dist/src/schema/rename-rewriter.d.ts.map +1 -1
- package/dist/src/schema/rename-rewriter.js +4 -3
- package/dist/src/schema/rename-rewriter.js.map +1 -1
- package/dist/src/schema/schema-differ.d.ts +54 -6
- package/dist/src/schema/schema-differ.d.ts.map +1 -1
- package/dist/src/schema/schema-differ.js +108 -42
- package/dist/src/schema/schema-differ.js.map +1 -1
- package/dist/src/schema/schema-hasher.d.ts +12 -0
- package/dist/src/schema/schema-hasher.d.ts.map +1 -1
- package/dist/src/schema/schema-hasher.js +28 -10
- package/dist/src/schema/schema-hasher.js.map +1 -1
- package/dist/src/schema/table.d.ts +74 -19
- package/dist/src/schema/table.d.ts.map +1 -1
- package/dist/src/schema/table.js +133 -71
- package/dist/src/schema/table.js.map +1 -1
- package/dist/src/types/comparison-coercion.d.ts +5 -1
- package/dist/src/types/comparison-coercion.d.ts.map +1 -1
- package/dist/src/types/comparison-coercion.js +21 -5
- package/dist/src/types/comparison-coercion.js.map +1 -1
- package/dist/src/types/representation.d.ts +65 -0
- package/dist/src/types/representation.d.ts.map +1 -0
- package/dist/src/types/representation.js +63 -0
- package/dist/src/types/representation.js.map +1 -0
- package/dist/src/types/validation.d.ts +76 -22
- package/dist/src/types/validation.d.ts.map +1 -1
- package/dist/src/types/validation.js +110 -31
- package/dist/src/types/validation.js.map +1 -1
- package/dist/src/vtab/best-access-plan.d.ts +10 -0
- package/dist/src/vtab/best-access-plan.d.ts.map +1 -1
- package/dist/src/vtab/best-access-plan.js +16 -0
- package/dist/src/vtab/best-access-plan.js.map +1 -1
- package/dist/src/vtab/capabilities.d.ts +72 -4
- package/dist/src/vtab/capabilities.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 +17 -13
- package/dist/src/vtab/memory/layer/manager.js.map +1 -1
- package/dist/src/vtab/module.d.ts +13 -7
- package/dist/src/vtab/module.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/src/planner/nodes/array-index-node.d.ts +0 -22
- package/dist/src/planner/nodes/array-index-node.d.ts.map +0 -1
- package/dist/src/planner/nodes/array-index-node.js +0 -41
- package/dist/src/planner/nodes/array-index-node.js.map +0 -1
- package/dist/src/runtime/emit/array-index.d.ts +0 -5
- package/dist/src/runtime/emit/array-index.d.ts.map +0 -1
- package/dist/src/runtime/emit/array-index.js +0 -22
- package/dist/src/runtime/emit/array-index.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { WindowNode } from '../nodes/window-node.js';
|
|
2
2
|
import { WindowFunctionCallNode } from '../nodes/window-function.js';
|
|
3
3
|
import { ProjectNode } from '../nodes/project-node.js';
|
|
4
|
-
import {
|
|
4
|
+
import { ColumnReferenceNode } from '../nodes/reference.js';
|
|
5
5
|
import { LiteralNode } from '../nodes/scalar.js';
|
|
6
6
|
import { buildExpression } from './expression.js';
|
|
7
|
-
import {
|
|
7
|
+
import { collectAggregateFunctionExprs, redirectPostAggregate } from './select-aggregates.js';
|
|
8
8
|
import { findMatchingAggregate } from './function-call.js';
|
|
9
|
-
import { QuereusError } from '../../common/errors.js';
|
|
9
|
+
import { QuereusError, quereusError } from '../../common/errors.js';
|
|
10
10
|
import { StatusCode } from '../../common/types.js';
|
|
11
11
|
import { expressionToString } from '../../emit/ast-stringify.js';
|
|
12
12
|
import { CapabilityDetectors } from '../framework/characteristics.js';
|
|
@@ -29,6 +29,9 @@ export function buildWindowPhase(input, windowFunctions, selectContext, selectLi
|
|
|
29
29
|
let currentInput = input;
|
|
30
30
|
// Group window functions by their window specification
|
|
31
31
|
const windowGroups = groupWindowFunctionsBySpec(windowFunctions);
|
|
32
|
+
// Each collected function's window-output attribute, recorded as its node is
|
|
33
|
+
// built; resolved to a WindowColumnEntry against the outermost node below.
|
|
34
|
+
const windowAttributes = new Map();
|
|
32
35
|
// Create WindowNode for each unique window specification
|
|
33
36
|
for (const [_windowSpecKey, functions] of windowGroups) {
|
|
34
37
|
const firstFunc = functions[0];
|
|
@@ -52,10 +55,10 @@ export function buildWindowPhase(input, windowFunctions, selectContext, selectLi
|
|
|
52
55
|
// nonetheless bind to a base-table attribute, because the scope these are built
|
|
53
56
|
// against falls through to the pre-aggregate select scope: a qualified `wg.a`
|
|
54
57
|
// against `group by a`, or the whole expression against `group by a || '!'`.
|
|
55
|
-
// Redirect every such subtree onto the aggregate's own output column.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
// Redirect every such subtree onto the aggregate's own output column. Anything a
|
|
59
|
+
// redirect leaves on a pre-grouping attribute is a genuinely ungrouped reference,
|
|
60
|
+
// rejected over the finished plan by `assertGroupedPlanCoverage` (select.ts).
|
|
61
|
+
const redirect = (expr) => redirectPostAggregate(expr, groupedWindowContext, selectContext.scope);
|
|
59
62
|
// CRITICAL: Build window specification expressions using the INPUT scope
|
|
60
63
|
// This ensures expressions reference the correct input attribute IDs,
|
|
61
64
|
// not premature output attribute IDs that don't exist in the runtime context
|
|
@@ -65,30 +68,33 @@ export function buildWindowPhase(input, windowFunctions, selectContext, selectLi
|
|
|
65
68
|
// so each re-created WindowFunctionCallNode can be handed its argument
|
|
66
69
|
// logical types for faithful return-type inference (window MIN/MAX).
|
|
67
70
|
const functionArguments = buildWindowFunctionArguments(functions.map(({ func }) => func), selectContext).map(args => args.map(redirect));
|
|
68
|
-
// After redirection, anything still naming one of this query's pre-grouping
|
|
69
|
-
// columns is a genuinely ungrouped reference, illegal for exactly the reason a
|
|
70
|
-
// bare column in the select list is, and must say so at plan time — otherwise it
|
|
71
|
-
// reaches the runtime as an attribute the aggregate row never had, and the query
|
|
72
|
-
// dies with an internal "no row context" error instead. A reference belonging to
|
|
73
|
-
// a subquery inside the specification, or correlated out to an ENCLOSING query,
|
|
74
|
-
// is not this query's business and passes through.
|
|
75
|
-
if (groupedWindowContext) {
|
|
76
|
-
for (const expr of partitionExpressions)
|
|
77
|
-
assertGroupedWindowCoverage(expr, groupedWindowContext);
|
|
78
|
-
for (const expr of orderByExpressions)
|
|
79
|
-
assertGroupedWindowCoverage(expr, groupedWindowContext);
|
|
80
|
-
for (const args of functionArguments) {
|
|
81
|
-
for (const arg of args)
|
|
82
|
-
assertGroupedWindowCoverage(arg, groupedWindowContext);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
71
|
// Create new WindowFunctionCallNode instances with alias + argument-type info
|
|
86
72
|
const windowFuncsWithAlias = functions.map(({ func, alias }, i) => new WindowFunctionCallNode(func.scope, func.expression, func.functionName, func.isDistinct, alias, functionArguments[i].map(a => a.getType().logicalType)));
|
|
87
73
|
// Now create the WindowNode with pre-compiled expressions
|
|
88
|
-
|
|
74
|
+
const windowNode = new WindowNode(selectContext.scope, currentInput, windowSpec, windowFuncsWithAlias, partitionExpressions, orderByExpressions, functionArguments);
|
|
75
|
+
// Record each function's freshly minted window-output attribute under the
|
|
76
|
+
// AST identity the select-list rewrite will look it up by.
|
|
77
|
+
const windowAttrs = windowNode.getWindowAttributes();
|
|
78
|
+
functions.forEach(({ func }, i) => {
|
|
79
|
+
windowAttributes.set(func.expression, windowAttrs[i]);
|
|
80
|
+
});
|
|
81
|
+
currentInput = windowNode;
|
|
82
|
+
}
|
|
83
|
+
// Resolve each window attribute's position against the OUTERMOST window node —
|
|
84
|
+
// stacked WindowNodes pass inner window columns through, so one lookup covers
|
|
85
|
+
// every group without index arithmetic.
|
|
86
|
+
const outerAttrIndex = currentInput.getAttributeIndex();
|
|
87
|
+
const windowColumns = new Map();
|
|
88
|
+
for (const [expr, attr] of windowAttributes) {
|
|
89
|
+
windowColumns.set(expr, {
|
|
90
|
+
attr,
|
|
91
|
+
// Present by construction: every window attribute is on the outermost node's row.
|
|
92
|
+
columnIndex: outerAttrIndex.get(attr.id),
|
|
93
|
+
});
|
|
89
94
|
}
|
|
90
|
-
//
|
|
91
|
-
|
|
95
|
+
// Rewrite the select list into the projection above the WindowNode(s), with each
|
|
96
|
+
// window function replaced by a reference to its window-output column.
|
|
97
|
+
const windowProjections = buildWindowProjections(selectListProjections, windowColumns, selectContext.scope);
|
|
92
98
|
if (windowProjections.length > 0) {
|
|
93
99
|
currentInput = new ProjectNode(selectContext.scope, currentInput, windowProjections);
|
|
94
100
|
}
|
|
@@ -142,28 +148,29 @@ function rejectUncollectedAggregates(func, selectContext) {
|
|
|
142
148
|
check(arg, 'arguments');
|
|
143
149
|
}
|
|
144
150
|
/**
|
|
145
|
-
* Groups window functions by their window specification
|
|
151
|
+
* Groups window functions by their window specification, so functions sharing a
|
|
152
|
+
* specification share one WindowNode — one sort and one buffering/streaming pass
|
|
153
|
+
* per unique specification.
|
|
146
154
|
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
* clauses
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* position first.
|
|
155
|
+
* The key is `JSON.stringify` over the raw AST spec fragments with every
|
|
156
|
+
* source-location (`loc`) field stripped, so two textually identical `over (…)`
|
|
157
|
+
* clauses key equal wherever they were written. Spelling differences that the
|
|
158
|
+
* scope would resolve identically (a different identifier case, an unused
|
|
159
|
+
* qualifier) still key apart — that only costs a duplicate WindowNode, never a
|
|
160
|
+
* wrong merge, because within one select list the same spelling always resolves
|
|
161
|
+
* to the same thing. Matching a function to its output COLUMN is independent of
|
|
162
|
+
* this grouping: each function's window attribute is recorded under its
|
|
163
|
+
* `AST.WindowFunctionExpr` identity as its node is built (see buildWindowPhase).
|
|
157
164
|
*/
|
|
158
165
|
function groupWindowFunctionsBySpec(windowFunctions) {
|
|
159
166
|
const windowGroups = new Map();
|
|
160
167
|
for (const { func, alias } of windowFunctions) {
|
|
161
|
-
//
|
|
168
|
+
// Structural key: the spec fragments minus source locations.
|
|
162
169
|
const windowSpecKey = JSON.stringify({
|
|
163
170
|
partitionBy: func.expression.window?.partitionBy || [],
|
|
164
171
|
orderBy: func.expression.window?.orderBy || [],
|
|
165
|
-
frame: func.expression.window?.frame
|
|
166
|
-
});
|
|
172
|
+
frame: func.expression.window?.frame ?? null
|
|
173
|
+
}, (key, value) => (key === 'loc' ? undefined : value));
|
|
167
174
|
if (!windowGroups.has(windowSpecKey)) {
|
|
168
175
|
windowGroups.set(windowSpecKey, []);
|
|
169
176
|
}
|
|
@@ -205,20 +212,19 @@ function buildWindowFunctionArguments(windowFuncs, selectContext) {
|
|
|
205
212
|
* expressions, which are left exactly as built. Only entries containing a window
|
|
206
213
|
* function are rebuilt, and only by substituting each window result in place.
|
|
207
214
|
*/
|
|
208
|
-
function buildWindowProjections(selectListProjections,
|
|
209
|
-
const windowType = windowNode.getType();
|
|
210
|
-
const sourceColumnCount = windowType.columns.length - windowFunctions.length;
|
|
215
|
+
function buildWindowProjections(selectListProjections, windowColumns, scope) {
|
|
211
216
|
return selectListProjections.map(projection => {
|
|
212
|
-
// Rewrite each window-function descendant into
|
|
213
|
-
//
|
|
214
|
-
//
|
|
215
|
-
const rewritten = rewriteWindowFunctions(projection.node,
|
|
217
|
+
// Rewrite each window-function descendant into a column reference to its
|
|
218
|
+
// computed window-output column, preserving any surrounding arithmetic /
|
|
219
|
+
// scalar wrapper (e.g. `1000 - row_number() over (...)`).
|
|
220
|
+
const rewritten = rewriteWindowFunctions(projection.node, windowColumns, scope);
|
|
216
221
|
if (rewritten === projection.node)
|
|
217
222
|
return projection;
|
|
218
|
-
// The rewrite replaces the authored expression with
|
|
219
|
-
// own name is
|
|
220
|
-
// expression the user wrote as its output name, like every
|
|
221
|
-
// select-list column (`select count(*) from t group by g`
|
|
223
|
+
// The rewrite replaces the authored expression with a column reference whose
|
|
224
|
+
// own name is the window column's synthetic name. An unaliased window column
|
|
225
|
+
// must keep the expression the user wrote as its output name, like every
|
|
226
|
+
// other unaliased select-list column (`select count(*) from t group by g`
|
|
227
|
+
// yields `count(*)`).
|
|
222
228
|
return {
|
|
223
229
|
...projection,
|
|
224
230
|
node: rewritten,
|
|
@@ -229,22 +235,37 @@ function buildWindowProjections(selectListProjections, windowNode, selectContext
|
|
|
229
235
|
}
|
|
230
236
|
/**
|
|
231
237
|
* Recursively rewrites every WindowFunctionCallNode descendant of a scalar
|
|
232
|
-
* expression into
|
|
233
|
-
*
|
|
238
|
+
* expression into a ColumnReferenceNode bound to that function's window-output
|
|
239
|
+
* attribute, leaving the surrounding expression structure intact.
|
|
240
|
+
*
|
|
241
|
+
* The reference resolves by attribute id at runtime (`resolveAttribute`), exactly
|
|
242
|
+
* like every other column read — so it stays correct no matter what operators the
|
|
243
|
+
* optimizer later places between the WindowNode and this projection.
|
|
234
244
|
*
|
|
235
245
|
* Mirrors the aggregate path (collectInnerAggregates): the whole outer
|
|
236
246
|
* expression is preserved and the inner window results are substituted back in.
|
|
237
247
|
* Does NOT recurse into a window function's own arguments — its result is a
|
|
238
248
|
* single output column already materialized by the WindowNode.
|
|
239
249
|
*/
|
|
240
|
-
function rewriteWindowFunctions(node,
|
|
250
|
+
function rewriteWindowFunctions(node, windowColumns, scope) {
|
|
241
251
|
if (CapabilityDetectors.isWindowFunction(node)) {
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
|
|
252
|
+
const windowFunc = node;
|
|
253
|
+
const entry = windowColumns.get(windowFunc.expression);
|
|
254
|
+
if (!entry) {
|
|
255
|
+
// Every window function in the select list was collected by
|
|
256
|
+
// analyzeSelectColumns and keyed here by its AST node; a miss means the
|
|
257
|
+
// two walks diverged, and silently keeping the raw node would reach the
|
|
258
|
+
// runtime as an unevaluable call.
|
|
259
|
+
quereusError(`Window function ${windowFunc.functionName} was not collected into any WindowNode`, StatusCode.INTERNAL);
|
|
245
260
|
}
|
|
246
|
-
//
|
|
247
|
-
|
|
261
|
+
// Synthetic column expression; only plan display and error text read it
|
|
262
|
+
// (ColumnReferenceNode.toString() / getLogicalAttributes()).
|
|
263
|
+
const columnExpr = {
|
|
264
|
+
type: 'column',
|
|
265
|
+
name: entry.attr.name,
|
|
266
|
+
loc: windowFunc.expression.loc,
|
|
267
|
+
};
|
|
268
|
+
return new ColumnReferenceNode(scope, columnExpr, entry.attr.type, entry.attr.id, entry.columnIndex);
|
|
248
269
|
}
|
|
249
270
|
const children = node.getChildren();
|
|
250
271
|
const newChildren = [];
|
|
@@ -252,7 +273,7 @@ function rewriteWindowFunctions(node, windowFunctions, sourceColumnCount, window
|
|
|
252
273
|
for (const child of children) {
|
|
253
274
|
// Only scalar children participate in window rewriting; pass others through.
|
|
254
275
|
if ('expression' in child) {
|
|
255
|
-
const rewrittenChild = rewriteWindowFunctions(child,
|
|
276
|
+
const rewrittenChild = rewriteWindowFunctions(child, windowColumns, scope);
|
|
256
277
|
if (rewrittenChild !== child) {
|
|
257
278
|
changed = true;
|
|
258
279
|
}
|
|
@@ -264,44 +285,4 @@ function rewriteWindowFunctions(node, windowFunctions, sourceColumnCount, window
|
|
|
264
285
|
}
|
|
265
286
|
return changed ? node.withChildren(newChildren) : node;
|
|
266
287
|
}
|
|
267
|
-
/**
|
|
268
|
-
* Finds the window-output column index for a single window-function node by
|
|
269
|
-
* matching it (name + window spec) against the collected window functions.
|
|
270
|
-
*/
|
|
271
|
-
function findWindowColumnIndex(windowNode, windowFunctions, sourceColumnCount) {
|
|
272
|
-
const matchingWindowFuncIndex = windowFunctions.findIndex(({ func }) => {
|
|
273
|
-
// Match based on function name and window specification
|
|
274
|
-
if (func.functionName.toLowerCase() !== windowNode.functionName.toLowerCase()) {
|
|
275
|
-
return false;
|
|
276
|
-
}
|
|
277
|
-
return compareWindowSpecs(windowNode.expression.window, func.expression.window);
|
|
278
|
-
});
|
|
279
|
-
return matchingWindowFuncIndex >= 0 ? sourceColumnCount + matchingWindowFuncIndex : -1;
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Compares two window specifications for equality
|
|
283
|
-
*
|
|
284
|
-
* NOTE: like {@link groupWindowFunctionsBySpec}, this compares `JSON.stringify` of
|
|
285
|
-
* raw AST fragments including their source-location (`loc`) data, so two textually
|
|
286
|
-
* identical `over (…)` clauses written at different positions never compare equal.
|
|
287
|
-
* That is what keeps `sum(v) over (order by v) a, sum(v*10) over (order by v) b`
|
|
288
|
-
* resolving to two different window columns despite matching on function name.
|
|
289
|
-
* Making this comparison structural without also teaching
|
|
290
|
-
* {@link findWindowColumnIndex} to match by node identity or position collapses
|
|
291
|
-
* both onto the first function's column.
|
|
292
|
-
*/
|
|
293
|
-
function compareWindowSpecs(originalWindow, funcWindow) {
|
|
294
|
-
// Compare partition expressions
|
|
295
|
-
const originalPartition = JSON.stringify(originalWindow?.partitionBy || []);
|
|
296
|
-
const funcPartition = JSON.stringify(funcWindow?.partitionBy || []);
|
|
297
|
-
// Compare order expressions
|
|
298
|
-
const originalOrder = JSON.stringify(originalWindow?.orderBy || []);
|
|
299
|
-
const funcOrder = JSON.stringify(funcWindow?.orderBy || []);
|
|
300
|
-
// Compare frame specifications
|
|
301
|
-
const originalFrame = JSON.stringify(originalWindow?.frame || null);
|
|
302
|
-
const funcFrame = JSON.stringify(funcWindow?.frame || null);
|
|
303
|
-
return originalPartition === funcPartition &&
|
|
304
|
-
originalOrder === funcOrder &&
|
|
305
|
-
originalFrame === funcFrame;
|
|
306
|
-
}
|
|
307
288
|
//# sourceMappingURL=select-window.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-window.js","sourceRoot":"","sources":["../../../../src/planner/building/select-window.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"select-window.js","sourceRoot":"","sources":["../../../../src/planner/building/select-window.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAmB,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,WAAW,EAAmB,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,6BAA6B,EAAE,qBAAqB,EAA+B,MAAM,wBAAwB,CAAC;AAC3H,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAmBtE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAC/B,KAAyB,EACzB,eAAmE,EACnE,aAA8B,EAC9B,qBAA4C,EAC5C,oBAA6C;IAE7C,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,KAAK,CAAC;IACd,CAAC;IAED,IAAI,YAAY,GAAG,KAAK,CAAC;IAEzB,uDAAuD;IACvD,MAAM,YAAY,GAAG,0BAA0B,CAAC,eAAe,CAAC,CAAC;IAEjE,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AG,CAAC,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,GAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAa,GAAG,kBAAkB,CA0RzJ;AA6FD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,mBAAmB,CAClC,YAAY,EAAE,SAAS,MAAM,EAAE,EAC/B,SAAS,EAAE,SAAS,SAAS,EAAE,EAC/B,UAAU,EAAE,SAAS,SAAS,EAAE,EAChC,KAAK,EAAE,KAAK,GACV,cAAc,CAchB"}
|
|
@@ -31,7 +31,7 @@ import { buildWithContext, enterStoredBodyEnv } from './select-context.js';
|
|
|
31
31
|
import { storedBodyContext } from '../stored-body-context.js';
|
|
32
32
|
import { buildCompoundSelect } from './select-compound.js';
|
|
33
33
|
import { analyzeSelectColumns, buildStarProjections } from './select-projections.js';
|
|
34
|
-
import { buildAggregatePhase, buildFinalAggregateProjections,
|
|
34
|
+
import { buildAggregatePhase, buildFinalAggregateProjections, assertGroupedPlanCoverage, redirectPostAggregate } from './select-aggregates.js';
|
|
35
35
|
import { buildWindowPhase } from './select-window.js';
|
|
36
36
|
import { buildFinalProjections, applyDistinct, applyOrderBy, applyLimitOffset, createProjectionOutputScope } from './select-modifiers.js';
|
|
37
37
|
import { SortNode } from '../nodes/sort.js';
|
|
@@ -155,10 +155,13 @@ preserveInputColumns = true) {
|
|
|
155
155
|
// Set when the query is BOTH grouped and windowed: the grouped select-list
|
|
156
156
|
// projection list, to be projected above the window phase's WindowNode.
|
|
157
157
|
let windowSelectProjections;
|
|
158
|
-
//
|
|
159
|
-
//
|
|
160
|
-
//
|
|
161
|
-
|
|
158
|
+
// Set for every GROUPED query (built by buildAggregatePhase the moment the
|
|
159
|
+
// AggregateNode exists, so no post-aggregate site here can run before it): what
|
|
160
|
+
// the aggregate's rows carry, so every post-aggregate expression built below —
|
|
161
|
+
// sort keys, the rebuilt select list, the window phase's specifications and
|
|
162
|
+
// arguments — reaches the grouping-key redirect through redirectPostAggregate,
|
|
163
|
+
// and so the finished plan can be boundary-checked once at the bottom.
|
|
164
|
+
const groupedRedirectContext = aggregateResult.groupedRedirectContext;
|
|
162
165
|
// The node whose output attributes ARE this SELECT's result columns, once one
|
|
163
166
|
// exists. A positional ORDER BY binds to its Nth attribute (see applyOrderBy).
|
|
164
167
|
let orderByOutputRelation;
|
|
@@ -174,40 +177,39 @@ preserveInputColumns = true) {
|
|
|
174
177
|
scope: aggregateResult.aggregateScope,
|
|
175
178
|
aggregates: aggregateResult.aggregatesContext,
|
|
176
179
|
};
|
|
177
|
-
//
|
|
178
|
-
//
|
|
179
|
-
//
|
|
180
|
-
//
|
|
180
|
+
// Applying ORDER BY here — *before* any stripping final projection — is the
|
|
181
|
+
// EXCEPTION, taken only when ORDER BY introduced aggregates the select list
|
|
182
|
+
// does not have. Those exist solely for the sort and the final projection
|
|
183
|
+
// strips them, so the sort must see the full AggregateNode output while they
|
|
184
|
+
// are still there. Every other aggregate ORDER BY falls through to the
|
|
185
|
+
// applyOrderBy at the bottom of this function, which gets the final
|
|
186
|
+
// projection's output scope — the only place an alias of a *wrapped* aggregate
|
|
187
|
+
// (`count(*) + 1 as c`, whose aggregate entry is aliased `count(*)`) is named.
|
|
188
|
+
// Also skipped when window functions are present (window output isn't
|
|
181
189
|
// available yet) or when pre-aggregate sort already handled ordering.
|
|
182
|
-
|
|
190
|
+
//
|
|
191
|
+
// The two scopes are mutually exclusive, so an ORDER BY that needs BOTH loses:
|
|
192
|
+
// `select count(*) + 1 as c from t order by max(a), c` takes this branch for
|
|
193
|
+
// `max(a)` and then cannot see `c`. Tracked as
|
|
194
|
+
// backlog/bug-order-by-alias-lost-when-order-by-adds-its-own-aggregate.
|
|
195
|
+
if (aggregateResult.orderByNeedsPostAggregateSort &&
|
|
196
|
+
aggregateResult.hasOrderByOnlyAggregates &&
|
|
183
197
|
!preAggregateSort &&
|
|
184
198
|
!hasWindowFunctions &&
|
|
185
199
|
stmt.orderBy && stmt.orderBy.length > 0) {
|
|
186
|
-
input = applyOrderBy(input, stmt, selectContext,
|
|
200
|
+
input = applyOrderBy(input, stmt, selectContext, {
|
|
201
|
+
allowAggregates: true,
|
|
202
|
+
selectList: selectListEntries,
|
|
203
|
+
groupedRedirect: groupedRedirectContext,
|
|
204
|
+
});
|
|
187
205
|
orderByAppliedEarly = true;
|
|
188
206
|
}
|
|
189
|
-
// A grouped, windowed query's window specifications and function arguments are
|
|
190
|
-
// built against the aggregate-output scope but fall through to the pre-aggregate
|
|
191
|
-
// select scope for anything the aggregate does not carry. Some of what falls
|
|
192
|
-
// through is a legal grouping key under another spelling and some is a genuinely
|
|
193
|
-
// ungrouped column, so hand the window phase both halves: the maps that redirect
|
|
194
|
-
// the former onto the aggregate's own output columns, and the strict coverage
|
|
195
|
-
// test that rejects the latter at plan time. The aggregate's source relation goes
|
|
196
|
-
// along so both halves can tell which references belong to THIS query — a window
|
|
197
|
-
// specification may contain a subquery, whose own columns and whose correlated
|
|
198
|
-
// references to an enclosing query are neither redirected nor rejected.
|
|
199
|
-
if (hasWindowFunctions &&
|
|
200
|
-
aggregateResult.aggregateNode &&
|
|
201
|
-
aggregateResult.groupByExpressions &&
|
|
202
|
-
aggregateResult.groupByExpressions.length > 0) {
|
|
203
|
-
windowGroupedContext = buildGroupedWindowContext(aggregateResult.groupByExpressions, aggregateResult.aggregateNode.getAttributes(), aggregateResult.aggregateNode.getRelations()[0]);
|
|
204
|
-
}
|
|
205
207
|
// Build final projections if needed. A window function in the select list also
|
|
206
208
|
// forces one: the window phase projects the select list ABOVE its WindowNode, so
|
|
207
209
|
// the grouped select list must be materialized as a projection list here even when
|
|
208
210
|
// the AggregateNode's own output would otherwise have been the result shape.
|
|
209
211
|
if ((aggregateResult.needsFinalProjection || hasWindowFunctions) && aggregateResult.aggregateNode && aggregateResult.groupByExpressions) {
|
|
210
|
-
const finalProjections = buildFinalAggregateProjections(stmt, selectContext, aggregateResult.aggregateScope, aggregateResult.aggregateNode, aggregates, aggregateResult.groupByExpressions, starProjectionsByColumn);
|
|
212
|
+
const finalProjections = buildFinalAggregateProjections(stmt, selectContext, aggregateResult.aggregateScope, aggregateResult.aggregateNode, aggregates, aggregateResult.groupByExpressions, starProjectionsByColumn, groupedRedirectContext);
|
|
211
213
|
if (hasWindowFunctions) {
|
|
212
214
|
// Hand the grouped select list to the window phase instead of projecting it
|
|
213
215
|
// here: the WindowNode must sit between the aggregate output and the final
|
|
@@ -250,9 +252,12 @@ preserveInputColumns = true) {
|
|
|
250
252
|
if (!selectedColumns.has(orderColumn)) {
|
|
251
253
|
// Apply ORDER BY before window projections. This sort sits BELOW the
|
|
252
254
|
// window projection, so a positional reference resolves through the
|
|
253
|
-
// select list (no output attributes exist yet to bind to).
|
|
255
|
+
// select list (no output attributes exist yet to bind to). In a
|
|
256
|
+
// grouped query this SortNode sits ABOVE the AggregateNode, so a key
|
|
257
|
+
// naming a grouping key by a spelling the aggregate output scope does
|
|
258
|
+
// not publish must land on the aggregate's own output column.
|
|
254
259
|
const sortKeys = stmt.orderBy.map(orderBy => ({
|
|
255
|
-
expression: buildOrdinalAwareExpression(selectContext, orderBy.expr, selectListEntries, 'ORDER BY'),
|
|
260
|
+
expression: redirectPostAggregate(buildOrdinalAwareExpression(selectContext, orderBy.expr, selectListEntries, 'ORDER BY'), groupedRedirectContext, selectContext.scope),
|
|
256
261
|
direction: orderBy.direction,
|
|
257
262
|
nulls: orderBy.nulls
|
|
258
263
|
}));
|
|
@@ -263,7 +268,7 @@ preserveInputColumns = true) {
|
|
|
263
268
|
}
|
|
264
269
|
}
|
|
265
270
|
}
|
|
266
|
-
input = buildWindowPhase(input, windowFunctions, selectContext, windowSelectProjections ?? projections,
|
|
271
|
+
input = buildWindowPhase(input, windowFunctions, selectContext, windowSelectProjections ?? projections, groupedRedirectContext);
|
|
267
272
|
// The window phase ends in a ProjectNode over the SELECT list, so that node's
|
|
268
273
|
// attributes are this query's result columns.
|
|
269
274
|
orderByOutputRelation = input;
|
|
@@ -299,7 +304,12 @@ preserveInputColumns = true) {
|
|
|
299
304
|
orderByOutputRelation = finalResult.output;
|
|
300
305
|
// Apply final modifiers with projection scope for column alias resolution
|
|
301
306
|
input = applyDistinct(input, stmt, selectScope);
|
|
302
|
-
input = applyOrderBy(input, stmt, selectContext,
|
|
307
|
+
input = applyOrderBy(input, stmt, selectContext, {
|
|
308
|
+
preAggregateSort,
|
|
309
|
+
projectionScope: finalResult.projectionScope,
|
|
310
|
+
selectList: selectListEntries,
|
|
311
|
+
outputRelation: orderByOutputRelation,
|
|
312
|
+
});
|
|
303
313
|
input = applyLimitOffset(input, stmt, selectContext, finalResult.projectionScope);
|
|
304
314
|
}
|
|
305
315
|
else {
|
|
@@ -311,10 +321,45 @@ preserveInputColumns = true) {
|
|
|
311
321
|
if (!orderByAppliedEarly) {
|
|
312
322
|
// In the aggregate path, ORDER BY may legally reference aggregates; in the
|
|
313
323
|
// window path it may reference window outputs. Both are now in selectContext.
|
|
314
|
-
|
|
324
|
+
// `groupedRedirect` makes a sort key naming a grouping key by a spelling the
|
|
325
|
+
// output scopes do not publish (`order by wg.a`, `order by upper(wg.a)`, a
|
|
326
|
+
// repeated computed key) land on the AggregateNode's own output column.
|
|
327
|
+
// Without it the key binds to a base-table attribute and the sort dies at run
|
|
328
|
+
// time whenever a buffering operator — a WindowNode — sits between the
|
|
329
|
+
// aggregate and this sort.
|
|
330
|
+
input = applyOrderBy(input, stmt, selectContext, {
|
|
331
|
+
preAggregateSort,
|
|
332
|
+
projectionScope: aggregateProjectionScope,
|
|
333
|
+
allowAggregates: hasAggregates,
|
|
334
|
+
selectList: selectListEntries,
|
|
335
|
+
outputRelation: orderByOutputRelation,
|
|
336
|
+
groupedRedirect: groupedRedirectContext,
|
|
337
|
+
});
|
|
315
338
|
}
|
|
316
339
|
input = applyLimitOffset(input, stmt, selectContext, aggregateProjectionScope);
|
|
317
340
|
}
|
|
341
|
+
// Boundary check over the finished plan of a GROUPED query: nothing above the
|
|
342
|
+
// AggregateNode may still reference a pre-grouping column, which is the invariant
|
|
343
|
+
// docs/runtime.md § "Corollary: a published source row reaches only the adjacent
|
|
344
|
+
// consumer" states. A post-aggregate builder that skipped redirectPostAggregate now
|
|
345
|
+
// fails here, at plan time, with the user-facing GROUP BY message — instead of
|
|
346
|
+
// shipping a plan that dies at run time with an internal "No row context found"
|
|
347
|
+
// error once a buffering operator separates it from the aggregate (how both the
|
|
348
|
+
// SELECT-list and ORDER BY escapes shipped).
|
|
349
|
+
//
|
|
350
|
+
// NOTE: deliberately STRICT — this also rejects a query that genuinely reads an
|
|
351
|
+
// ungrouped column above the aggregate (`select a from wg group by a order by b`,
|
|
352
|
+
// or a correlated subquery reading an ungrouped column), which previously ran and
|
|
353
|
+
// read an arbitrary representative row of each group. That was a wrong-result bug,
|
|
354
|
+
// no test asserted it (measured across the full engine suite: zero hand-written
|
|
355
|
+
// occurrences; 18 fuzz-generated sort keys, all in error-tolerant harnesses), and
|
|
356
|
+
// rejecting it matches what the SELECT list and HAVING already do. Revisit only if
|
|
357
|
+
// SQLite-style bare-column ORDER BY tolerance becomes a compatibility requirement;
|
|
358
|
+
// the weaker alternative is checking only above buffering operators (WindowNode),
|
|
359
|
+
// where the representative source row genuinely dies.
|
|
360
|
+
if (groupedRedirectContext && aggregateResult.aggregateNode) {
|
|
361
|
+
assertGroupedPlanCoverage(input, aggregateResult.aggregateNode, groupedRedirectContext);
|
|
362
|
+
}
|
|
318
363
|
return input;
|
|
319
364
|
}
|
|
320
365
|
/**
|