@quereus/quereus 0.2.0 → 0.4.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 +12 -1
- package/dist/src/common/errors.js.map +1 -1
- package/dist/src/common/json-types.d.ts +11 -0
- package/dist/src/common/json-types.d.ts.map +1 -0
- package/dist/src/common/json-types.js +3 -0
- package/dist/src/common/json-types.js.map +1 -0
- package/dist/src/common/types.d.ts +2 -0
- package/dist/src/common/types.d.ts.map +1 -1
- package/dist/src/core/database-options.d.ts +2 -2
- package/dist/src/core/database-options.d.ts.map +1 -1
- package/dist/src/core/database-options.js.map +1 -1
- package/dist/src/core/database.d.ts +61 -14
- package/dist/src/core/database.d.ts.map +1 -1
- package/dist/src/core/database.js +481 -54
- package/dist/src/core/database.js.map +1 -1
- package/dist/src/core/statement.d.ts.map +1 -1
- package/dist/src/core/statement.js +3 -1
- package/dist/src/core/statement.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.map +1 -1
- package/dist/src/func/builtins/datetime.d.ts +2 -0
- package/dist/src/func/builtins/datetime.d.ts.map +1 -1
- package/dist/src/func/builtins/datetime.js +39 -0
- package/dist/src/func/builtins/datetime.js.map +1 -1
- package/dist/src/func/builtins/explain.d.ts +1 -0
- package/dist/src/func/builtins/explain.d.ts.map +1 -1
- package/dist/src/func/builtins/explain.js +159 -36
- package/dist/src/func/builtins/explain.js.map +1 -1
- package/dist/src/func/builtins/index.d.ts.map +1 -1
- package/dist/src/func/builtins/index.js +5 -2
- package/dist/src/func/builtins/index.js.map +1 -1
- package/dist/src/func/builtins/json-helpers.d.ts +8 -8
- package/dist/src/func/builtins/json-helpers.d.ts.map +1 -1
- package/dist/src/func/builtins/json-helpers.js +3 -3
- package/dist/src/func/builtins/json-helpers.js.map +1 -1
- package/dist/src/func/builtins/json-tvf.d.ts.map +1 -1
- package/dist/src/func/builtins/json-tvf.js +1 -1
- package/dist/src/func/builtins/json-tvf.js.map +1 -1
- package/dist/src/func/builtins/json.d.ts.map +1 -1
- package/dist/src/func/builtins/json.js +3 -2
- package/dist/src/func/builtins/json.js.map +1 -1
- package/dist/src/func/builtins/schema.d.ts.map +1 -1
- package/dist/src/func/builtins/schema.js +22 -1
- package/dist/src/func/builtins/schema.js.map +1 -1
- package/dist/src/func/context.d.ts.map +1 -1
- package/dist/src/func/context.js +5 -0
- package/dist/src/func/context.js.map +1 -1
- package/dist/src/func/registration.d.ts +2 -1
- package/dist/src/func/registration.d.ts.map +1 -1
- package/dist/src/func/registration.js.map +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/parser/ast.d.ts +84 -6
- package/dist/src/parser/ast.d.ts.map +1 -1
- package/dist/src/parser/lexer.d.ts +11 -0
- package/dist/src/parser/lexer.d.ts.map +1 -1
- package/dist/src/parser/lexer.js +29 -21
- package/dist/src/parser/lexer.js.map +1 -1
- package/dist/src/parser/parser.d.ts +16 -0
- package/dist/src/parser/parser.d.ts.map +1 -1
- package/dist/src/parser/parser.js +542 -26
- package/dist/src/parser/parser.js.map +1 -1
- package/dist/src/parser/visitor.d.ts.map +1 -1
- package/dist/src/parser/visitor.js +1 -0
- package/dist/src/parser/visitor.js.map +1 -1
- package/dist/src/planner/analysis/binding-collector.d.ts +5 -0
- package/dist/src/planner/analysis/binding-collector.d.ts.map +1 -0
- package/dist/src/planner/analysis/binding-collector.js +73 -0
- package/dist/src/planner/analysis/binding-collector.js.map +1 -0
- package/dist/src/planner/analysis/const-evaluator.js +1 -1
- package/dist/src/planner/analysis/const-evaluator.js.map +1 -1
- package/dist/src/planner/analysis/const-pass.d.ts.map +1 -1
- package/dist/src/planner/analysis/const-pass.js +1 -1
- package/dist/src/planner/analysis/const-pass.js.map +1 -1
- package/dist/src/planner/analysis/constraint-extractor.d.ts +67 -31
- package/dist/src/planner/analysis/constraint-extractor.d.ts.map +1 -1
- package/dist/src/planner/analysis/constraint-extractor.js +513 -84
- package/dist/src/planner/analysis/constraint-extractor.js.map +1 -1
- package/dist/src/planner/analysis/predicate-normalizer.d.ts +17 -0
- package/dist/src/planner/analysis/predicate-normalizer.d.ts.map +1 -0
- package/dist/src/planner/analysis/predicate-normalizer.js +222 -0
- package/dist/src/planner/analysis/predicate-normalizer.js.map +1 -0
- package/dist/src/planner/building/alter-table.d.ts.map +1 -1
- package/dist/src/planner/building/alter-table.js +5 -2
- package/dist/src/planner/building/alter-table.js.map +1 -1
- package/dist/src/planner/building/block.d.ts.map +1 -1
- package/dist/src/planner/building/block.js +16 -0
- package/dist/src/planner/building/block.js.map +1 -1
- package/dist/src/planner/building/constraint-builder.d.ts +2 -2
- package/dist/src/planner/building/constraint-builder.d.ts.map +1 -1
- package/dist/src/planner/building/constraint-builder.js +52 -3
- package/dist/src/planner/building/constraint-builder.js.map +1 -1
- package/dist/src/planner/building/create-assertion.d.ts +5 -0
- package/dist/src/planner/building/create-assertion.d.ts.map +1 -0
- package/dist/src/planner/building/create-assertion.js +5 -0
- package/dist/src/planner/building/create-assertion.js.map +1 -0
- package/dist/src/planner/building/declare-schema.d.ts +8 -0
- package/dist/src/planner/building/declare-schema.d.ts.map +1 -0
- package/dist/src/planner/building/declare-schema.js +14 -0
- package/dist/src/planner/building/declare-schema.js.map +1 -0
- package/dist/src/planner/building/delete.d.ts.map +1 -1
- package/dist/src/planner/building/delete.js +38 -6
- package/dist/src/planner/building/delete.js.map +1 -1
- package/dist/src/planner/building/drop-assertion.d.ts +5 -0
- package/dist/src/planner/building/drop-assertion.d.ts.map +1 -0
- package/dist/src/planner/building/drop-assertion.js +8 -0
- package/dist/src/planner/building/drop-assertion.js.map +1 -0
- package/dist/src/planner/building/expression.d.ts.map +1 -1
- package/dist/src/planner/building/expression.js +1 -0
- package/dist/src/planner/building/expression.js.map +1 -1
- package/dist/src/planner/building/function-call.d.ts.map +1 -1
- package/dist/src/planner/building/function-call.js +2 -1
- 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 +68 -11
- package/dist/src/planner/building/insert.js.map +1 -1
- package/dist/src/planner/building/pragma.d.ts.map +1 -1
- package/dist/src/planner/building/pragma.js +1 -0
- package/dist/src/planner/building/pragma.js.map +1 -1
- package/dist/src/planner/building/schema-resolution.d.ts +2 -2
- package/dist/src/planner/building/schema-resolution.d.ts.map +1 -1
- package/dist/src/planner/building/select-aggregates.d.ts.map +1 -1
- package/dist/src/planner/building/select-aggregates.js +3 -2
- package/dist/src/planner/building/select-aggregates.js.map +1 -1
- package/dist/src/planner/building/select-compound.d.ts +2 -2
- package/dist/src/planner/building/select-compound.d.ts.map +1 -1
- package/dist/src/planner/building/select-compound.js +10 -1
- package/dist/src/planner/building/select-compound.js.map +1 -1
- package/dist/src/planner/building/select-context.d.ts +3 -3
- package/dist/src/planner/building/select-context.d.ts.map +1 -1
- package/dist/src/planner/building/select-context.js.map +1 -1
- package/dist/src/planner/building/select-modifiers.d.ts +6 -5
- package/dist/src/planner/building/select-modifiers.d.ts.map +1 -1
- package/dist/src/planner/building/select-modifiers.js +5 -4
- package/dist/src/planner/building/select-modifiers.js.map +1 -1
- package/dist/src/planner/building/select-projections.d.ts.map +1 -1
- package/dist/src/planner/building/select-projections.js +4 -5
- package/dist/src/planner/building/select-projections.js.map +1 -1
- package/dist/src/planner/building/select-window.d.ts.map +1 -1
- package/dist/src/planner/building/select-window.js +6 -3
- package/dist/src/planner/building/select-window.js.map +1 -1
- package/dist/src/planner/building/select.d.ts +3 -3
- package/dist/src/planner/building/select.d.ts.map +1 -1
- package/dist/src/planner/building/select.js +18 -8
- package/dist/src/planner/building/select.js.map +1 -1
- package/dist/src/planner/building/table-function.d.ts.map +1 -1
- package/dist/src/planner/building/table-function.js +1 -1
- package/dist/src/planner/building/table-function.js.map +1 -1
- package/dist/src/planner/building/table.d.ts +5 -3
- package/dist/src/planner/building/table.d.ts.map +1 -1
- package/dist/src/planner/building/table.js +7 -2
- package/dist/src/planner/building/table.js.map +1 -1
- package/dist/src/planner/building/update.d.ts.map +1 -1
- package/dist/src/planner/building/update.js +39 -7
- package/dist/src/planner/building/update.js.map +1 -1
- package/dist/src/planner/building/with.d.ts +3 -3
- package/dist/src/planner/building/with.d.ts.map +1 -1
- package/dist/src/planner/building/with.js.map +1 -1
- package/dist/src/planner/debug.d.ts.map +1 -1
- package/dist/src/planner/debug.js.map +1 -1
- package/dist/src/planner/framework/characteristics.d.ts +235 -0
- package/dist/src/planner/framework/characteristics.d.ts.map +1 -0
- package/dist/src/planner/framework/characteristics.js +299 -0
- package/dist/src/planner/framework/characteristics.js.map +1 -0
- package/dist/src/planner/framework/context.d.ts +16 -5
- package/dist/src/planner/framework/context.d.ts.map +1 -1
- package/dist/src/planner/framework/context.js +2 -0
- package/dist/src/planner/framework/context.js.map +1 -1
- package/dist/src/planner/framework/pass.d.ts +116 -0
- package/dist/src/planner/framework/pass.d.ts.map +1 -0
- package/dist/src/planner/framework/pass.js +236 -0
- package/dist/src/planner/framework/pass.js.map +1 -0
- package/dist/src/planner/nodes/aggregate-node.d.ts +16 -6
- package/dist/src/planner/nodes/aggregate-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/aggregate-node.js +40 -4
- package/dist/src/planner/nodes/aggregate-node.js.map +1 -1
- package/dist/src/planner/nodes/array-index-node.js.map +1 -1
- package/dist/src/planner/nodes/cache-node.d.ts +5 -2
- package/dist/src/planner/nodes/cache-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/cache-node.js +6 -0
- package/dist/src/planner/nodes/cache-node.js.map +1 -1
- package/dist/src/planner/nodes/constraint-check-node.d.ts +12 -4
- package/dist/src/planner/nodes/constraint-check-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/constraint-check-node.js +12 -4
- package/dist/src/planner/nodes/constraint-check-node.js.map +1 -1
- package/dist/src/planner/nodes/create-assertion-node.d.ts +22 -0
- package/dist/src/planner/nodes/create-assertion-node.d.ts.map +1 -0
- package/dist/src/planner/nodes/create-assertion-node.js +41 -0
- package/dist/src/planner/nodes/create-assertion-node.js.map +1 -0
- package/dist/src/planner/nodes/create-index-node.js +2 -2
- package/dist/src/planner/nodes/create-index-node.js.map +1 -1
- package/dist/src/planner/nodes/create-table-node.js +2 -2
- package/dist/src/planner/nodes/create-table-node.js.map +1 -1
- package/dist/src/planner/nodes/cte-node.d.ts +17 -2
- package/dist/src/planner/nodes/cte-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/cte-node.js +9 -1
- package/dist/src/planner/nodes/cte-node.js.map +1 -1
- package/dist/src/planner/nodes/cte-reference-node.js +1 -1
- package/dist/src/planner/nodes/cte-reference-node.js.map +1 -1
- package/dist/src/planner/nodes/declarative-schema.d.ts +62 -0
- package/dist/src/planner/nodes/declarative-schema.d.ts.map +1 -0
- package/dist/src/planner/nodes/declarative-schema.js +181 -0
- package/dist/src/planner/nodes/declarative-schema.js.map +1 -0
- package/dist/src/planner/nodes/delete-node.d.ts +8 -3
- package/dist/src/planner/nodes/delete-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/delete-node.js +10 -2
- package/dist/src/planner/nodes/delete-node.js.map +1 -1
- package/dist/src/planner/nodes/distinct-node.d.ts +3 -2
- package/dist/src/planner/nodes/distinct-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/distinct-node.js +17 -4
- package/dist/src/planner/nodes/distinct-node.js.map +1 -1
- package/dist/src/planner/nodes/dml-executor-node.d.ts +2 -2
- package/dist/src/planner/nodes/dml-executor-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/drop-assertion-node.d.ts +21 -0
- package/dist/src/planner/nodes/drop-assertion-node.d.ts.map +1 -0
- package/dist/src/planner/nodes/drop-assertion-node.js +41 -0
- package/dist/src/planner/nodes/drop-assertion-node.js.map +1 -0
- package/dist/src/planner/nodes/drop-table-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/drop-table-node.js +1 -0
- package/dist/src/planner/nodes/drop-table-node.js.map +1 -1
- package/dist/src/planner/nodes/filter.d.ts +8 -3
- package/dist/src/planner/nodes/filter.d.ts.map +1 -1
- package/dist/src/planner/nodes/filter.js +44 -0
- package/dist/src/planner/nodes/filter.js.map +1 -1
- package/dist/src/planner/nodes/insert-node.d.ts +9 -3
- package/dist/src/planner/nodes/insert-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/insert-node.js +11 -2
- package/dist/src/planner/nodes/insert-node.js.map +1 -1
- package/dist/src/planner/nodes/internal-recursive-cte-ref-node.d.ts +3 -4
- package/dist/src/planner/nodes/internal-recursive-cte-ref-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/internal-recursive-cte-ref-node.js +1 -16
- package/dist/src/planner/nodes/internal-recursive-cte-ref-node.js.map +1 -1
- package/dist/src/planner/nodes/join-node.d.ts +12 -3
- package/dist/src/planner/nodes/join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/join-node.js +111 -2
- package/dist/src/planner/nodes/join-node.js.map +1 -1
- package/dist/src/planner/nodes/limit-offset.d.ts +7 -3
- package/dist/src/planner/nodes/limit-offset.d.ts.map +1 -1
- package/dist/src/planner/nodes/limit-offset.js +15 -0
- package/dist/src/planner/nodes/limit-offset.js.map +1 -1
- package/dist/src/planner/nodes/plan-node-type.d.ts +8 -0
- package/dist/src/planner/nodes/plan-node-type.d.ts.map +1 -1
- package/dist/src/planner/nodes/plan-node-type.js +8 -0
- package/dist/src/planner/nodes/plan-node-type.js.map +1 -1
- package/dist/src/planner/nodes/plan-node.d.ts +9 -9
- package/dist/src/planner/nodes/plan-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/plan-node.js +3 -3
- package/dist/src/planner/nodes/plan-node.js.map +1 -1
- package/dist/src/planner/nodes/pragma.d.ts +2 -1
- package/dist/src/planner/nodes/pragma.d.ts.map +1 -1
- package/dist/src/planner/nodes/pragma.js +3 -1
- package/dist/src/planner/nodes/pragma.js.map +1 -1
- package/dist/src/planner/nodes/project-node.d.ts +16 -3
- package/dist/src/planner/nodes/project-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/project-node.js +82 -2
- package/dist/src/planner/nodes/project-node.js.map +1 -1
- package/dist/src/planner/nodes/recursive-cte-node.d.ts +2 -2
- package/dist/src/planner/nodes/recursive-cte-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/recursive-cte-node.js +1 -1
- package/dist/src/planner/nodes/recursive-cte-node.js.map +1 -1
- package/dist/src/planner/nodes/reference.d.ts +13 -4
- package/dist/src/planner/nodes/reference.d.ts.map +1 -1
- package/dist/src/planner/nodes/reference.js +16 -0
- package/dist/src/planner/nodes/reference.js.map +1 -1
- package/dist/src/planner/nodes/remote-query-node.d.ts +37 -0
- package/dist/src/planner/nodes/remote-query-node.d.ts.map +1 -0
- package/dist/src/planner/nodes/remote-query-node.js +63 -0
- package/dist/src/planner/nodes/remote-query-node.js.map +1 -0
- package/dist/src/planner/nodes/retrieve-node.d.ts +46 -0
- package/dist/src/planner/nodes/retrieve-node.d.ts.map +1 -0
- package/dist/src/planner/nodes/retrieve-node.js +77 -0
- package/dist/src/planner/nodes/retrieve-node.js.map +1 -0
- package/dist/src/planner/nodes/returning-node.d.ts +4 -3
- package/dist/src/planner/nodes/returning-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/returning-node.js +44 -3
- package/dist/src/planner/nodes/returning-node.js.map +1 -1
- package/dist/src/planner/nodes/sequencing-node.d.ts +1 -1
- package/dist/src/planner/nodes/sequencing-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/sequencing-node.js.map +1 -1
- package/dist/src/planner/nodes/set-operation-node.d.ts +1 -1
- package/dist/src/planner/nodes/set-operation-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/set-operation-node.js.map +1 -1
- package/dist/src/planner/nodes/sort.d.ts +11 -2
- package/dist/src/planner/nodes/sort.d.ts.map +1 -1
- package/dist/src/planner/nodes/sort.js +23 -2
- package/dist/src/planner/nodes/sort.js.map +1 -1
- package/dist/src/planner/nodes/stream-aggregate.d.ts.map +1 -1
- package/dist/src/planner/nodes/stream-aggregate.js +4 -1
- package/dist/src/planner/nodes/stream-aggregate.js.map +1 -1
- package/dist/src/planner/nodes/table-access-nodes.d.ts +7 -1
- package/dist/src/planner/nodes/table-access-nodes.d.ts.map +1 -1
- package/dist/src/planner/nodes/table-access-nodes.js +22 -4
- package/dist/src/planner/nodes/table-access-nodes.js.map +1 -1
- package/dist/src/planner/nodes/table-function-call.d.ts +2 -1
- package/dist/src/planner/nodes/table-function-call.d.ts.map +1 -1
- package/dist/src/planner/nodes/table-function-call.js +12 -5
- package/dist/src/planner/nodes/table-function-call.js.map +1 -1
- package/dist/src/planner/nodes/transaction-node.js +2 -2
- package/dist/src/planner/nodes/transaction-node.js.map +1 -1
- package/dist/src/planner/nodes/update-node.d.ts +7 -1
- package/dist/src/planner/nodes/update-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/update-node.js +11 -2
- package/dist/src/planner/nodes/update-node.js.map +1 -1
- package/dist/src/planner/nodes/view-reference-node.js.map +1 -1
- package/dist/src/planner/nodes/window-function.js.map +1 -1
- package/dist/src/planner/nodes/window-node.js.map +1 -1
- package/dist/src/planner/optimizer-tuning.d.ts +11 -0
- package/dist/src/planner/optimizer-tuning.d.ts.map +1 -1
- package/dist/src/planner/optimizer-tuning.js +6 -0
- package/dist/src/planner/optimizer-tuning.js.map +1 -1
- package/dist/src/planner/optimizer.d.ts +17 -3
- package/dist/src/planner/optimizer.d.ts.map +1 -1
- package/dist/src/planner/optimizer.js +159 -67
- package/dist/src/planner/optimizer.js.map +1 -1
- package/dist/src/planner/planning-context.d.ts +5 -3
- package/dist/src/planner/planning-context.d.ts.map +1 -1
- package/dist/src/planner/planning-context.js +2 -0
- package/dist/src/planner/planning-context.js.map +1 -1
- package/dist/src/planner/resolve.d.ts +3 -2
- package/dist/src/planner/resolve.d.ts.map +1 -1
- package/dist/src/planner/resolve.js +6 -5
- package/dist/src/planner/resolve.js.map +1 -1
- package/dist/src/planner/rules/access/rule-select-access-path.d.ts +8 -3
- 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 +206 -47
- package/dist/src/planner/rules/access/rule-select-access-path.js.map +1 -1
- package/dist/src/planner/rules/aggregate/rule-aggregate-streaming.d.ts +10 -3
- package/dist/src/planner/rules/aggregate/rule-aggregate-streaming.d.ts.map +1 -1
- package/dist/src/planner/rules/aggregate/rule-aggregate-streaming.js +95 -87
- package/dist/src/planner/rules/aggregate/rule-aggregate-streaming.js.map +1 -1
- package/dist/src/planner/rules/cache/rule-cte-optimization.d.ts +8 -2
- package/dist/src/planner/rules/cache/rule-cte-optimization.d.ts.map +1 -1
- package/dist/src/planner/rules/cache/rule-cte-optimization.js +24 -13
- package/dist/src/planner/rules/cache/rule-cte-optimization.js.map +1 -1
- package/dist/src/planner/rules/cache/rule-materialization-advisory.d.ts +9 -2
- package/dist/src/planner/rules/cache/rule-materialization-advisory.d.ts.map +1 -1
- package/dist/src/planner/rules/cache/rule-materialization-advisory.js +14 -7
- package/dist/src/planner/rules/cache/rule-materialization-advisory.js.map +1 -1
- package/dist/src/planner/rules/cache/rule-mutating-subquery-cache.d.ts +9 -3
- package/dist/src/planner/rules/cache/rule-mutating-subquery-cache.d.ts.map +1 -1
- package/dist/src/planner/rules/cache/rule-mutating-subquery-cache.js +34 -37
- package/dist/src/planner/rules/cache/rule-mutating-subquery-cache.js.map +1 -1
- package/dist/src/planner/rules/join/rule-join-greedy-commute.d.ts +14 -0
- package/dist/src/planner/rules/join/rule-join-greedy-commute.d.ts.map +1 -0
- package/dist/src/planner/rules/join/rule-join-greedy-commute.js +33 -0
- package/dist/src/planner/rules/join/rule-join-greedy-commute.js.map +1 -0
- package/dist/src/planner/rules/join/rule-join-key-inference.d.ts +11 -0
- package/dist/src/planner/rules/join/rule-join-key-inference.d.ts.map +1 -0
- package/dist/src/planner/rules/join/rule-join-key-inference.js +32 -0
- package/dist/src/planner/rules/join/rule-join-key-inference.js.map +1 -0
- package/dist/src/planner/rules/join/rule-quickpick-enumeration.d.ts +4 -0
- package/dist/src/planner/rules/join/rule-quickpick-enumeration.d.ts.map +1 -0
- package/dist/src/planner/rules/join/rule-quickpick-enumeration.js +233 -0
- package/dist/src/planner/rules/join/rule-quickpick-enumeration.js.map +1 -0
- package/dist/src/planner/rules/predicate/rule-predicate-pushdown.d.ts +21 -0
- package/dist/src/planner/rules/predicate/rule-predicate-pushdown.d.ts.map +1 -0
- package/dist/src/planner/rules/predicate/rule-predicate-pushdown.js +125 -0
- package/dist/src/planner/rules/predicate/rule-predicate-pushdown.js.map +1 -0
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.d.ts +21 -0
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.d.ts.map +1 -0
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js +261 -0
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js.map +1 -0
- package/dist/src/planner/scopes/registered.d.ts +1 -0
- package/dist/src/planner/scopes/registered.d.ts.map +1 -1
- package/dist/src/planner/scopes/registered.js +7 -0
- package/dist/src/planner/scopes/registered.js.map +1 -1
- package/dist/src/planner/stats/index.d.ts +0 -17
- package/dist/src/planner/stats/index.d.ts.map +1 -1
- package/dist/src/planner/stats/index.js +0 -58
- package/dist/src/planner/stats/index.js.map +1 -1
- package/dist/src/planner/util/deferred-constraint.d.ts +14 -0
- package/dist/src/planner/util/deferred-constraint.d.ts.map +1 -0
- package/dist/src/planner/util/deferred-constraint.js +85 -0
- package/dist/src/planner/util/deferred-constraint.js.map +1 -0
- package/dist/src/planner/util/key-utils.d.ts +15 -0
- package/dist/src/planner/util/key-utils.d.ts.map +1 -0
- package/dist/src/planner/util/key-utils.js +43 -0
- package/dist/src/planner/util/key-utils.js.map +1 -0
- package/dist/src/planner/validation/plan-validator.d.ts.map +1 -1
- package/dist/src/planner/validation/plan-validator.js +1 -0
- package/dist/src/planner/validation/plan-validator.js.map +1 -1
- package/dist/src/runtime/deferred-constraint-queue.d.ts +33 -0
- package/dist/src/runtime/deferred-constraint-queue.d.ts.map +1 -0
- package/dist/src/runtime/deferred-constraint-queue.js +172 -0
- package/dist/src/runtime/deferred-constraint-queue.js.map +1 -0
- package/dist/src/runtime/emission-context.d.ts +9 -3
- package/dist/src/runtime/emission-context.d.ts.map +1 -1
- package/dist/src/runtime/emission-context.js +5 -1
- package/dist/src/runtime/emission-context.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 -4
- package/dist/src/runtime/emit/add-constraint.js.map +1 -1
- package/dist/src/runtime/emit/aggregate.d.ts.map +1 -1
- package/dist/src/runtime/emit/aggregate.js +3 -2
- package/dist/src/runtime/emit/aggregate.js.map +1 -1
- package/dist/src/runtime/emit/array-index.js.map +1 -1
- package/dist/src/runtime/emit/binary.d.ts.map +1 -1
- package/dist/src/runtime/emit/binary.js +9 -2
- package/dist/src/runtime/emit/binary.js.map +1 -1
- package/dist/src/runtime/emit/cache.d.ts.map +1 -1
- package/dist/src/runtime/emit/cache.js +1 -1
- package/dist/src/runtime/emit/cache.js.map +1 -1
- package/dist/src/runtime/emit/cast.d.ts.map +1 -1
- package/dist/src/runtime/emit/cast.js.map +1 -1
- package/dist/src/runtime/emit/constraint-check.d.ts.map +1 -1
- package/dist/src/runtime/emit/constraint-check.js +112 -25
- package/dist/src/runtime/emit/constraint-check.js.map +1 -1
- package/dist/src/runtime/emit/create-assertion.d.ts +5 -0
- package/dist/src/runtime/emit/create-assertion.d.ts.map +1 -0
- package/dist/src/runtime/emit/create-assertion.js +70 -0
- package/dist/src/runtime/emit/create-assertion.js.map +1 -0
- package/dist/src/runtime/emit/cte-reference.d.ts.map +1 -1
- package/dist/src/runtime/emit/cte-reference.js.map +1 -1
- package/dist/src/runtime/emit/cte.d.ts.map +1 -1
- package/dist/src/runtime/emit/cte.js.map +1 -1
- package/dist/src/runtime/emit/distinct.d.ts.map +1 -1
- package/dist/src/runtime/emit/distinct.js.map +1 -1
- package/dist/src/runtime/emit/dml-executor.d.ts.map +1 -1
- package/dist/src/runtime/emit/dml-executor.js +17 -9
- package/dist/src/runtime/emit/dml-executor.js.map +1 -1
- package/dist/src/runtime/emit/drop-assertion.d.ts +5 -0
- package/dist/src/runtime/emit/drop-assertion.d.ts.map +1 -0
- package/dist/src/runtime/emit/drop-assertion.js +30 -0
- package/dist/src/runtime/emit/drop-assertion.js.map +1 -0
- package/dist/src/runtime/emit/filter.d.ts.map +1 -1
- package/dist/src/runtime/emit/filter.js.map +1 -1
- package/dist/src/runtime/emit/join.d.ts.map +1 -1
- package/dist/src/runtime/emit/join.js.map +1 -1
- package/dist/src/runtime/emit/limit-offset.d.ts.map +1 -1
- package/dist/src/runtime/emit/limit-offset.js.map +1 -1
- package/dist/src/runtime/emit/pragma.js.map +1 -1
- package/dist/src/runtime/emit/project.d.ts.map +1 -1
- package/dist/src/runtime/emit/project.js.map +1 -1
- package/dist/src/runtime/emit/recursive-cte.d.ts.map +1 -1
- package/dist/src/runtime/emit/recursive-cte.js +1 -1
- package/dist/src/runtime/emit/recursive-cte.js.map +1 -1
- package/dist/src/runtime/emit/remote-query.d.ts +9 -0
- package/dist/src/runtime/emit/remote-query.d.ts.map +1 -0
- package/dist/src/runtime/emit/remote-query.js +30 -0
- package/dist/src/runtime/emit/remote-query.js.map +1 -0
- package/dist/src/runtime/emit/retrieve.d.ts +5 -0
- package/dist/src/runtime/emit/retrieve.d.ts.map +1 -0
- package/dist/src/runtime/emit/retrieve.js +9 -0
- package/dist/src/runtime/emit/retrieve.js.map +1 -0
- package/dist/src/runtime/emit/returning.d.ts.map +1 -1
- package/dist/src/runtime/emit/returning.js +1 -1
- package/dist/src/runtime/emit/returning.js.map +1 -1
- package/dist/src/runtime/emit/scalar-function.d.ts.map +1 -1
- package/dist/src/runtime/emit/scalar-function.js.map +1 -1
- package/dist/src/runtime/emit/scan.d.ts.map +1 -1
- package/dist/src/runtime/emit/scan.js +20 -5
- package/dist/src/runtime/emit/scan.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 -0
- package/dist/src/runtime/emit/schema-declarative.js +163 -0
- package/dist/src/runtime/emit/schema-declarative.js.map +1 -0
- package/dist/src/runtime/emit/sequencing.d.ts.map +1 -1
- package/dist/src/runtime/emit/sequencing.js.map +1 -1
- package/dist/src/runtime/emit/set-operation.d.ts.map +1 -1
- package/dist/src/runtime/emit/set-operation.js +6 -6
- package/dist/src/runtime/emit/set-operation.js.map +1 -1
- package/dist/src/runtime/emit/sort.d.ts.map +1 -1
- package/dist/src/runtime/emit/sort.js.map +1 -1
- package/dist/src/runtime/emit/subquery.d.ts +1 -1
- package/dist/src/runtime/emit/subquery.d.ts.map +1 -1
- package/dist/src/runtime/emit/subquery.js +6 -6
- package/dist/src/runtime/emit/subquery.js.map +1 -1
- package/dist/src/runtime/emit/transaction.d.ts.map +1 -1
- package/dist/src/runtime/emit/transaction.js +48 -8
- package/dist/src/runtime/emit/transaction.js.map +1 -1
- package/dist/src/runtime/emit/values.d.ts.map +1 -1
- package/dist/src/runtime/emit/values.js.map +1 -1
- package/dist/src/runtime/emit/window.d.ts.map +1 -1
- package/dist/src/runtime/emit/window.js.map +1 -1
- package/dist/src/runtime/emitters.d.ts.map +1 -1
- package/dist/src/runtime/emitters.js +1 -0
- package/dist/src/runtime/emitters.js.map +1 -1
- package/dist/src/runtime/register.d.ts.map +1 -1
- package/dist/src/runtime/register.js +16 -2
- package/dist/src/runtime/register.js.map +1 -1
- package/dist/src/runtime/scheduler.js.map +1 -1
- package/dist/src/runtime/types.d.ts +2 -2
- package/dist/src/runtime/types.d.ts.map +1 -1
- package/dist/src/runtime/types.js +4 -1
- package/dist/src/runtime/types.js.map +1 -1
- package/dist/src/runtime/utils.d.ts +2 -2
- package/dist/src/runtime/utils.d.ts.map +1 -1
- package/dist/src/runtime/utils.js +1 -0
- package/dist/src/runtime/utils.js.map +1 -1
- package/dist/src/schema/assertion.d.ts +19 -0
- package/dist/src/schema/assertion.d.ts.map +1 -0
- package/dist/src/schema/assertion.js +2 -0
- package/dist/src/schema/assertion.js.map +1 -0
- package/dist/src/schema/catalog.d.ts +44 -0
- package/dist/src/schema/catalog.d.ts.map +1 -0
- package/dist/src/schema/catalog.js +148 -0
- package/dist/src/schema/catalog.js.map +1 -0
- package/dist/src/schema/change-events.d.ts +2 -2
- package/dist/src/schema/change-events.d.ts.map +1 -1
- package/dist/src/schema/column.d.ts +2 -0
- package/dist/src/schema/column.d.ts.map +1 -1
- package/dist/src/schema/column.js.map +1 -1
- package/dist/src/schema/declared-schema-manager.d.ts +42 -0
- package/dist/src/schema/declared-schema-manager.d.ts.map +1 -0
- package/dist/src/schema/declared-schema-manager.js +71 -0
- package/dist/src/schema/declared-schema-manager.js.map +1 -0
- package/dist/src/schema/function.d.ts +3 -2
- package/dist/src/schema/function.d.ts.map +1 -1
- package/dist/src/schema/function.js.map +1 -1
- package/dist/src/schema/manager.d.ts +8 -3
- package/dist/src/schema/manager.d.ts.map +1 -1
- package/dist/src/schema/manager.js +32 -3
- package/dist/src/schema/manager.js.map +1 -1
- package/dist/src/schema/schema-differ.d.ts +34 -0
- package/dist/src/schema/schema-differ.d.ts.map +1 -0
- package/dist/src/schema/schema-differ.js +157 -0
- package/dist/src/schema/schema-differ.js.map +1 -0
- package/dist/src/schema/schema-hasher.d.ts +10 -0
- package/dist/src/schema/schema-hasher.d.ts.map +1 -0
- package/dist/src/schema/schema-hasher.js +39 -0
- package/dist/src/schema/schema-hasher.js.map +1 -0
- package/dist/src/schema/schema.d.ts +7 -0
- package/dist/src/schema/schema.d.ts.map +1 -1
- package/dist/src/schema/schema.js +19 -0
- package/dist/src/schema/schema.js.map +1 -1
- package/dist/src/schema/table.d.ts +31 -6
- package/dist/src/schema/table.d.ts.map +1 -1
- package/dist/src/schema/table.js +27 -12
- package/dist/src/schema/table.js.map +1 -1
- package/dist/src/schema/window-function.d.ts.map +1 -1
- package/dist/src/schema/window-function.js.map +1 -1
- package/dist/src/util/ast-stringify.d.ts.map +1 -1
- package/dist/src/util/ast-stringify.js +116 -3
- package/dist/src/util/ast-stringify.js.map +1 -1
- package/dist/src/util/environment.js.map +1 -1
- package/dist/src/util/plugin-loader.d.ts +25 -0
- package/dist/src/util/plugin-loader.d.ts.map +1 -1
- package/dist/src/util/plugin-loader.js +137 -0
- package/dist/src/util/plugin-loader.js.map +1 -1
- package/dist/src/util/row-descriptor.d.ts +1 -1
- package/dist/src/util/row-descriptor.d.ts.map +1 -1
- package/dist/src/util/row-descriptor.js.map +1 -1
- package/dist/src/util/serialization.d.ts +3 -0
- package/dist/src/util/serialization.d.ts.map +1 -1
- package/dist/src/util/serialization.js +1 -0
- package/dist/src/util/serialization.js.map +1 -1
- package/dist/src/vtab/best-access-plan.d.ts +1 -1
- package/dist/src/vtab/best-access-plan.d.ts.map +1 -1
- package/dist/src/vtab/best-access-plan.js +1 -0
- package/dist/src/vtab/best-access-plan.js.map +1 -1
- package/dist/src/vtab/manifest.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/base.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/base.js +2 -0
- package/dist/src/vtab/memory/layer/base.js.map +1 -1
- package/dist/src/vtab/memory/layer/manager.d.ts +2 -1
- package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/manager.js +24 -6
- package/dist/src/vtab/memory/layer/manager.js.map +1 -1
- package/dist/src/vtab/memory/layer/safe-iterate.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/safe-iterate.js.map +1 -1
- package/dist/src/vtab/memory/module.d.ts.map +1 -1
- package/dist/src/vtab/memory/module.js +5 -0
- package/dist/src/vtab/memory/module.js.map +1 -1
- package/dist/src/vtab/memory/table.d.ts +2 -1
- package/dist/src/vtab/memory/table.d.ts.map +1 -1
- package/dist/src/vtab/memory/table.js +3 -2
- package/dist/src/vtab/memory/table.js.map +1 -1
- package/dist/src/vtab/memory/utils/logging.d.ts +2 -2
- package/dist/src/vtab/memory/utils/logging.d.ts.map +1 -1
- package/dist/src/vtab/memory/utils/logging.js +6 -3
- package/dist/src/vtab/memory/utils/logging.js.map +1 -1
- package/dist/src/vtab/module.d.ts +25 -0
- package/dist/src/vtab/module.d.ts.map +1 -1
- package/dist/src/vtab/table.d.ts +18 -5
- package/dist/src/vtab/table.d.ts.map +1 -1
- package/dist/src/vtab/table.js.map +1 -1
- package/package.json +5 -3
- package/src/common/errors.ts +1 -1
- package/src/common/json-types.ts +16 -0
- package/src/common/types.ts +3 -0
- package/src/core/database-options.ts +8 -8
- package/src/core/database.ts +537 -71
- package/src/core/statement.ts +3 -1
- package/src/func/builtins/builtin-window-functions.ts +11 -10
- package/src/func/builtins/datetime.ts +42 -0
- package/src/func/builtins/explain.ts +186 -44
- package/src/func/builtins/index.ts +5 -2
- package/src/func/builtins/json-helpers.ts +21 -21
- package/src/func/builtins/json-tvf.ts +8 -9
- package/src/func/builtins/json.ts +10 -9
- package/src/func/builtins/schema.ts +24 -4
- package/src/func/context.ts +7 -0
- package/src/func/registration.ts +5 -1
- package/src/index.ts +3 -3
- package/src/parser/ast.ts +582 -484
- package/src/parser/lexer.ts +27 -21
- package/src/parser/parser.ts +3336 -2776
- package/src/parser/visitor.ts +1 -0
- package/src/planner/analysis/binding-collector.ts +83 -0
- package/src/planner/analysis/const-evaluator.ts +1 -1
- package/src/planner/analysis/const-pass.ts +3 -2
- package/src/planner/analysis/constraint-extractor.ts +610 -123
- package/src/planner/analysis/predicate-normalizer.ts +237 -0
- package/src/planner/building/alter-table.ts +3 -1
- package/src/planner/building/block.ts +93 -78
- package/src/planner/building/constraint-builder.ts +173 -114
- package/src/planner/building/create-assertion.ts +7 -0
- package/src/planner/building/declare-schema.ts +22 -0
- package/src/planner/building/delete.ts +214 -171
- package/src/planner/building/drop-assertion.ts +11 -0
- package/src/planner/building/expression.ts +1 -0
- package/src/planner/building/function-call.ts +6 -5
- package/src/planner/building/insert.ts +428 -349
- package/src/planner/building/pragma.ts +1 -0
- package/src/planner/building/schema-resolution.ts +176 -176
- package/src/planner/building/select-aggregates.ts +5 -3
- package/src/planner/building/select-compound.ts +22 -13
- package/src/planner/building/select-context.ts +6 -6
- package/src/planner/building/select-modifiers.ts +8 -7
- package/src/planner/building/select-projections.ts +177 -176
- package/src/planner/building/select-window.ts +259 -253
- package/src/planner/building/select.ts +531 -520
- package/src/planner/building/table-function.ts +49 -48
- package/src/planner/building/table.ts +9 -3
- package/src/planner/building/update.ts +319 -270
- package/src/planner/building/with.ts +7 -7
- package/src/planner/debug.ts +1 -0
- package/src/planner/framework/characteristics.ts +503 -0
- package/src/planner/framework/context.ts +23 -6
- package/src/planner/framework/pass.ts +354 -0
- package/src/planner/nodes/aggregate-node.ts +52 -7
- package/src/planner/nodes/array-index-node.ts +1 -1
- package/src/planner/nodes/cache-node.ts +11 -2
- package/src/planner/nodes/constraint-check-node.ts +16 -7
- package/src/planner/nodes/create-assertion-node.ts +51 -0
- package/src/planner/nodes/create-index-node.ts +2 -2
- package/src/planner/nodes/create-table-node.ts +2 -2
- package/src/planner/nodes/cte-node.ts +30 -4
- package/src/planner/nodes/cte-reference-node.ts +2 -2
- package/src/planner/nodes/declarative-schema.ts +221 -0
- package/src/planner/nodes/delete-node.ts +102 -96
- package/src/planner/nodes/distinct-node.ts +20 -6
- package/src/planner/nodes/dml-executor-node.ts +2 -2
- package/src/planner/nodes/drop-assertion-node.ts +50 -0
- package/src/planner/nodes/drop-table-node.ts +1 -0
- package/src/planner/nodes/filter.ts +56 -3
- package/src/planner/nodes/insert-node.ts +126 -120
- package/src/planner/nodes/internal-recursive-cte-ref-node.ts +5 -20
- package/src/planner/nodes/join-node.ts +122 -4
- package/src/planner/nodes/limit-offset.ts +132 -113
- package/src/planner/nodes/plan-node-type.ts +95 -87
- package/src/planner/nodes/plan-node.ts +8 -8
- package/src/planner/nodes/pragma.ts +6 -3
- package/src/planner/nodes/project-node.ts +101 -7
- package/src/planner/nodes/recursive-cte-node.ts +6 -6
- package/src/planner/nodes/reference.ts +334 -312
- package/src/planner/nodes/remote-query-node.ts +73 -0
- package/src/planner/nodes/retrieve-node.ts +86 -0
- package/src/planner/nodes/returning-node.ts +52 -10
- package/src/planner/nodes/sequencing-node.ts +2 -2
- package/src/planner/nodes/set-operation-node.ts +3 -3
- package/src/planner/nodes/sort.ts +33 -4
- package/src/planner/nodes/stream-aggregate.ts +5 -1
- package/src/planner/nodes/table-access-nodes.ts +31 -6
- package/src/planner/nodes/table-function-call.ts +134 -127
- package/src/planner/nodes/transaction-node.ts +2 -2
- package/src/planner/nodes/update-node.ts +138 -132
- package/src/planner/nodes/view-reference-node.ts +1 -1
- package/src/planner/nodes/window-function.ts +2 -2
- package/src/planner/nodes/window-node.ts +1 -1
- package/src/planner/optimizer-tuning.ts +18 -0
- package/src/planner/optimizer.ts +171 -96
- package/src/planner/planning-context.ts +10 -3
- package/src/planner/resolve.ts +10 -9
- package/src/planner/rules/README.md +96 -96
- package/src/planner/rules/access/rule-select-access-path.ts +384 -184
- package/src/planner/rules/aggregate/rule-aggregate-streaming.ts +118 -104
- package/src/planner/rules/cache/rule-cte-optimization.ts +29 -16
- package/src/planner/rules/cache/rule-materialization-advisory.ts +14 -7
- package/src/planner/rules/cache/rule-mutating-subquery-cache.ts +38 -44
- package/src/planner/rules/join/rule-join-greedy-commute.ts +48 -0
- package/src/planner/rules/join/rule-join-key-inference.ts +35 -0
- package/src/planner/rules/join/rule-quickpick-enumeration.ts +267 -0
- package/src/planner/rules/predicate/rule-predicate-pushdown.ts +144 -0
- package/src/planner/rules/retrieve/rule-grow-retrieve.ts +337 -0
- package/src/planner/scopes/registered.ts +8 -0
- package/src/planner/stats/index.ts +0 -65
- package/src/planner/util/key-utils.ts +46 -0
- package/src/planner/validation/plan-validator.ts +5 -3
- package/src/runtime/deferred-constraint-queue.ts +196 -0
- package/src/runtime/emission-context.ts +11 -5
- package/src/runtime/emit/add-constraint.ts +26 -5
- package/src/runtime/emit/aggregate.ts +9 -7
- package/src/runtime/emit/array-index.ts +2 -2
- package/src/runtime/emit/binary.ts +26 -8
- package/src/runtime/emit/cache.ts +2 -2
- package/src/runtime/emit/cast.ts +2 -2
- package/src/runtime/emit/constraint-check.ts +150 -28
- package/src/runtime/emit/create-assertion.ts +82 -0
- package/src/runtime/emit/cte-reference.ts +2 -2
- package/src/runtime/emit/cte.ts +2 -2
- package/src/runtime/emit/distinct.ts +2 -2
- package/src/runtime/emit/dml-executor.ts +20 -12
- package/src/runtime/emit/drop-assertion.ts +45 -0
- package/src/runtime/emit/filter.ts +4 -4
- package/src/runtime/emit/join.ts +8 -7
- package/src/runtime/emit/limit-offset.ts +2 -2
- package/src/runtime/emit/pragma.ts +2 -2
- package/src/runtime/emit/project.ts +2 -2
- package/src/runtime/emit/recursive-cte.ts +2 -2
- package/src/runtime/emit/remote-query.ts +47 -0
- package/src/runtime/emit/retrieve.ts +15 -0
- package/src/runtime/emit/returning.ts +4 -4
- package/src/runtime/emit/scalar-function.ts +2 -2
- package/src/runtime/emit/scan.ts +29 -13
- package/src/runtime/emit/schema-declarative.ts +205 -0
- package/src/runtime/emit/sequencing.ts +3 -3
- package/src/runtime/emit/set-operation.ts +7 -7
- package/src/runtime/emit/sort.ts +2 -2
- package/src/runtime/emit/subquery.ts +10 -10
- package/src/runtime/emit/transaction.ts +46 -8
- package/src/runtime/emit/values.ts +2 -2
- package/src/runtime/emit/window.ts +3 -3
- package/src/runtime/emitters.ts +1 -0
- package/src/runtime/register.ts +150 -135
- package/src/runtime/scheduler.ts +2 -2
- package/src/runtime/types.ts +10 -7
- package/src/runtime/utils.ts +3 -2
- package/src/schema/assertion.ts +21 -0
- package/src/schema/catalog.ts +208 -0
- package/src/schema/change-events.ts +2 -2
- package/src/schema/column.ts +2 -0
- package/src/schema/declared-schema-manager.ts +82 -0
- package/src/schema/function.ts +5 -2
- package/src/schema/manager.ts +742 -709
- package/src/schema/schema-differ.ts +214 -0
- package/src/schema/schema-hasher.ts +44 -0
- package/src/schema/schema.ts +23 -0
- package/src/schema/table.ts +398 -364
- package/src/schema/window-function.ts +2 -0
- package/src/util/ast-stringify.ts +869 -764
- package/src/util/environment.ts +2 -2
- package/src/util/plugin-loader.ts +184 -0
- package/src/util/row-descriptor.ts +1 -1
- package/src/util/serialization.ts +2 -0
- package/src/vtab/best-access-plan.ts +2 -1
- package/src/vtab/manifest.ts +1 -0
- package/src/vtab/memory/index.ts +178 -178
- package/src/vtab/memory/layer/base.ts +275 -273
- package/src/vtab/memory/layer/interface.ts +47 -47
- package/src/vtab/memory/layer/manager.ts +33 -11
- package/src/vtab/memory/layer/safe-iterate.ts +3 -3
- package/src/vtab/memory/layer/transaction.ts +229 -229
- package/src/vtab/memory/module.ts +24 -18
- package/src/vtab/memory/table.ts +256 -253
- package/src/vtab/memory/utils/logging.ts +6 -3
- package/src/vtab/module.ts +170 -140
- package/src/vtab/table.ts +162 -143
|
@@ -17,6 +17,7 @@ export function buildPragmaStmt(ctx: PlanningContext, stmt: AST.PragmaStmt): Pla
|
|
|
17
17
|
} else if (stmt.value.type === 'identifier') {
|
|
18
18
|
value = stmt.value.name;
|
|
19
19
|
} else {
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
21
|
throw new QuereusError(`Unsupported PRAGMA value type: ${(stmt.value as any).type}`, StatusCode.ERROR);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
@@ -1,176 +1,176 @@
|
|
|
1
|
-
import type { PlanningContext, SchemaDependency } from '../planning-context.js';
|
|
2
|
-
import type { TableSchema } from '../../schema/table.js';
|
|
3
|
-
import type { FunctionSchema } from '../../schema/function.js';
|
|
4
|
-
import type {
|
|
5
|
-
import type { CollationFunction } from '../../util/comparison.js';
|
|
6
|
-
import { QuereusError } from '../../common/errors.js';
|
|
7
|
-
import { StatusCode } from '../../common/types.js';
|
|
8
|
-
import { createLogger } from '../../common/logger.js';
|
|
9
|
-
|
|
10
|
-
const log = createLogger('planner:schema-resolution');
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Resolves a table schema at build time and records the dependency.
|
|
14
|
-
*/
|
|
15
|
-
export function resolveTableSchema(
|
|
16
|
-
ctx: PlanningContext,
|
|
17
|
-
tableName: string,
|
|
18
|
-
schemaName?: string
|
|
19
|
-
): TableSchema {
|
|
20
|
-
const resolvedSchemaName = schemaName || ctx.db.schemaManager.getCurrentSchemaName();
|
|
21
|
-
const cacheKey = `table:${resolvedSchemaName}:${tableName}`;
|
|
22
|
-
|
|
23
|
-
// Check cache first
|
|
24
|
-
const cached = ctx.schemaCache.get(cacheKey);
|
|
25
|
-
if (cached) {
|
|
26
|
-
log('Using cached table schema: %s.%s', resolvedSchemaName, tableName);
|
|
27
|
-
return cached as TableSchema;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Resolve table schema
|
|
31
|
-
const tableSchema = ctx.schemaManager.findTable(tableName, resolvedSchemaName);
|
|
32
|
-
if (!tableSchema) {
|
|
33
|
-
throw new QuereusError(
|
|
34
|
-
`Table not found: ${resolvedSchemaName}.${tableName}`,
|
|
35
|
-
StatusCode.ERROR
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Record dependency
|
|
40
|
-
const dependency: SchemaDependency = {
|
|
41
|
-
type: 'table',
|
|
42
|
-
schemaName: tableSchema.schemaName,
|
|
43
|
-
objectName: tableSchema.name
|
|
44
|
-
};
|
|
45
|
-
ctx.schemaDependencies.recordDependency(dependency, tableSchema);
|
|
46
|
-
|
|
47
|
-
// Cache result
|
|
48
|
-
ctx.schemaCache.set(cacheKey, tableSchema);
|
|
49
|
-
|
|
50
|
-
log('Resolved table schema: %s.%s', tableSchema.schemaName, tableSchema.name);
|
|
51
|
-
return tableSchema;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Resolves a function schema at build time and records the dependency.
|
|
56
|
-
*/
|
|
57
|
-
export function resolveFunctionSchema(
|
|
58
|
-
ctx: PlanningContext,
|
|
59
|
-
funcName: string,
|
|
60
|
-
numArgs: number
|
|
61
|
-
): FunctionSchema {
|
|
62
|
-
const cacheKey = `function:${funcName}/${numArgs}`;
|
|
63
|
-
|
|
64
|
-
// Check cache first
|
|
65
|
-
const cached = ctx.schemaCache.get(cacheKey);
|
|
66
|
-
if (cached) {
|
|
67
|
-
log('Using cached function schema: %s/%d', funcName, numArgs);
|
|
68
|
-
return cached as FunctionSchema;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Resolve function schema - try exact match first
|
|
72
|
-
let functionSchema = ctx.schemaManager.findFunction(funcName, numArgs);
|
|
73
|
-
|
|
74
|
-
// If not found, try variable argument function
|
|
75
|
-
if (!functionSchema) {
|
|
76
|
-
functionSchema = ctx.schemaManager.findFunction(funcName, -1);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (!functionSchema) {
|
|
80
|
-
throw new QuereusError(
|
|
81
|
-
`Function not found: ${funcName}/${numArgs}`,
|
|
82
|
-
StatusCode.ERROR
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Record dependency using the actual function's numArgs
|
|
87
|
-
const dependency: SchemaDependency = {
|
|
88
|
-
type: 'function',
|
|
89
|
-
objectName: `${functionSchema.name}/${functionSchema.numArgs}`
|
|
90
|
-
};
|
|
91
|
-
ctx.schemaDependencies.recordDependency(dependency, functionSchema);
|
|
92
|
-
|
|
93
|
-
// Cache result with the requested key for future lookups
|
|
94
|
-
ctx.schemaCache.set(cacheKey, functionSchema);
|
|
95
|
-
|
|
96
|
-
log('Resolved function schema: %s/%d', functionSchema.name, functionSchema.numArgs);
|
|
97
|
-
return functionSchema;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Resolves a virtual table module at build time and records the dependency.
|
|
102
|
-
*/
|
|
103
|
-
export function resolveVtabModule(
|
|
104
|
-
ctx: PlanningContext,
|
|
105
|
-
moduleName: string
|
|
106
|
-
): { module:
|
|
107
|
-
const cacheKey = `vtab_module:${moduleName}`;
|
|
108
|
-
|
|
109
|
-
// Check cache first
|
|
110
|
-
const cached = ctx.schemaCache.get(cacheKey);
|
|
111
|
-
if (cached) {
|
|
112
|
-
log('Using cached vtab module: %s', moduleName);
|
|
113
|
-
return cached;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Resolve vtab module
|
|
117
|
-
const moduleInfo = ctx.schemaManager.getModule(moduleName);
|
|
118
|
-
if (!moduleInfo) {
|
|
119
|
-
throw new QuereusError(
|
|
120
|
-
`Virtual table module not found: ${moduleName}`,
|
|
121
|
-
StatusCode.ERROR
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Record dependency
|
|
126
|
-
const dependency: SchemaDependency = {
|
|
127
|
-
type: 'vtab_module',
|
|
128
|
-
objectName: moduleName
|
|
129
|
-
};
|
|
130
|
-
ctx.schemaDependencies.recordDependency(dependency, moduleInfo);
|
|
131
|
-
|
|
132
|
-
// Cache result
|
|
133
|
-
ctx.schemaCache.set(cacheKey, moduleInfo);
|
|
134
|
-
|
|
135
|
-
log('Resolved vtab module: %s', moduleName);
|
|
136
|
-
return moduleInfo;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Resolves a collation function at build time and records the dependency.
|
|
141
|
-
*/
|
|
142
|
-
export function resolveCollation(
|
|
143
|
-
ctx: PlanningContext,
|
|
144
|
-
collationName: string
|
|
145
|
-
): CollationFunction {
|
|
146
|
-
const cacheKey = `collation:${collationName}`;
|
|
147
|
-
|
|
148
|
-
// Check cache first
|
|
149
|
-
const cached = ctx.schemaCache.get(cacheKey);
|
|
150
|
-
if (cached) {
|
|
151
|
-
log('Using cached collation: %s', collationName);
|
|
152
|
-
return cached as CollationFunction;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// Resolve collation
|
|
156
|
-
const collation = ctx.db._getCollation(collationName);
|
|
157
|
-
if (!collation) {
|
|
158
|
-
throw new QuereusError(
|
|
159
|
-
`Collation not found: ${collationName}`,
|
|
160
|
-
StatusCode.ERROR
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// Record dependency
|
|
165
|
-
const dependency: SchemaDependency = {
|
|
166
|
-
type: 'collation',
|
|
167
|
-
objectName: collationName
|
|
168
|
-
};
|
|
169
|
-
ctx.schemaDependencies.recordDependency(dependency, collation);
|
|
170
|
-
|
|
171
|
-
// Cache result
|
|
172
|
-
ctx.schemaCache.set(cacheKey, collation);
|
|
173
|
-
|
|
174
|
-
log('Resolved collation: %s', collationName);
|
|
175
|
-
return collation;
|
|
176
|
-
}
|
|
1
|
+
import type { PlanningContext, SchemaDependency } from '../planning-context.js';
|
|
2
|
+
import type { TableSchema } from '../../schema/table.js';
|
|
3
|
+
import type { FunctionSchema } from '../../schema/function.js';
|
|
4
|
+
import type { AnyVirtualTableModule } from '../../vtab/module.js';
|
|
5
|
+
import type { CollationFunction } from '../../util/comparison.js';
|
|
6
|
+
import { QuereusError } from '../../common/errors.js';
|
|
7
|
+
import { StatusCode } from '../../common/types.js';
|
|
8
|
+
import { createLogger } from '../../common/logger.js';
|
|
9
|
+
|
|
10
|
+
const log = createLogger('planner:schema-resolution');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Resolves a table schema at build time and records the dependency.
|
|
14
|
+
*/
|
|
15
|
+
export function resolveTableSchema(
|
|
16
|
+
ctx: PlanningContext,
|
|
17
|
+
tableName: string,
|
|
18
|
+
schemaName?: string
|
|
19
|
+
): TableSchema {
|
|
20
|
+
const resolvedSchemaName = schemaName || ctx.db.schemaManager.getCurrentSchemaName();
|
|
21
|
+
const cacheKey = `table:${resolvedSchemaName}:${tableName}`;
|
|
22
|
+
|
|
23
|
+
// Check cache first
|
|
24
|
+
const cached = ctx.schemaCache.get(cacheKey);
|
|
25
|
+
if (cached) {
|
|
26
|
+
log('Using cached table schema: %s.%s', resolvedSchemaName, tableName);
|
|
27
|
+
return cached as TableSchema;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Resolve table schema
|
|
31
|
+
const tableSchema = ctx.schemaManager.findTable(tableName, resolvedSchemaName);
|
|
32
|
+
if (!tableSchema) {
|
|
33
|
+
throw new QuereusError(
|
|
34
|
+
`Table not found: ${resolvedSchemaName}.${tableName}`,
|
|
35
|
+
StatusCode.ERROR
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Record dependency
|
|
40
|
+
const dependency: SchemaDependency = {
|
|
41
|
+
type: 'table',
|
|
42
|
+
schemaName: tableSchema.schemaName,
|
|
43
|
+
objectName: tableSchema.name
|
|
44
|
+
};
|
|
45
|
+
ctx.schemaDependencies.recordDependency(dependency, tableSchema);
|
|
46
|
+
|
|
47
|
+
// Cache result
|
|
48
|
+
ctx.schemaCache.set(cacheKey, tableSchema);
|
|
49
|
+
|
|
50
|
+
log('Resolved table schema: %s.%s', tableSchema.schemaName, tableSchema.name);
|
|
51
|
+
return tableSchema;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Resolves a function schema at build time and records the dependency.
|
|
56
|
+
*/
|
|
57
|
+
export function resolveFunctionSchema(
|
|
58
|
+
ctx: PlanningContext,
|
|
59
|
+
funcName: string,
|
|
60
|
+
numArgs: number
|
|
61
|
+
): FunctionSchema {
|
|
62
|
+
const cacheKey = `function:${funcName}/${numArgs}`;
|
|
63
|
+
|
|
64
|
+
// Check cache first
|
|
65
|
+
const cached = ctx.schemaCache.get(cacheKey);
|
|
66
|
+
if (cached) {
|
|
67
|
+
log('Using cached function schema: %s/%d', funcName, numArgs);
|
|
68
|
+
return cached as FunctionSchema;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Resolve function schema - try exact match first
|
|
72
|
+
let functionSchema = ctx.schemaManager.findFunction(funcName, numArgs);
|
|
73
|
+
|
|
74
|
+
// If not found, try variable argument function
|
|
75
|
+
if (!functionSchema) {
|
|
76
|
+
functionSchema = ctx.schemaManager.findFunction(funcName, -1);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!functionSchema) {
|
|
80
|
+
throw new QuereusError(
|
|
81
|
+
`Function not found: ${funcName}/${numArgs}`,
|
|
82
|
+
StatusCode.ERROR
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Record dependency using the actual function's numArgs
|
|
87
|
+
const dependency: SchemaDependency = {
|
|
88
|
+
type: 'function',
|
|
89
|
+
objectName: `${functionSchema.name}/${functionSchema.numArgs}`
|
|
90
|
+
};
|
|
91
|
+
ctx.schemaDependencies.recordDependency(dependency, functionSchema);
|
|
92
|
+
|
|
93
|
+
// Cache result with the requested key for future lookups
|
|
94
|
+
ctx.schemaCache.set(cacheKey, functionSchema);
|
|
95
|
+
|
|
96
|
+
log('Resolved function schema: %s/%d', functionSchema.name, functionSchema.numArgs);
|
|
97
|
+
return functionSchema;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Resolves a virtual table module at build time and records the dependency.
|
|
102
|
+
*/
|
|
103
|
+
export function resolveVtabModule(
|
|
104
|
+
ctx: PlanningContext,
|
|
105
|
+
moduleName: string
|
|
106
|
+
): { module: AnyVirtualTableModule, auxData?: unknown } {
|
|
107
|
+
const cacheKey = `vtab_module:${moduleName}`;
|
|
108
|
+
|
|
109
|
+
// Check cache first
|
|
110
|
+
const cached = ctx.schemaCache.get(cacheKey);
|
|
111
|
+
if (cached) {
|
|
112
|
+
log('Using cached vtab module: %s', moduleName);
|
|
113
|
+
return cached;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Resolve vtab module
|
|
117
|
+
const moduleInfo = ctx.schemaManager.getModule(moduleName);
|
|
118
|
+
if (!moduleInfo) {
|
|
119
|
+
throw new QuereusError(
|
|
120
|
+
`Virtual table module not found: ${moduleName}`,
|
|
121
|
+
StatusCode.ERROR
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Record dependency
|
|
126
|
+
const dependency: SchemaDependency = {
|
|
127
|
+
type: 'vtab_module',
|
|
128
|
+
objectName: moduleName
|
|
129
|
+
};
|
|
130
|
+
ctx.schemaDependencies.recordDependency(dependency, moduleInfo);
|
|
131
|
+
|
|
132
|
+
// Cache result
|
|
133
|
+
ctx.schemaCache.set(cacheKey, moduleInfo);
|
|
134
|
+
|
|
135
|
+
log('Resolved vtab module: %s', moduleName);
|
|
136
|
+
return moduleInfo;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Resolves a collation function at build time and records the dependency.
|
|
141
|
+
*/
|
|
142
|
+
export function resolveCollation(
|
|
143
|
+
ctx: PlanningContext,
|
|
144
|
+
collationName: string
|
|
145
|
+
): CollationFunction {
|
|
146
|
+
const cacheKey = `collation:${collationName}`;
|
|
147
|
+
|
|
148
|
+
// Check cache first
|
|
149
|
+
const cached = ctx.schemaCache.get(cacheKey);
|
|
150
|
+
if (cached) {
|
|
151
|
+
log('Using cached collation: %s', collationName);
|
|
152
|
+
return cached as CollationFunction;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Resolve collation
|
|
156
|
+
const collation = ctx.db._getCollation(collationName);
|
|
157
|
+
if (!collation) {
|
|
158
|
+
throw new QuereusError(
|
|
159
|
+
`Collation not found: ${collationName}`,
|
|
160
|
+
StatusCode.ERROR
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Record dependency
|
|
165
|
+
const dependency: SchemaDependency = {
|
|
166
|
+
type: 'collation',
|
|
167
|
+
objectName: collationName
|
|
168
|
+
};
|
|
169
|
+
ctx.schemaDependencies.recordDependency(dependency, collation);
|
|
170
|
+
|
|
171
|
+
// Cache result
|
|
172
|
+
ctx.schemaCache.set(cacheKey, collation);
|
|
173
|
+
|
|
174
|
+
log('Resolved collation: %s', collationName);
|
|
175
|
+
return collation;
|
|
176
|
+
}
|
|
@@ -10,6 +10,8 @@ import { ColumnReferenceNode } from '../nodes/reference.js';
|
|
|
10
10
|
import { buildExpression } from './expression.js';
|
|
11
11
|
import { QuereusError } from '../../common/errors.js';
|
|
12
12
|
import { StatusCode } from '../../common/types.js';
|
|
13
|
+
import { CapabilityDetectors } from '../framework/characteristics.js';
|
|
14
|
+
import { Scope } from '../scopes/scope.js';
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* Processes GROUP BY, aggregates, and HAVING clauses
|
|
@@ -143,7 +145,7 @@ function validateAggregateProjections(
|
|
|
143
145
|
* Creates a scope that includes the aggregate output columns
|
|
144
146
|
*/
|
|
145
147
|
function createAggregateOutputScope(
|
|
146
|
-
parentScope:
|
|
148
|
+
parentScope: Scope,
|
|
147
149
|
aggregateNode: RelationalPlanNode,
|
|
148
150
|
groupByExpressions: ScalarPlanNode[],
|
|
149
151
|
aggregates: { expression: ScalarPlanNode; alias: string }[]
|
|
@@ -254,7 +256,7 @@ function checkNeedsFinalProjection(projections: Projection[]): boolean {
|
|
|
254
256
|
// Check if any of the projections are complex expressions (not just column refs)
|
|
255
257
|
return projections.some(proj => {
|
|
256
258
|
// If it's not a simple ColumnReferenceNode, we need final projection
|
|
257
|
-
return !(proj.node
|
|
259
|
+
return !CapabilityDetectors.isColumnReference(proj.node);
|
|
258
260
|
});
|
|
259
261
|
}
|
|
260
262
|
|
|
@@ -275,7 +277,7 @@ export function buildFinalAggregateProjections(
|
|
|
275
277
|
const scalarNode = buildExpression(finalContext, column.expr, true);
|
|
276
278
|
|
|
277
279
|
let attrId: number | undefined = undefined;
|
|
278
|
-
if (scalarNode
|
|
280
|
+
if (CapabilityDetectors.isColumnReference(scalarNode)) {
|
|
279
281
|
attrId = scalarNode.attributeId;
|
|
280
282
|
}
|
|
281
283
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type * as AST from '../../parser/ast.js';
|
|
2
2
|
import type { RelationalPlanNode } from '../nodes/plan-node.js';
|
|
3
3
|
import type { PlanningContext } from '../planning-context.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { CTEScopeNode } from '../nodes/cte-node.js';
|
|
5
|
+
import type { Scope } from '../scopes/scope.js';
|
|
5
6
|
import { SetOperationNode } from '../nodes/set-operation-node.js';
|
|
6
7
|
import { SortNode, type SortKey } from '../nodes/sort.js';
|
|
7
8
|
import { LimitOffsetNode } from '../nodes/limit-offset.js';
|
|
@@ -19,23 +20,31 @@ import { StatusCode } from '../../common/types.js';
|
|
|
19
20
|
export function buildCompoundSelect(
|
|
20
21
|
stmt: AST.SelectStmt,
|
|
21
22
|
contextWithCTEs: PlanningContext,
|
|
22
|
-
cteNodes: Map<string,
|
|
23
|
-
buildSelectStmt: (ctx: PlanningContext, stmt: AST.SelectStmt, parentCTEs?: Map<string,
|
|
23
|
+
cteNodes: Map<string, CTEScopeNode>,
|
|
24
|
+
buildSelectStmt: (ctx: PlanningContext, stmt: AST.SelectStmt, parentCTEs?: Map<string, CTEScopeNode>) => RelationalPlanNode
|
|
24
25
|
): RelationalPlanNode {
|
|
25
26
|
if (!stmt.compound) {
|
|
26
27
|
throw new QuereusError('buildCompoundSelect called without compound clause', StatusCode.INTERNAL);
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
// Build left side by cloning the statement without compound and stripping ORDER BY/LIMIT/OFFSET that belong to outer query
|
|
30
|
-
const { compound: _outerCompound, orderBy: outerOrderBy, limit: outerLimit, offset: outerOffset, ...leftCore } = stmt
|
|
31
|
+
const { compound: _outerCompound, orderBy: outerOrderBy, limit: outerLimit, offset: outerOffset, ...leftCore } = stmt;
|
|
31
32
|
|
|
32
33
|
// Also strip ORDER BY/LIMIT/OFFSET from the right side - they should only apply to the final compound result
|
|
33
|
-
const { orderBy: _rightOrderBy, limit: _rightLimit, offset: _rightOffset, ...rightCore } = stmt.compound.select
|
|
34
|
+
const { orderBy: _rightOrderBy, limit: _rightLimit, offset: _rightOffset, ...rightCore } = stmt.compound.select;
|
|
34
35
|
|
|
35
36
|
const leftPlan = buildSelectStmt(contextWithCTEs, leftCore as AST.SelectStmt, cteNodes) as RelationalPlanNode;
|
|
36
37
|
const rightPlan = buildSelectStmt(contextWithCTEs, rightCore as AST.SelectStmt, cteNodes) as RelationalPlanNode;
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
// Expand DIFF as (A EXCEPT B) UNION (B EXCEPT A)
|
|
40
|
+
let setNode: RelationalPlanNode;
|
|
41
|
+
if (stmt.compound.op === 'diff') {
|
|
42
|
+
const leftMinusRight = new SetOperationNode(contextWithCTEs.scope, leftPlan, rightPlan, 'except');
|
|
43
|
+
const rightMinusLeft = new SetOperationNode(contextWithCTEs.scope, rightPlan, leftPlan, 'except');
|
|
44
|
+
setNode = new SetOperationNode(contextWithCTEs.scope, leftMinusRight, rightMinusLeft, 'union');
|
|
45
|
+
} else {
|
|
46
|
+
setNode = new SetOperationNode(contextWithCTEs.scope, leftPlan, rightPlan, stmt.compound.op);
|
|
47
|
+
}
|
|
39
48
|
|
|
40
49
|
// After set operation, apply ORDER BY / LIMIT / OFFSET from the *outer* (original) statement
|
|
41
50
|
let input: RelationalPlanNode = setNode;
|
|
@@ -58,15 +67,15 @@ function createSetOperationScope(setNode: RelationalPlanNode): RegisteredScope {
|
|
|
58
67
|
const setScope = new RegisteredScope();
|
|
59
68
|
const attrs = setNode.getAttributes();
|
|
60
69
|
|
|
61
|
-
setNode.getType().columns.forEach((c
|
|
70
|
+
setNode.getType().columns.forEach((c, i: number) => {
|
|
62
71
|
const attr = attrs[i];
|
|
63
72
|
// Ensure column has a name - use attribute name as fallback
|
|
64
73
|
const columnName = c.name || attr.name;
|
|
65
74
|
if (!columnName) {
|
|
66
75
|
throw new QuereusError(`Column at index ${i} has no name in set operation`, StatusCode.ERROR);
|
|
67
76
|
}
|
|
68
|
-
setScope.registerSymbol(columnName.toLowerCase(), (exp:
|
|
69
|
-
new ColumnReferenceNode(s, exp, c.type, attr.id, i));
|
|
77
|
+
setScope.registerSymbol(columnName.toLowerCase(), (exp: AST.Expression, s: Scope) =>
|
|
78
|
+
new ColumnReferenceNode(s, exp as AST.ColumnExpr, c.type, attr.id, i));
|
|
70
79
|
});
|
|
71
80
|
|
|
72
81
|
return setScope;
|
|
@@ -77,11 +86,11 @@ function createSetOperationScope(setNode: RelationalPlanNode): RegisteredScope {
|
|
|
77
86
|
*/
|
|
78
87
|
function applyOuterOrderBy(
|
|
79
88
|
input: RelationalPlanNode,
|
|
80
|
-
outerOrderBy:
|
|
89
|
+
outerOrderBy: AST.OrderByClause[] | undefined,
|
|
81
90
|
selectContext: PlanningContext
|
|
82
91
|
): RelationalPlanNode {
|
|
83
92
|
if (outerOrderBy && outerOrderBy.length > 0) {
|
|
84
|
-
const sortKeys: SortKey[] = outerOrderBy.map((ob
|
|
93
|
+
const sortKeys: SortKey[] = outerOrderBy.map((ob) => ({
|
|
85
94
|
expression: buildExpression(selectContext, ob.expr),
|
|
86
95
|
direction: ob.direction,
|
|
87
96
|
nulls: ob.nulls,
|
|
@@ -96,8 +105,8 @@ function applyOuterOrderBy(
|
|
|
96
105
|
*/
|
|
97
106
|
function applyOuterLimitOffset(
|
|
98
107
|
input: RelationalPlanNode,
|
|
99
|
-
outerLimit:
|
|
100
|
-
outerOffset:
|
|
108
|
+
outerLimit: AST.Expression | undefined,
|
|
109
|
+
outerOffset: AST.Expression | undefined,
|
|
101
110
|
selectContext: PlanningContext
|
|
102
111
|
): RelationalPlanNode {
|
|
103
112
|
if (outerLimit || outerOffset) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as AST from '../../parser/ast.js';
|
|
2
2
|
import type { PlanningContext } from '../planning-context.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { CTEScopeNode } from '../nodes/cte-node.js';
|
|
4
4
|
import type { Scope } from '../scopes/scope.js';
|
|
5
5
|
import { RegisteredScope } from '../scopes/registered.js';
|
|
6
6
|
import { ParameterScope } from '../scopes/param.js';
|
|
@@ -22,13 +22,13 @@ export function getNonParamAncestor(scope: Scope): Scope {
|
|
|
22
22
|
export function buildWithContext(
|
|
23
23
|
ctx: PlanningContext,
|
|
24
24
|
stmt: AST.SelectStmt,
|
|
25
|
-
parentCTEs: Map<string,
|
|
25
|
+
parentCTEs: Map<string, CTEScopeNode> = new Map()
|
|
26
26
|
): {
|
|
27
27
|
contextWithCTEs: PlanningContext;
|
|
28
|
-
cteNodes: Map<string,
|
|
28
|
+
cteNodes: Map<string, CTEScopeNode>;
|
|
29
29
|
} {
|
|
30
30
|
// Start with parent CTEs - either from parameter or from context
|
|
31
|
-
const cteNodes: Map<string,
|
|
31
|
+
const cteNodes: Map<string, CTEScopeNode> = new Map(parentCTEs.size > 0 ? parentCTEs : (ctx.cteNodes ?? new Map()));
|
|
32
32
|
let contextWithCTEs = ctx;
|
|
33
33
|
|
|
34
34
|
if (stmt.withClause) {
|
|
@@ -56,7 +56,7 @@ export function buildWithContext(
|
|
|
56
56
|
* that might cause attribute ID collisions in correlated subqueries
|
|
57
57
|
*/
|
|
58
58
|
function createCTEScope(
|
|
59
|
-
cteNodes: Map<string,
|
|
59
|
+
cteNodes: Map<string, CTEScopeNode>,
|
|
60
60
|
ctx: PlanningContext
|
|
61
61
|
): RegisteredScope {
|
|
62
62
|
const cteScope = new RegisteredScope(getNonParamAncestor(ctx.scope));
|
|
@@ -70,7 +70,7 @@ function createCTEScope(
|
|
|
70
70
|
|
|
71
71
|
// Only register columns that are stable input attributes
|
|
72
72
|
// This prevents scope pollution from projection output attributes
|
|
73
|
-
columnTypes.forEach((col
|
|
73
|
+
columnTypes.forEach((col, i) => {
|
|
74
74
|
if (i < attributes.length) {
|
|
75
75
|
const attr = attributes[i];
|
|
76
76
|
// Register CTE columns with qualified names to avoid collisions
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import type * as AST from '../../parser/ast.js';
|
|
2
2
|
import type { RelationalPlanNode } from '../nodes/plan-node.js';
|
|
3
3
|
import type { PlanningContext } from '../planning-context.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Scope } from '../scopes/scope.js';
|
|
5
|
+
import { ProjectNode, type Projection } from '../nodes/project-node.js';
|
|
5
6
|
import { DistinctNode } from '../nodes/distinct-node.js';
|
|
6
7
|
import { SortNode, type SortKey } from '../nodes/sort.js';
|
|
7
8
|
import { LimitOffsetNode } from '../nodes/limit-offset.js';
|
|
8
9
|
import { LiteralNode } from '../nodes/scalar.js';
|
|
9
|
-
import { ProjectNode } from '../nodes/project-node.js';
|
|
10
10
|
import { MultiScope } from '../scopes/multi.js';
|
|
11
11
|
import { RegisteredScope } from '../scopes/registered.js';
|
|
12
12
|
import { ColumnReferenceNode } from '../nodes/reference.js';
|
|
13
13
|
import { buildExpression } from './expression.js';
|
|
14
|
+
import { CapabilityDetectors } from '../framework/characteristics.js';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* Creates final output projections and applies result column aliases
|
|
17
18
|
*/
|
|
18
19
|
export function buildFinalProjections(
|
|
19
20
|
input: RelationalPlanNode,
|
|
20
21
|
projections: Projection[],
|
|
21
|
-
selectScope:
|
|
22
|
+
selectScope: Scope,
|
|
22
23
|
stmt: AST.SelectStmt,
|
|
23
24
|
selectContext: PlanningContext,
|
|
24
25
|
preserveInputColumns: boolean = true
|
|
@@ -68,12 +69,12 @@ export function buildFinalProjections(
|
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
/**
|
|
71
|
-
* Applies DISTINCT
|
|
72
|
+
* Applies DISTINCT if specified
|
|
72
73
|
*/
|
|
73
74
|
export function applyDistinct(
|
|
74
75
|
input: RelationalPlanNode,
|
|
75
76
|
stmt: AST.SelectStmt,
|
|
76
|
-
selectScope:
|
|
77
|
+
selectScope: Scope
|
|
77
78
|
): RelationalPlanNode {
|
|
78
79
|
if (stmt.distinct) {
|
|
79
80
|
return new DistinctNode(selectScope, input);
|
|
@@ -156,7 +157,7 @@ function shouldApplyOrderByBeforeProjection(
|
|
|
156
157
|
// Check if this column is in the projection aliases
|
|
157
158
|
const isInProjection = projections.some(proj =>
|
|
158
159
|
(proj.alias?.toLowerCase() === orderColumn) ||
|
|
159
|
-
(proj.node
|
|
160
|
+
(CapabilityDetectors.isColumnReference(proj.node) && proj.node.expression.name.toLowerCase() === orderColumn)
|
|
160
161
|
);
|
|
161
162
|
if (!isInProjection) {
|
|
162
163
|
return true;
|