@quereus/quereus 0.7.3 → 0.7.4
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/package.json +3 -3
- package/dist/src/common/constants.js.map +0 -1
- package/dist/src/common/datatype.js.map +0 -1
- package/dist/src/common/errors.js.map +0 -1
- package/dist/src/common/json-types.js.map +0 -1
- package/dist/src/common/logger.js.map +0 -1
- package/dist/src/common/type-inference.js.map +0 -1
- package/dist/src/common/types.js.map +0 -1
- package/dist/src/core/database-options.js.map +0 -1
- package/dist/src/core/database.js.map +0 -1
- package/dist/src/core/param.js.map +0 -1
- package/dist/src/core/statement.js.map +0 -1
- package/dist/src/func/builtins/aggregate.js.map +0 -1
- package/dist/src/func/builtins/builtin-window-functions.js.map +0 -1
- package/dist/src/func/builtins/conversion.js.map +0 -1
- package/dist/src/func/builtins/datetime.js.map +0 -1
- package/dist/src/func/builtins/explain.js.map +0 -1
- package/dist/src/func/builtins/generation.js.map +0 -1
- package/dist/src/func/builtins/index.js.map +0 -1
- package/dist/src/func/builtins/json-helpers.js.map +0 -1
- package/dist/src/func/builtins/json-tvf.js.map +0 -1
- package/dist/src/func/builtins/json.js.map +0 -1
- package/dist/src/func/builtins/scalar.js.map +0 -1
- package/dist/src/func/builtins/schema.js.map +0 -1
- package/dist/src/func/builtins/string.js.map +0 -1
- package/dist/src/func/builtins/timespan.js.map +0 -1
- package/dist/src/func/context.js.map +0 -1
- package/dist/src/func/registration.js.map +0 -1
- package/dist/src/index.js.map +0 -1
- package/dist/src/parser/ast.js.map +0 -1
- package/dist/src/parser/index.js.map +0 -1
- package/dist/src/parser/lexer.js.map +0 -1
- package/dist/src/parser/parser.js.map +0 -1
- package/dist/src/parser/utils.js.map +0 -1
- package/dist/src/parser/visitor.js.map +0 -1
- package/dist/src/planner/analysis/binding-collector.js.map +0 -1
- package/dist/src/planner/analysis/const-evaluator.js.map +0 -1
- package/dist/src/planner/analysis/const-pass.js.map +0 -1
- package/dist/src/planner/analysis/constraint-extractor.js.map +0 -1
- package/dist/src/planner/analysis/predicate-normalizer.js.map +0 -1
- package/dist/src/planner/building/alter-table.js.map +0 -1
- package/dist/src/planner/building/block.js.map +0 -1
- package/dist/src/planner/building/constraint-builder.js.map +0 -1
- package/dist/src/planner/building/create-assertion.js.map +0 -1
- package/dist/src/planner/building/create-view.js.map +0 -1
- package/dist/src/planner/building/ddl.js.map +0 -1
- package/dist/src/planner/building/declare-schema.js.map +0 -1
- package/dist/src/planner/building/delete.js.map +0 -1
- package/dist/src/planner/building/drop-assertion.js.map +0 -1
- package/dist/src/planner/building/drop-table.js.map +0 -1
- package/dist/src/planner/building/drop-view.js.map +0 -1
- package/dist/src/planner/building/expression.js.map +0 -1
- package/dist/src/planner/building/function-call.js.map +0 -1
- package/dist/src/planner/building/insert.js.map +0 -1
- package/dist/src/planner/building/pragma.js.map +0 -1
- package/dist/src/planner/building/schema-resolution.js.map +0 -1
- package/dist/src/planner/building/select-aggregates.js.map +0 -1
- package/dist/src/planner/building/select-compound.js.map +0 -1
- package/dist/src/planner/building/select-context.js.map +0 -1
- package/dist/src/planner/building/select-modifiers.js.map +0 -1
- package/dist/src/planner/building/select-projections.js.map +0 -1
- package/dist/src/planner/building/select-window.js.map +0 -1
- package/dist/src/planner/building/select.js.map +0 -1
- package/dist/src/planner/building/table-function.js.map +0 -1
- package/dist/src/planner/building/table.js.map +0 -1
- package/dist/src/planner/building/transaction.js.map +0 -1
- package/dist/src/planner/building/update.js.map +0 -1
- package/dist/src/planner/building/with.js.map +0 -1
- package/dist/src/planner/cache/correlation-detector.js.map +0 -1
- package/dist/src/planner/cache/materialization-advisory.js.map +0 -1
- package/dist/src/planner/cache/reference-graph.js.map +0 -1
- package/dist/src/planner/cost/index.js.map +0 -1
- package/dist/src/planner/debug/logger-utils.js.map +0 -1
- package/dist/src/planner/debug.js.map +0 -1
- package/dist/src/planner/framework/characteristics.js.map +0 -1
- package/dist/src/planner/framework/context.js.map +0 -1
- package/dist/src/planner/framework/pass.js.map +0 -1
- package/dist/src/planner/framework/physical-utils.js.map +0 -1
- package/dist/src/planner/framework/registry.js.map +0 -1
- package/dist/src/planner/framework/trace.js.map +0 -1
- package/dist/src/planner/nodes/add-constraint-node.js.map +0 -1
- package/dist/src/planner/nodes/aggregate-function.js.map +0 -1
- package/dist/src/planner/nodes/aggregate-node.js.map +0 -1
- package/dist/src/planner/nodes/array-index-node.js.map +0 -1
- package/dist/src/planner/nodes/block.js.map +0 -1
- package/dist/src/planner/nodes/cache-node.js.map +0 -1
- package/dist/src/planner/nodes/constraint-check-node.js.map +0 -1
- package/dist/src/planner/nodes/create-assertion-node.js.map +0 -1
- package/dist/src/planner/nodes/create-index-node.js.map +0 -1
- package/dist/src/planner/nodes/create-table-node.js.map +0 -1
- package/dist/src/planner/nodes/create-view-node.js.map +0 -1
- package/dist/src/planner/nodes/cte-node.js.map +0 -1
- package/dist/src/planner/nodes/cte-reference-node.js.map +0 -1
- package/dist/src/planner/nodes/declarative-schema.js.map +0 -1
- package/dist/src/planner/nodes/delete-node.js.map +0 -1
- package/dist/src/planner/nodes/distinct-node.js.map +0 -1
- package/dist/src/planner/nodes/dml-executor-node.js.map +0 -1
- package/dist/src/planner/nodes/drop-assertion-node.js.map +0 -1
- package/dist/src/planner/nodes/drop-table-node.js.map +0 -1
- package/dist/src/planner/nodes/drop-view-node.js.map +0 -1
- package/dist/src/planner/nodes/filter.js.map +0 -1
- package/dist/src/planner/nodes/function.js.map +0 -1
- package/dist/src/planner/nodes/insert-node.js.map +0 -1
- package/dist/src/planner/nodes/internal-recursive-cte-ref-node.js.map +0 -1
- package/dist/src/planner/nodes/join-node.js.map +0 -1
- package/dist/src/planner/nodes/limit-offset.js.map +0 -1
- package/dist/src/planner/nodes/plan-node-type.js.map +0 -1
- package/dist/src/planner/nodes/plan-node.js.map +0 -1
- package/dist/src/planner/nodes/pragma.js.map +0 -1
- package/dist/src/planner/nodes/project-node.js.map +0 -1
- package/dist/src/planner/nodes/recursive-cte-node.js.map +0 -1
- package/dist/src/planner/nodes/reference.js.map +0 -1
- package/dist/src/planner/nodes/remote-query-node.js.map +0 -1
- package/dist/src/planner/nodes/retrieve-node.js.map +0 -1
- package/dist/src/planner/nodes/returning-node.js.map +0 -1
- package/dist/src/planner/nodes/scalar.js.map +0 -1
- package/dist/src/planner/nodes/sequencing-node.js.map +0 -1
- package/dist/src/planner/nodes/set-operation-node.js.map +0 -1
- package/dist/src/planner/nodes/single-row.js.map +0 -1
- package/dist/src/planner/nodes/sink-node.js.map +0 -1
- package/dist/src/planner/nodes/sort.js.map +0 -1
- package/dist/src/planner/nodes/stream-aggregate.js.map +0 -1
- package/dist/src/planner/nodes/subquery.js.map +0 -1
- package/dist/src/planner/nodes/table-access-nodes.js.map +0 -1
- package/dist/src/planner/nodes/table-function-call.js.map +0 -1
- package/dist/src/planner/nodes/transaction-node.js.map +0 -1
- package/dist/src/planner/nodes/update-node.js.map +0 -1
- package/dist/src/planner/nodes/values-node.js.map +0 -1
- package/dist/src/planner/nodes/view-reference-node.js.map +0 -1
- package/dist/src/planner/nodes/window-function.js.map +0 -1
- package/dist/src/planner/nodes/window-node.js.map +0 -1
- package/dist/src/planner/optimizer-tuning.js.map +0 -1
- package/dist/src/planner/optimizer.js.map +0 -1
- package/dist/src/planner/planning-context.js.map +0 -1
- package/dist/src/planner/resolve.js.map +0 -1
- package/dist/src/planner/rules/access/rule-select-access-path.js.map +0 -1
- package/dist/src/planner/rules/aggregate/rule-aggregate-streaming.js.map +0 -1
- package/dist/src/planner/rules/cache/rule-cte-optimization.js.map +0 -1
- package/dist/src/planner/rules/cache/rule-materialization-advisory.js.map +0 -1
- package/dist/src/planner/rules/cache/rule-mutating-subquery-cache.js.map +0 -1
- package/dist/src/planner/rules/join/rule-join-greedy-commute.js.map +0 -1
- package/dist/src/planner/rules/join/rule-join-key-inference.js.map +0 -1
- package/dist/src/planner/rules/join/rule-quickpick-enumeration.js.map +0 -1
- package/dist/src/planner/rules/predicate/rule-predicate-pushdown.js.map +0 -1
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js.map +0 -1
- package/dist/src/planner/scopes/aliased.js.map +0 -1
- package/dist/src/planner/scopes/base.js.map +0 -1
- package/dist/src/planner/scopes/empty.js.map +0 -1
- package/dist/src/planner/scopes/global.js.map +0 -1
- package/dist/src/planner/scopes/multi.js.map +0 -1
- package/dist/src/planner/scopes/param.js.map +0 -1
- package/dist/src/planner/scopes/registered.js.map +0 -1
- package/dist/src/planner/scopes/scope.js.map +0 -1
- package/dist/src/planner/stats/basic-estimates.js.map +0 -1
- package/dist/src/planner/stats/index.js.map +0 -1
- package/dist/src/planner/type-utils.js.map +0 -1
- package/dist/src/planner/util/key-utils.js.map +0 -1
- package/dist/src/planner/validation/determinism-validator.js.map +0 -1
- package/dist/src/planner/validation/plan-validator.js.map +0 -1
- package/dist/src/runtime/async-util.js.map +0 -1
- package/dist/src/runtime/cache/shared-cache.js.map +0 -1
- package/dist/src/runtime/context-helpers.js.map +0 -1
- package/dist/src/runtime/deferred-constraint-queue.js.map +0 -1
- package/dist/src/runtime/emission-context.js.map +0 -1
- package/dist/src/runtime/emit/add-constraint.js.map +0 -1
- package/dist/src/runtime/emit/aggregate.js.map +0 -1
- package/dist/src/runtime/emit/array-index.js.map +0 -1
- package/dist/src/runtime/emit/between.js.map +0 -1
- package/dist/src/runtime/emit/binary.js.map +0 -1
- package/dist/src/runtime/emit/block.js.map +0 -1
- package/dist/src/runtime/emit/cache.js.map +0 -1
- package/dist/src/runtime/emit/case.js.map +0 -1
- package/dist/src/runtime/emit/cast.js.map +0 -1
- package/dist/src/runtime/emit/collate.js.map +0 -1
- package/dist/src/runtime/emit/column-reference.js.map +0 -1
- package/dist/src/runtime/emit/constraint-check.js.map +0 -1
- package/dist/src/runtime/emit/create-assertion.js.map +0 -1
- package/dist/src/runtime/emit/create-index.js.map +0 -1
- package/dist/src/runtime/emit/create-table.js.map +0 -1
- package/dist/src/runtime/emit/create-view.js.map +0 -1
- package/dist/src/runtime/emit/cte-reference.js.map +0 -1
- package/dist/src/runtime/emit/cte.js.map +0 -1
- package/dist/src/runtime/emit/delete.js.map +0 -1
- package/dist/src/runtime/emit/distinct.js.map +0 -1
- package/dist/src/runtime/emit/dml-executor.js.map +0 -1
- package/dist/src/runtime/emit/drop-assertion.js.map +0 -1
- package/dist/src/runtime/emit/drop-table.js.map +0 -1
- package/dist/src/runtime/emit/drop-view.js.map +0 -1
- package/dist/src/runtime/emit/filter.js.map +0 -1
- package/dist/src/runtime/emit/insert.js.map +0 -1
- package/dist/src/runtime/emit/internal-recursive-cte-ref.js.map +0 -1
- package/dist/src/runtime/emit/join.js.map +0 -1
- package/dist/src/runtime/emit/limit-offset.js.map +0 -1
- package/dist/src/runtime/emit/literal.js.map +0 -1
- package/dist/src/runtime/emit/parameter.js.map +0 -1
- package/dist/src/runtime/emit/pragma.js.map +0 -1
- package/dist/src/runtime/emit/project.js.map +0 -1
- package/dist/src/runtime/emit/recursive-cte.js.map +0 -1
- package/dist/src/runtime/emit/remote-query.js.map +0 -1
- package/dist/src/runtime/emit/retrieve.js.map +0 -1
- package/dist/src/runtime/emit/returning.js.map +0 -1
- package/dist/src/runtime/emit/scalar-function.js.map +0 -1
- package/dist/src/runtime/emit/scan.js.map +0 -1
- package/dist/src/runtime/emit/schema-declarative.js.map +0 -1
- package/dist/src/runtime/emit/sequencing.js.map +0 -1
- package/dist/src/runtime/emit/set-operation.js.map +0 -1
- package/dist/src/runtime/emit/sink.js.map +0 -1
- package/dist/src/runtime/emit/sort.js.map +0 -1
- package/dist/src/runtime/emit/subquery.js.map +0 -1
- package/dist/src/runtime/emit/table-valued-function.js.map +0 -1
- package/dist/src/runtime/emit/temporal-arithmetic.js.map +0 -1
- package/dist/src/runtime/emit/transaction.js.map +0 -1
- package/dist/src/runtime/emit/unary.js.map +0 -1
- package/dist/src/runtime/emit/update.js.map +0 -1
- package/dist/src/runtime/emit/values.js.map +0 -1
- package/dist/src/runtime/emit/window-function.js.map +0 -1
- package/dist/src/runtime/emit/window.js.map +0 -1
- package/dist/src/runtime/emitters.js.map +0 -1
- package/dist/src/runtime/register.js.map +0 -1
- package/dist/src/runtime/scheduler.js.map +0 -1
- package/dist/src/runtime/types.js.map +0 -1
- package/dist/src/runtime/utils.js.map +0 -1
- package/dist/src/schema/assertion.js.map +0 -1
- package/dist/src/schema/catalog.js.map +0 -1
- package/dist/src/schema/change-events.js.map +0 -1
- package/dist/src/schema/column.js.map +0 -1
- package/dist/src/schema/declared-schema-manager.js.map +0 -1
- package/dist/src/schema/function.js.map +0 -1
- package/dist/src/schema/manager.js.map +0 -1
- package/dist/src/schema/schema-differ.js.map +0 -1
- package/dist/src/schema/schema-hasher.js.map +0 -1
- package/dist/src/schema/schema.js.map +0 -1
- package/dist/src/schema/table.js.map +0 -1
- package/dist/src/schema/view.js.map +0 -1
- package/dist/src/schema/window-function.js.map +0 -1
- package/dist/src/types/builtin-types.js.map +0 -1
- package/dist/src/types/index.js.map +0 -1
- package/dist/src/types/json-type.js.map +0 -1
- package/dist/src/types/logical-type.js.map +0 -1
- package/dist/src/types/plugin-interface.js.map +0 -1
- package/dist/src/types/registry.js.map +0 -1
- package/dist/src/types/temporal-types.js.map +0 -1
- package/dist/src/types/validation.js.map +0 -1
- package/dist/src/util/affinity.js.map +0 -1
- package/dist/src/util/ast-stringify.js.map +0 -1
- package/dist/src/util/cached.js.map +0 -1
- package/dist/src/util/coercion.js.map +0 -1
- package/dist/src/util/comparison.js.map +0 -1
- package/dist/src/util/environment.js.map +0 -1
- package/dist/src/util/hash.js.map +0 -1
- package/dist/src/util/latches.js.map +0 -1
- package/dist/src/util/mutation-statement.js.map +0 -1
- package/dist/src/util/patterns.js.map +0 -1
- package/dist/src/util/plan-formatter.js.map +0 -1
- package/dist/src/util/plugin-helper.js.map +0 -1
- package/dist/src/util/row-descriptor.js.map +0 -1
- package/dist/src/util/serialization.js.map +0 -1
- package/dist/src/util/sql-literal.js.map +0 -1
- package/dist/src/util/working-table-iterable.js.map +0 -1
- package/dist/src/vtab/best-access-plan.js.map +0 -1
- package/dist/src/vtab/connection.js.map +0 -1
- package/dist/src/vtab/filter-info.js.map +0 -1
- package/dist/src/vtab/index-info.js.map +0 -1
- package/dist/src/vtab/manifest.js.map +0 -1
- package/dist/src/vtab/memory/connection.js.map +0 -1
- package/dist/src/vtab/memory/index.js.map +0 -1
- package/dist/src/vtab/memory/layer/base-cursor.js.map +0 -1
- package/dist/src/vtab/memory/layer/base.js.map +0 -1
- package/dist/src/vtab/memory/layer/connection.js.map +0 -1
- package/dist/src/vtab/memory/layer/interface.js.map +0 -1
- package/dist/src/vtab/memory/layer/manager.js.map +0 -1
- package/dist/src/vtab/memory/layer/safe-iterate.js.map +0 -1
- package/dist/src/vtab/memory/layer/scan-plan.js.map +0 -1
- package/dist/src/vtab/memory/layer/transaction-cursor.js.map +0 -1
- package/dist/src/vtab/memory/layer/transaction.js.map +0 -1
- package/dist/src/vtab/memory/module.js.map +0 -1
- package/dist/src/vtab/memory/table.js.map +0 -1
- package/dist/src/vtab/memory/types.js.map +0 -1
- package/dist/src/vtab/memory/utils/logging.js.map +0 -1
- package/dist/src/vtab/memory/utils/primary-key.js.map +0 -1
- package/dist/src/vtab/module.js.map +0 -1
- package/dist/src/vtab/table.js.map +0 -1
- package/src/common/constants.ts +0 -60
- package/src/common/datatype.ts +0 -85
- package/src/common/errors.ts +0 -189
- package/src/common/json-types.ts +0 -16
- package/src/common/logger.ts +0 -97
- package/src/common/type-inference.ts +0 -39
- package/src/common/types.ts +0 -151
- package/src/core/database-options.ts +0 -258
- package/src/core/database.ts +0 -1461
- package/src/core/param.ts +0 -56
- package/src/core/statement.ts +0 -528
- package/src/func/builtins/aggregate.ts +0 -269
- package/src/func/builtins/builtin-window-functions.ts +0 -166
- package/src/func/builtins/conversion.ts +0 -226
- package/src/func/builtins/datetime.ts +0 -500
- package/src/func/builtins/explain.ts +0 -779
- package/src/func/builtins/generation.ts +0 -43
- package/src/func/builtins/index.ts +0 -167
- package/src/func/builtins/json-helpers.ts +0 -237
- package/src/func/builtins/json-tvf.ts +0 -224
- package/src/func/builtins/json.ts +0 -588
- package/src/func/builtins/scalar.ts +0 -423
- package/src/func/builtins/schema.ts +0 -213
- package/src/func/builtins/string.ts +0 -306
- package/src/func/builtins/timespan.ts +0 -179
- package/src/func/context.ts +0 -258
- package/src/func/registration.ts +0 -201
- package/src/index.ts +0 -172
- package/src/parser/ast.ts +0 -581
- package/src/parser/index.ts +0 -65
- package/src/parser/lexer.ts +0 -806
- package/src/parser/parser.ts +0 -3352
- package/src/parser/utils.ts +0 -10
- package/src/parser/visitor.ts +0 -188
- package/src/planner/analysis/README.md +0 -93
- package/src/planner/analysis/binding-collector.ts +0 -83
- package/src/planner/analysis/const-evaluator.ts +0 -63
- package/src/planner/analysis/const-pass.ts +0 -282
- package/src/planner/analysis/constraint-extractor.ts +0 -764
- package/src/planner/analysis/predicate-normalizer.ts +0 -237
- package/src/planner/building/alter-table.ts +0 -49
- package/src/planner/building/block.ts +0 -93
- package/src/planner/building/constraint-builder.ts +0 -178
- package/src/planner/building/create-assertion.ts +0 -7
- package/src/planner/building/create-view.ts +0 -29
- package/src/planner/building/ddl.ts +0 -24
- package/src/planner/building/declare-schema.ts +0 -22
- package/src/planner/building/delete.ts +0 -218
- package/src/planner/building/drop-assertion.ts +0 -11
- package/src/planner/building/drop-table.ts +0 -13
- package/src/planner/building/drop-view.ts +0 -19
- package/src/planner/building/expression.ts +0 -205
- package/src/planner/building/function-call.ts +0 -129
- package/src/planner/building/insert.ts +0 -435
- package/src/planner/building/pragma.ts +0 -34
- package/src/planner/building/schema-resolution.ts +0 -176
- package/src/planner/building/select-aggregates.ts +0 -318
- package/src/planner/building/select-compound.ts +0 -119
- package/src/planner/building/select-context.ts +0 -85
- package/src/planner/building/select-modifiers.ts +0 -236
- package/src/planner/building/select-projections.ts +0 -177
- package/src/planner/building/select-window.ts +0 -259
- package/src/planner/building/select.ts +0 -567
- package/src/planner/building/table-function.ts +0 -49
- package/src/planner/building/table.ts +0 -40
- package/src/planner/building/transaction.ts +0 -23
- package/src/planner/building/update.ts +0 -331
- package/src/planner/building/with.ts +0 -180
- package/src/planner/cache/correlation-detector.ts +0 -83
- package/src/planner/cache/materialization-advisory.ts +0 -265
- package/src/planner/cache/reference-graph.ts +0 -196
- package/src/planner/cost/index.ts +0 -169
- package/src/planner/debug/logger-utils.ts +0 -68
- package/src/planner/debug.ts +0 -480
- package/src/planner/framework/README.md +0 -132
- package/src/planner/framework/characteristics.ts +0 -503
- package/src/planner/framework/context.ts +0 -239
- package/src/planner/framework/pass.ts +0 -354
- package/src/planner/framework/physical-utils.ts +0 -210
- package/src/planner/framework/registry.ts +0 -261
- package/src/planner/framework/trace.ts +0 -259
- package/src/planner/nodes/add-constraint-node.ts +0 -62
- package/src/planner/nodes/aggregate-function.ts +0 -155
- package/src/planner/nodes/aggregate-node.ts +0 -267
- package/src/planner/nodes/array-index-node.ts +0 -50
- package/src/planner/nodes/block.ts +0 -80
- package/src/planner/nodes/cache-node.ts +0 -103
- package/src/planner/nodes/constraint-check-node.ts +0 -138
- package/src/planner/nodes/create-assertion-node.ts +0 -51
- package/src/planner/nodes/create-index-node.ts +0 -41
- package/src/planner/nodes/create-table-node.ts +0 -35
- package/src/planner/nodes/create-view-node.ts +0 -44
- package/src/planner/nodes/cte-node.ts +0 -168
- package/src/planner/nodes/cte-reference-node.ts +0 -125
- package/src/planner/nodes/declarative-schema.ts +0 -221
- package/src/planner/nodes/delete-node.ts +0 -102
- package/src/planner/nodes/distinct-node.ts +0 -107
- package/src/planner/nodes/dml-executor-node.ts +0 -104
- package/src/planner/nodes/drop-assertion-node.ts +0 -50
- package/src/planner/nodes/drop-table-node.ts +0 -36
- package/src/planner/nodes/drop-view-node.ts +0 -37
- package/src/planner/nodes/filter.ts +0 -144
- package/src/planner/nodes/function.ts +0 -98
- package/src/planner/nodes/insert-node.ts +0 -126
- package/src/planner/nodes/internal-recursive-cte-ref-node.ts +0 -61
- package/src/planner/nodes/join-node.ts +0 -336
- package/src/planner/nodes/limit-offset.ts +0 -144
- package/src/planner/nodes/plan-node-type.ts +0 -95
- package/src/planner/nodes/plan-node.ts +0 -503
- package/src/planner/nodes/pragma.ts +0 -98
- package/src/planner/nodes/project-node.ts +0 -337
- package/src/planner/nodes/recursive-cte-node.ts +0 -158
- package/src/planner/nodes/reference.ts +0 -334
- package/src/planner/nodes/remote-query-node.ts +0 -73
- package/src/planner/nodes/retrieve-node.ts +0 -86
- package/src/planner/nodes/returning-node.ts +0 -269
- package/src/planner/nodes/scalar.ts +0 -772
- package/src/planner/nodes/sequencing-node.ts +0 -113
- package/src/planner/nodes/set-operation-node.ts +0 -87
- package/src/planner/nodes/single-row.ts +0 -85
- package/src/planner/nodes/sink-node.ts +0 -61
- package/src/planner/nodes/sort.ts +0 -166
- package/src/planner/nodes/stream-aggregate.ts +0 -293
- package/src/planner/nodes/subquery.ts +0 -268
- package/src/planner/nodes/table-access-nodes.ts +0 -323
- package/src/planner/nodes/table-function-call.ts +0 -134
- package/src/planner/nodes/transaction-node.ts +0 -55
- package/src/planner/nodes/update-node.ts +0 -138
- package/src/planner/nodes/values-node.ts +0 -244
- package/src/planner/nodes/view-reference-node.ts +0 -97
- package/src/planner/nodes/window-function.ts +0 -73
- package/src/planner/nodes/window-node.ts +0 -199
- package/src/planner/optimizer-tuning.ts +0 -105
- package/src/planner/optimizer.ts +0 -332
- package/src/planner/planning-context.ts +0 -190
- package/src/planner/resolve.ts +0 -101
- package/src/planner/rules/README.md +0 -96
- package/src/planner/rules/access/rule-select-access-path.ts +0 -399
- package/src/planner/rules/aggregate/rule-aggregate-streaming.ts +0 -162
- package/src/planner/rules/cache/rule-cte-optimization.ts +0 -79
- package/src/planner/rules/cache/rule-materialization-advisory.ts +0 -77
- package/src/planner/rules/cache/rule-mutating-subquery-cache.ts +0 -104
- package/src/planner/rules/join/rule-join-greedy-commute.ts +0 -48
- package/src/planner/rules/join/rule-join-key-inference.ts +0 -35
- package/src/planner/rules/join/rule-quickpick-enumeration.ts +0 -267
- package/src/planner/rules/predicate/rule-predicate-pushdown.ts +0 -144
- package/src/planner/rules/retrieve/rule-grow-retrieve.ts +0 -337
- package/src/planner/scopes/aliased.ts +0 -50
- package/src/planner/scopes/base.ts +0 -10
- package/src/planner/scopes/empty.ts +0 -12
- package/src/planner/scopes/global.ts +0 -73
- package/src/planner/scopes/multi.ts +0 -40
- package/src/planner/scopes/param.ts +0 -95
- package/src/planner/scopes/registered.ts +0 -67
- package/src/planner/scopes/scope.ts +0 -16
- package/src/planner/stats/basic-estimates.ts +0 -107
- package/src/planner/stats/index.ts +0 -158
- package/src/planner/type-utils.ts +0 -87
- package/src/planner/util/key-utils.ts +0 -46
- package/src/planner/validation/determinism-validator.ts +0 -104
- package/src/planner/validation/plan-validator.ts +0 -335
- package/src/runtime/async-util.ts +0 -283
- package/src/runtime/cache/shared-cache.ts +0 -169
- package/src/runtime/context-helpers.ts +0 -191
- package/src/runtime/deferred-constraint-queue.ts +0 -196
- package/src/runtime/emission-context.ts +0 -319
- package/src/runtime/emit/add-constraint.ts +0 -78
- package/src/runtime/emit/aggregate.ts +0 -581
- package/src/runtime/emit/array-index.ts +0 -25
- package/src/runtime/emit/between.ts +0 -51
- package/src/runtime/emit/binary.ts +0 -357
- package/src/runtime/emit/block.ts +0 -23
- package/src/runtime/emit/cache.ts +0 -64
- package/src/runtime/emit/case.ts +0 -87
- package/src/runtime/emit/cast.ts +0 -151
- package/src/runtime/emit/collate.ts +0 -9
- package/src/runtime/emit/column-reference.ts +0 -17
- package/src/runtime/emit/constraint-check.ts +0 -290
- package/src/runtime/emit/create-assertion.ts +0 -82
- package/src/runtime/emit/create-index.ts +0 -15
- package/src/runtime/emit/create-table.ts +0 -15
- package/src/runtime/emit/create-view.ts +0 -52
- package/src/runtime/emit/cte-reference.ts +0 -38
- package/src/runtime/emit/cte.ts +0 -39
- package/src/runtime/emit/delete.ts +0 -24
- package/src/runtime/emit/distinct.ts +0 -40
- package/src/runtime/emit/dml-executor.ts +0 -198
- package/src/runtime/emit/drop-assertion.ts +0 -45
- package/src/runtime/emit/drop-table.ts +0 -27
- package/src/runtime/emit/drop-view.ts +0 -49
- package/src/runtime/emit/filter.ts +0 -30
- package/src/runtime/emit/insert.ts +0 -42
- package/src/runtime/emit/internal-recursive-cte-ref.ts +0 -37
- package/src/runtime/emit/join.ts +0 -148
- package/src/runtime/emit/limit-offset.ts +0 -73
- package/src/runtime/emit/literal.ts +0 -17
- package/src/runtime/emit/parameter.ts +0 -59
- package/src/runtime/emit/pragma.ts +0 -56
- package/src/runtime/emit/project.ts +0 -46
- package/src/runtime/emit/recursive-cte.ts +0 -111
- package/src/runtime/emit/remote-query.ts +0 -47
- package/src/runtime/emit/retrieve.ts +0 -15
- package/src/runtime/emit/returning.ts +0 -41
- package/src/runtime/emit/scalar-function.ts +0 -69
- package/src/runtime/emit/scan.ts +0 -106
- package/src/runtime/emit/schema-declarative.ts +0 -215
- package/src/runtime/emit/sequencing.ts +0 -24
- package/src/runtime/emit/set-operation.ts +0 -141
- package/src/runtime/emit/sink.ts +0 -27
- package/src/runtime/emit/sort.ts +0 -75
- package/src/runtime/emit/subquery.ts +0 -203
- package/src/runtime/emit/table-valued-function.ts +0 -106
- package/src/runtime/emit/temporal-arithmetic.ts +0 -302
- package/src/runtime/emit/transaction.ts +0 -205
- package/src/runtime/emit/unary.ts +0 -101
- package/src/runtime/emit/update.ts +0 -66
- package/src/runtime/emit/values.ts +0 -66
- package/src/runtime/emit/window-function.ts +0 -42
- package/src/runtime/emit/window.ts +0 -458
- package/src/runtime/emitters.ts +0 -183
- package/src/runtime/register.ts +0 -150
- package/src/runtime/scheduler.ts +0 -488
- package/src/runtime/types.ts +0 -242
- package/src/runtime/utils.ts +0 -177
- package/src/schema/assertion.ts +0 -21
- package/src/schema/catalog.ts +0 -269
- package/src/schema/change-events.ts +0 -80
- package/src/schema/column.ts +0 -51
- package/src/schema/declared-schema-manager.ts +0 -82
- package/src/schema/function.ts +0 -188
- package/src/schema/manager.ts +0 -1034
- package/src/schema/schema-differ.ts +0 -214
- package/src/schema/schema-hasher.ts +0 -26
- package/src/schema/schema.ts +0 -222
- package/src/schema/table.ts +0 -409
- package/src/schema/view.ts +0 -19
- package/src/schema/window-function.ts +0 -56
- package/src/types/builtin-types.ts +0 -350
- package/src/types/index.ts +0 -17
- package/src/types/json-type.ts +0 -152
- package/src/types/logical-type.ts +0 -91
- package/src/types/plugin-interface.ts +0 -10
- package/src/types/registry.ts +0 -204
- package/src/types/temporal-types.ts +0 -290
- package/src/types/validation.ts +0 -120
- package/src/util/affinity.ts +0 -151
- package/src/util/ast-stringify.ts +0 -887
- package/src/util/cached.ts +0 -25
- package/src/util/coercion.ts +0 -113
- package/src/util/comparison.ts +0 -510
- package/src/util/environment.ts +0 -52
- package/src/util/hash.ts +0 -90
- package/src/util/latches.ts +0 -47
- package/src/util/mutation-statement.ts +0 -135
- package/src/util/patterns.ts +0 -56
- package/src/util/plan-formatter.ts +0 -48
- package/src/util/plugin-helper.ts +0 -110
- package/src/util/row-descriptor.ts +0 -105
- package/src/util/serialization.ts +0 -47
- package/src/util/sql-literal.ts +0 -22
- package/src/util/working-table-iterable.ts +0 -38
- package/src/vtab/best-access-plan.ts +0 -244
- package/src/vtab/connection.ts +0 -36
- package/src/vtab/filter-info.ts +0 -23
- package/src/vtab/index-info.ts +0 -84
- package/src/vtab/manifest.ts +0 -86
- package/src/vtab/memory/connection.ts +0 -73
- package/src/vtab/memory/index.ts +0 -191
- package/src/vtab/memory/layer/base-cursor.ts +0 -124
- package/src/vtab/memory/layer/base.ts +0 -275
- package/src/vtab/memory/layer/connection.ts +0 -203
- package/src/vtab/memory/layer/interface.ts +0 -47
- package/src/vtab/memory/layer/manager.ts +0 -909
- package/src/vtab/memory/layer/safe-iterate.ts +0 -49
- package/src/vtab/memory/layer/scan-plan.ts +0 -84
- package/src/vtab/memory/layer/transaction-cursor.ts +0 -162
- package/src/vtab/memory/layer/transaction.ts +0 -229
- package/src/vtab/memory/module.ts +0 -667
- package/src/vtab/memory/table.ts +0 -251
- package/src/vtab/memory/types.ts +0 -23
- package/src/vtab/memory/utils/logging.ts +0 -36
- package/src/vtab/memory/utils/primary-key.ts +0 -163
- package/src/vtab/module.ts +0 -162
- package/src/vtab/table.ts +0 -177
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import { PlanNodeType } from './plan-node-type.js';
|
|
2
|
-
import { PlanNode, type RelationalPlanNode, type ScalarPlanNode, type UnaryRelationalNode, type Attribute, isRelationalNode, type PhysicalProperties } from './plan-node.js';
|
|
3
|
-
import { ColumnReferenceNode } from './reference.js';
|
|
4
|
-
import type { RelationType } from '../../common/datatype.js';
|
|
5
|
-
import type { Scope } from '../scopes/scope.js';
|
|
6
|
-
import { Cached } from '../../util/cached.js';
|
|
7
|
-
import { formatExpressionList } from '../../util/plan-formatter.js';
|
|
8
|
-
import { StatusCode } from '../../common/types.js';
|
|
9
|
-
import { quereusError } from '../../common/errors.js';
|
|
10
|
-
import type { AggregationCapable } from '../framework/characteristics.js';
|
|
11
|
-
|
|
12
|
-
export interface AggregateExpression {
|
|
13
|
-
expression: ScalarPlanNode;
|
|
14
|
-
alias: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Logical node representing an aggregate operation.
|
|
19
|
-
* Requires transformation to StreamAggregateNode or HashAggregateNode by optimizer.
|
|
20
|
-
*/
|
|
21
|
-
export class AggregateNode extends PlanNode implements UnaryRelationalNode, AggregationCapable {
|
|
22
|
-
override readonly nodeType = PlanNodeType.Aggregate;
|
|
23
|
-
|
|
24
|
-
private outputTypeCache: Cached<RelationType>;
|
|
25
|
-
private attributesCache: Cached<Attribute[]>;
|
|
26
|
-
|
|
27
|
-
constructor(
|
|
28
|
-
scope: Scope,
|
|
29
|
-
public readonly source: RelationalPlanNode,
|
|
30
|
-
public readonly groupBy: readonly ScalarPlanNode[],
|
|
31
|
-
public readonly aggregates: readonly AggregateExpression[],
|
|
32
|
-
estimatedCostOverride?: number,
|
|
33
|
-
public readonly preserveAttributeIds?: readonly Attribute[]
|
|
34
|
-
) {
|
|
35
|
-
super(scope, estimatedCostOverride ?? source.getTotalCost());
|
|
36
|
-
|
|
37
|
-
this.outputTypeCache = new Cached(() => this.buildOutputType());
|
|
38
|
-
this.attributesCache = new Cached(() => this.buildAttributes());
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Helper function to extract a meaningful name from a GROUP BY expression
|
|
42
|
-
private getGroupByColumnName(expr: ScalarPlanNode, index: number): string {
|
|
43
|
-
// If it's a column reference, use the column name
|
|
44
|
-
if (expr.nodeType === PlanNodeType.ColumnReference) {
|
|
45
|
-
const colRef = expr as ColumnReferenceNode;
|
|
46
|
-
return colRef.expression.name;
|
|
47
|
-
}
|
|
48
|
-
// Otherwise, use a generic name
|
|
49
|
-
return `group_${index}`;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
private buildOutputType(): RelationType {
|
|
53
|
-
// Build the output relation type based on group by columns and aggregates
|
|
54
|
-
const columns = [
|
|
55
|
-
// Group by columns come first
|
|
56
|
-
...this.groupBy.map((expr, index) => ({
|
|
57
|
-
name: this.getGroupByColumnName(expr, index),
|
|
58
|
-
type: expr.getType(),
|
|
59
|
-
generated: false
|
|
60
|
-
})),
|
|
61
|
-
// Then aggregate columns
|
|
62
|
-
...this.aggregates.map(agg => ({
|
|
63
|
-
name: agg.alias,
|
|
64
|
-
type: agg.expression.getType(),
|
|
65
|
-
generated: true
|
|
66
|
-
}))
|
|
67
|
-
];
|
|
68
|
-
|
|
69
|
-
// Determine if result is a set
|
|
70
|
-
// - Without GROUP BY: always produces exactly 1 row, so it's a set
|
|
71
|
-
// - With GROUP BY: produces one row per unique group, so it's a set
|
|
72
|
-
const isSet = true;
|
|
73
|
-
|
|
74
|
-
return {
|
|
75
|
-
typeClass: 'relation',
|
|
76
|
-
columns,
|
|
77
|
-
keys: [], // No keys for aggregate results
|
|
78
|
-
rowConstraints: [], // No row constraints for aggregate results
|
|
79
|
-
isReadOnly: true,
|
|
80
|
-
isSet
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
private buildAttributes(): Attribute[] {
|
|
85
|
-
// If we have preserved attribute IDs, use them
|
|
86
|
-
if (this.preserveAttributeIds) {
|
|
87
|
-
return this.preserveAttributeIds.slice(); // Return a copy
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const attributes: Attribute[] = [];
|
|
91
|
-
|
|
92
|
-
// Group by columns come first
|
|
93
|
-
this.groupBy.forEach((expr, index) => {
|
|
94
|
-
const name = this.getGroupByColumnName(expr, index);
|
|
95
|
-
attributes.push({
|
|
96
|
-
id: PlanNode.nextAttrId(),
|
|
97
|
-
name,
|
|
98
|
-
type: expr.getType(),
|
|
99
|
-
sourceRelation: `${this.nodeType}:${this.id}`,
|
|
100
|
-
relationName: 'aggregate' // AggregateNode creates new relation context
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
// Then aggregate columns
|
|
105
|
-
this.aggregates.forEach((agg) => {
|
|
106
|
-
attributes.push({
|
|
107
|
-
id: PlanNode.nextAttrId(),
|
|
108
|
-
name: agg.alias,
|
|
109
|
-
type: agg.expression.getType(),
|
|
110
|
-
sourceRelation: `${this.nodeType}:${this.id}`,
|
|
111
|
-
relationName: 'aggregate' // AggregateNode creates new relation context
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
return attributes;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
getType(): RelationType {
|
|
119
|
-
return this.outputTypeCache.value;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
getAttributes(): readonly Attribute[] {
|
|
123
|
-
return this.attributesCache.value;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
getChildren(): readonly PlanNode[] {
|
|
127
|
-
return [this.source, ...this.groupBy, ...this.aggregates.map(agg => agg.expression)];
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
getRelations(): readonly [RelationalPlanNode] {
|
|
131
|
-
return [this.source];
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
withChildren(newChildren: readonly PlanNode[]): PlanNode {
|
|
135
|
-
const expectedLength = 1 + this.groupBy.length + this.aggregates.length;
|
|
136
|
-
if (newChildren.length !== expectedLength) {
|
|
137
|
-
quereusError(`AggregateNode expects ${expectedLength} children, got ${newChildren.length}`, StatusCode.INTERNAL);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const [newSource, ...restChildren] = newChildren;
|
|
141
|
-
const newGroupBy = restChildren.slice(0, this.groupBy.length);
|
|
142
|
-
const newAggregateExpressions = restChildren.slice(this.groupBy.length);
|
|
143
|
-
|
|
144
|
-
// Type check
|
|
145
|
-
if (!isRelationalNode(newSource)) {
|
|
146
|
-
quereusError('AggregateNode: first child must be a RelationalPlanNode', StatusCode.INTERNAL);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Check if anything changed
|
|
150
|
-
const sourceChanged = newSource !== this.source;
|
|
151
|
-
const groupByChanged = newGroupBy.some((expr, i) => expr !== this.groupBy[i]);
|
|
152
|
-
const aggregatesChanged = newAggregateExpressions.some((expr, i) => expr !== this.aggregates[i].expression);
|
|
153
|
-
|
|
154
|
-
if (!sourceChanged && !groupByChanged && !aggregatesChanged) {
|
|
155
|
-
return this;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Build new aggregates array
|
|
159
|
-
const newAggregates = newAggregateExpressions.map((expr, i) => ({
|
|
160
|
-
expression: expr as ScalarPlanNode,
|
|
161
|
-
alias: this.aggregates[i].alias
|
|
162
|
-
}));
|
|
163
|
-
|
|
164
|
-
// Create new instance that preserves original attribute IDs
|
|
165
|
-
return new AggregateNode(
|
|
166
|
-
this.scope,
|
|
167
|
-
newSource as RelationalPlanNode,
|
|
168
|
-
newGroupBy as ScalarPlanNode[],
|
|
169
|
-
newAggregates,
|
|
170
|
-
undefined, // estimatedCostOverride
|
|
171
|
-
this.getAttributes() // Preserve original attribute IDs
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
get estimatedRows(): number | undefined {
|
|
176
|
-
const sourceRows = this.source.estimatedRows;
|
|
177
|
-
if (sourceRows === undefined) return undefined;
|
|
178
|
-
|
|
179
|
-
// If we have GROUP BY, the output rows depend on the number of distinct groups
|
|
180
|
-
// For now, we'll use a conservative estimate
|
|
181
|
-
if (this.groupBy.length > 0) {
|
|
182
|
-
// Estimate that we'll have at most sourceRows/2 groups, but at least 1
|
|
183
|
-
return Math.max(1, Math.floor(sourceRows / 2));
|
|
184
|
-
} else {
|
|
185
|
-
// No GROUP BY means we're aggregating the entire table into a single row
|
|
186
|
-
return 1;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
computePhysical(childrenPhysical: PhysicalProperties[]): Partial<PhysicalProperties> {
|
|
191
|
-
const sourcePhysical = childrenPhysical[0];
|
|
192
|
-
const groupCount = this.groupBy.length;
|
|
193
|
-
// If there is a GROUP BY, the group-by columns form a unique key on the output
|
|
194
|
-
// Output attribute indices for group-by are 0..groupCount-1 per buildAttributes
|
|
195
|
-
const uniqueKeys = groupCount > 0 ? [Array.from({ length: groupCount }, (_, i) => i)] : [[]];
|
|
196
|
-
return {
|
|
197
|
-
uniqueKeys,
|
|
198
|
-
estimatedRows: this.estimatedRows,
|
|
199
|
-
ordering: sourcePhysical?.ordering,
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
override toString(): string {
|
|
204
|
-
const parts: string[] = [];
|
|
205
|
-
|
|
206
|
-
if (this.groupBy.length > 0) {
|
|
207
|
-
parts.push(`GROUP BY ${formatExpressionList(this.groupBy)}`);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (this.aggregates.length > 0) {
|
|
211
|
-
const aggregatesStr = this.aggregates.map(agg =>
|
|
212
|
-
`${agg.expression.toString()} AS ${agg.alias}`
|
|
213
|
-
).join(', ');
|
|
214
|
-
parts.push(`AGG ${aggregatesStr}`);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
return parts.join(' ');
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
override getLogicalAttributes(): Record<string, unknown> {
|
|
221
|
-
const props: Record<string, unknown> = {};
|
|
222
|
-
|
|
223
|
-
if (this.groupBy.length > 0) {
|
|
224
|
-
props.groupBy = this.groupBy.map(expr => expr.toString());
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
if (this.aggregates.length > 0) {
|
|
228
|
-
props.aggregates = this.aggregates.map(agg => ({
|
|
229
|
-
expression: agg.expression.toString(),
|
|
230
|
-
alias: agg.alias
|
|
231
|
-
}));
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// Expose logical unique keys: group-by columns (0..groupCount-1) or [[]] for global aggregate
|
|
235
|
-
const groupCount = this.groupBy.length;
|
|
236
|
-
(props as any).uniqueKeys = groupCount > 0 ? [Array.from({ length: groupCount }, (_, i) => i)] : [[]];
|
|
237
|
-
return props;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// AggregationCapable interface implementation
|
|
241
|
-
getGroupingKeys(): readonly ScalarPlanNode[] {
|
|
242
|
-
return this.groupBy;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
getAggregateExpressions(): readonly { expr: ScalarPlanNode; alias: string; attributeId: number }[] {
|
|
246
|
-
const attributes = this.getAttributes();
|
|
247
|
-
const groupByCount = this.groupBy.length;
|
|
248
|
-
|
|
249
|
-
return this.aggregates.map((agg, index) => ({
|
|
250
|
-
expr: agg.expression,
|
|
251
|
-
alias: agg.alias,
|
|
252
|
-
attributeId: attributes[groupByCount + index].id
|
|
253
|
-
}));
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
requiresOrdering(): boolean {
|
|
257
|
-
return this.groupBy.length > 0; // Only requires ordering if we have GROUP BY
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
canStreamAggregate(): boolean {
|
|
261
|
-
return true; // AggregateNode can always be converted to streaming
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
getSource(): RelationalPlanNode {
|
|
265
|
-
return this.source;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { PlanNodeType } from './plan-node-type.js';
|
|
2
|
-
import { PlanNode, type ZeroAryScalarNode } from './plan-node.js';
|
|
3
|
-
import type { ScalarType } from '../../common/datatype.js';
|
|
4
|
-
import type { Scope } from '../scopes/scope.js';
|
|
5
|
-
import type * as AST from '../../parser/ast.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Represents direct access to a value in a row by array index.
|
|
9
|
-
* This is used when we know the exact position of a value in the output row.
|
|
10
|
-
*/
|
|
11
|
-
export class ArrayIndexNode extends PlanNode implements ZeroAryScalarNode {
|
|
12
|
-
override readonly nodeType = PlanNodeType.ArrayIndex;
|
|
13
|
-
public readonly expression: AST.Expression;
|
|
14
|
-
|
|
15
|
-
constructor(
|
|
16
|
-
scope: Scope,
|
|
17
|
-
public readonly index: number,
|
|
18
|
-
public readonly type: ScalarType
|
|
19
|
-
) {
|
|
20
|
-
super(scope);
|
|
21
|
-
// Create a synthetic expression for this array access
|
|
22
|
-
this.expression = {
|
|
23
|
-
type: 'literal',
|
|
24
|
-
value: `[${index}]`
|
|
25
|
-
} satisfies AST.LiteralExpr;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
getType(): ScalarType {
|
|
29
|
-
return this.type;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
getChildren(): readonly [] {
|
|
33
|
-
return [];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
getRelations(): readonly [] {
|
|
37
|
-
return [];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
withChildren(newChildren: readonly PlanNode[]): PlanNode {
|
|
41
|
-
if (newChildren.length !== 0) {
|
|
42
|
-
throw new Error(`ArrayIndexNode expects 0 children, got ${newChildren.length}`);
|
|
43
|
-
}
|
|
44
|
-
return this; // No children, so no change
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
override toString(): string {
|
|
48
|
-
return `[${this.index}]`;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { PlanNodeType } from './plan-node-type.js';
|
|
2
|
-
import { PlanNode, type RelationalPlanNode } from './plan-node.js';
|
|
3
|
-
import type { BaseType } from '../../common/datatype.js';
|
|
4
|
-
import type { Scope } from '../scopes/scope.js';
|
|
5
|
-
import type { SqlParameters } from '../../common/types.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Represents a block of one or more statements to be executed in sequence.
|
|
9
|
-
* This is the root of most SQL query plans.
|
|
10
|
-
*/
|
|
11
|
-
export class BlockNode extends PlanNode {
|
|
12
|
-
override readonly nodeType = PlanNodeType.Block;
|
|
13
|
-
|
|
14
|
-
constructor(
|
|
15
|
-
scope: Scope,
|
|
16
|
-
public readonly statements: PlanNode[],
|
|
17
|
-
/** Snapshot of parameters utilized by the block. */
|
|
18
|
-
public readonly parameters: SqlParameters,
|
|
19
|
-
estimatedCostOverride?: number
|
|
20
|
-
) {
|
|
21
|
-
// Cost: sum of all statement costs
|
|
22
|
-
const totalCost = statements.reduce((sum, stmt) => sum + stmt.getTotalCost(), 0);
|
|
23
|
-
super(scope, estimatedCostOverride ?? totalCost);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
getType(): BaseType {
|
|
27
|
-
// A block doesn't have a well-defined type; it's context-dependent
|
|
28
|
-
return { typeClass: 'void' };
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
getChildren(): readonly PlanNode[] {
|
|
32
|
-
return this.statements;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
getRelations(): readonly RelationalPlanNode[] {
|
|
36
|
-
return this.statements.filter(s => s.getType().typeClass === "relation") as unknown as readonly RelationalPlanNode[];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
override toString(): string {
|
|
40
|
-
return `${this.statements.length} statements`;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
override getLogicalAttributes(): Record<string, unknown> {
|
|
44
|
-
return {
|
|
45
|
-
numStatements: this.statements.length,
|
|
46
|
-
statementTypes: this.statements.map(stmt => stmt.nodeType),
|
|
47
|
-
parameters: Object.keys(this.parameters)
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
get estimatedRows(): number | undefined {
|
|
52
|
-
return this.getRelations().reduce((acc, s) => acc + (s.estimatedRows ?? 0), 0);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
withChildren(newChildren: readonly PlanNode[]): PlanNode {
|
|
56
|
-
// Check if statements changed
|
|
57
|
-
if (newChildren.length !== this.statements.length) {
|
|
58
|
-
// Create new instance with new statements
|
|
59
|
-
return new BlockNode(
|
|
60
|
-
this.scope,
|
|
61
|
-
[...newChildren],
|
|
62
|
-
this.parameters
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Check if any individual statement changed
|
|
67
|
-
const statementsChanged = newChildren.some((child, i) => child !== this.statements[i]);
|
|
68
|
-
|
|
69
|
-
if (!statementsChanged) {
|
|
70
|
-
return this;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Create new instance with updated statements
|
|
74
|
-
return new BlockNode(
|
|
75
|
-
this.scope,
|
|
76
|
-
[...newChildren],
|
|
77
|
-
this.parameters
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { PlanNodeType } from './plan-node-type.js';
|
|
2
|
-
import { PlanNode, type RelationalPlanNode, type UnaryRelationalNode, type Attribute, isRelationalNode } from './plan-node.js';
|
|
3
|
-
import type { RelationType } from '../../common/datatype.js';
|
|
4
|
-
import type { Scope } from '../scopes/scope.js';
|
|
5
|
-
import { StatusCode } from '../../common/types.js';
|
|
6
|
-
import { quereusError } from '../../common/errors.js';
|
|
7
|
-
import type { CacheCapable } from '../framework/characteristics.js';
|
|
8
|
-
|
|
9
|
-
export type CacheStrategy = 'memory' | 'spill'; // Future: spill-to-disk
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* CacheNode provides smart caching for any relational input.
|
|
13
|
-
*
|
|
14
|
-
* This node materializes its input on first iteration and serves
|
|
15
|
-
* subsequent iterations from the cached result. It implements
|
|
16
|
-
* smart threshold-based policies to avoid excessive memory usage.
|
|
17
|
-
*/
|
|
18
|
-
export class CacheNode extends PlanNode implements UnaryRelationalNode, CacheCapable {
|
|
19
|
-
readonly nodeType = PlanNodeType.Cache;
|
|
20
|
-
|
|
21
|
-
constructor(
|
|
22
|
-
scope: Scope,
|
|
23
|
-
public readonly source: RelationalPlanNode,
|
|
24
|
-
public readonly strategy: CacheStrategy = 'memory',
|
|
25
|
-
public readonly threshold: number = 10000, // Rows before switching to pass-through
|
|
26
|
-
estimatedCostOverride?: number
|
|
27
|
-
) {
|
|
28
|
-
super(scope, estimatedCostOverride);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Cache preserves source attributes exactly
|
|
32
|
-
getAttributes(): readonly Attribute[] {
|
|
33
|
-
return this.source.getAttributes();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
getType(): RelationType {
|
|
37
|
-
const sourceType = this.source.getType();
|
|
38
|
-
// Cache preserves all properties of the source relation
|
|
39
|
-
return {
|
|
40
|
-
...sourceType,
|
|
41
|
-
// Note: Caching doesn't change the logical properties
|
|
42
|
-
// but may affect physical properties like ordering
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
getChildren(): readonly [RelationalPlanNode] {
|
|
47
|
-
return [this.source];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
getRelations(): readonly [RelationalPlanNode] {
|
|
51
|
-
return [this.source];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
withChildren(newChildren: readonly PlanNode[]): PlanNode {
|
|
55
|
-
if (newChildren.length !== 1) {
|
|
56
|
-
quereusError(`CacheNode expects 1 child, got ${newChildren.length}`, StatusCode.INTERNAL);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const [newSource] = newChildren;
|
|
60
|
-
|
|
61
|
-
// Type check
|
|
62
|
-
if (!isRelationalNode(newSource)) {
|
|
63
|
-
quereusError('CacheNode: child must be a RelationalPlanNode', StatusCode.INTERNAL);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Return same instance if nothing changed
|
|
67
|
-
if (newSource === this.source) {
|
|
68
|
-
return this;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Create new instance preserving attributes (cache preserves source attributes exactly)
|
|
72
|
-
return new CacheNode(
|
|
73
|
-
this.scope,
|
|
74
|
-
newSource as RelationalPlanNode,
|
|
75
|
-
this.strategy,
|
|
76
|
-
this.threshold
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
get estimatedRows(): number | undefined {
|
|
81
|
-
return this.source.estimatedRows;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
getCacheStrategy(): string {
|
|
85
|
-
return this.strategy;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
isCached(): boolean {
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
override toString(): string {
|
|
93
|
-
return `CACHE (${this.strategy}, threshold=${this.threshold})`;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
override getLogicalAttributes(): Record<string, unknown> {
|
|
97
|
-
return {
|
|
98
|
-
strategy: this.strategy,
|
|
99
|
-
threshold: this.threshold,
|
|
100
|
-
sourceNodeType: this.source.nodeType
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import type { Scope } from '../scopes/scope.js';
|
|
2
|
-
import { PlanNode, type RelationalPlanNode, type Attribute, type RowDescriptor, type ScalarPlanNode, isRelationalNode, isScalarNode } from './plan-node.js';
|
|
3
|
-
import { PlanNodeType } from './plan-node-type.js';
|
|
4
|
-
import type { TableReferenceNode } from './reference.js';
|
|
5
|
-
import type { RelationType } from '../../common/datatype.js';
|
|
6
|
-
import type { RowOpFlag } from '../../schema/table.js';
|
|
7
|
-
import type { RowConstraintSchema } from '../../schema/table.js';
|
|
8
|
-
|
|
9
|
-
export interface ConstraintCheck {
|
|
10
|
-
constraint: RowConstraintSchema; // The constraint metadata
|
|
11
|
-
expression: ScalarPlanNode; // Pre-built expression node
|
|
12
|
-
deferrable?: boolean;
|
|
13
|
-
initiallyDeferred?: boolean;
|
|
14
|
-
containsSubquery: boolean; // Cached result of subquery detection
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Represents constraint checking for DML operations.
|
|
19
|
-
* This node validates constraints against rows flowing through it.
|
|
20
|
-
*/
|
|
21
|
-
export class ConstraintCheckNode extends PlanNode implements RelationalPlanNode {
|
|
22
|
-
override readonly nodeType = PlanNodeType.ConstraintCheck;
|
|
23
|
-
|
|
24
|
-
constructor(
|
|
25
|
-
scope: Scope,
|
|
26
|
-
public readonly source: RelationalPlanNode,
|
|
27
|
-
public readonly table: TableReferenceNode,
|
|
28
|
-
public readonly operation: RowOpFlag,
|
|
29
|
-
public readonly oldRowDescriptor: RowDescriptor | undefined,
|
|
30
|
-
public readonly newRowDescriptor: RowDescriptor | undefined,
|
|
31
|
-
public readonly flatRowDescriptor: RowDescriptor,
|
|
32
|
-
public readonly constraintChecks: ConstraintCheck[],
|
|
33
|
-
public readonly mutationContextValues?: Map<string, ScalarPlanNode>, // Mutation context value expressions
|
|
34
|
-
public readonly contextAttributes?: Attribute[], // Mutation context attributes
|
|
35
|
-
public readonly contextDescriptor?: RowDescriptor, // Mutation context row descriptor
|
|
36
|
-
) {
|
|
37
|
-
super(scope);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
getType(): RelationType {
|
|
41
|
-
return this.source.getType();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
getAttributes(): readonly Attribute[] {
|
|
45
|
-
// ConstraintCheck passes through the same attributes as its source
|
|
46
|
-
return this.source.getAttributes();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
getRelations(): readonly [RelationalPlanNode, TableReferenceNode] {
|
|
50
|
-
return [this.source, this.table];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
getChildren(): readonly PlanNode[] {
|
|
54
|
-
const children: PlanNode[] = [this.source];
|
|
55
|
-
// Add all constraint expression nodes as children so optimizer can see them
|
|
56
|
-
this.constraintChecks.forEach(check => {
|
|
57
|
-
children.push(check.expression);
|
|
58
|
-
});
|
|
59
|
-
return children;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
withChildren(newChildren: readonly PlanNode[]): PlanNode {
|
|
63
|
-
const expectedChildren = 1 + this.constraintChecks.length;
|
|
64
|
-
if (newChildren.length !== expectedChildren) {
|
|
65
|
-
throw new Error(`ConstraintCheckNode expects ${expectedChildren} children, got ${newChildren.length}`);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const [newSource, ...newConstraintExprs] = newChildren;
|
|
69
|
-
|
|
70
|
-
// Type check the source
|
|
71
|
-
if (!isRelationalNode(newSource)) {
|
|
72
|
-
throw new Error('ConstraintCheckNode: first child must be a RelationalPlanNode');
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Type check constraint expressions
|
|
76
|
-
for (let i = 0; i < newConstraintExprs.length; i++) {
|
|
77
|
-
const expr = newConstraintExprs[i];
|
|
78
|
-
if (!isScalarNode(expr)) {
|
|
79
|
-
throw new Error(`ConstraintCheckNode: constraint child ${i + 1} must be a ScalarPlanNode`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Return same instance if nothing changed
|
|
84
|
-
if (newSource === this.source &&
|
|
85
|
-
newConstraintExprs.every((expr, i) => expr === this.constraintChecks[i].expression)) {
|
|
86
|
-
return this;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Rebuild constraint checks with new expressions
|
|
90
|
-
const newConstraintChecks = this.constraintChecks.map((check, i) => ({
|
|
91
|
-
...check,
|
|
92
|
-
expression: newConstraintExprs[i] as ScalarPlanNode
|
|
93
|
-
}));
|
|
94
|
-
|
|
95
|
-
// Create new instance
|
|
96
|
-
return new ConstraintCheckNode(
|
|
97
|
-
this.scope,
|
|
98
|
-
newSource as RelationalPlanNode,
|
|
99
|
-
this.table,
|
|
100
|
-
this.operation,
|
|
101
|
-
this.oldRowDescriptor,
|
|
102
|
-
this.newRowDescriptor,
|
|
103
|
-
this.flatRowDescriptor,
|
|
104
|
-
newConstraintChecks,
|
|
105
|
-
this.mutationContextValues,
|
|
106
|
-
this.contextAttributes,
|
|
107
|
-
this.contextDescriptor
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
get estimatedRows(): number | undefined {
|
|
112
|
-
return this.source.estimatedRows;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
override toString(): string {
|
|
116
|
-
const opName = this.operation === 1 ? 'INSERT' :
|
|
117
|
-
this.operation === 2 ? 'UPDATE' :
|
|
118
|
-
this.operation === 4 ? 'DELETE' : 'UNKNOWN';
|
|
119
|
-
const constraintCount = this.constraintChecks.length;
|
|
120
|
-
return `CHECK ${constraintCount} CONSTRAINTS ON ${opName}`;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
override getLogicalAttributes(): Record<string, unknown> {
|
|
124
|
-
const opName = this.operation === 1 ? 'INSERT' :
|
|
125
|
-
this.operation === 2 ? 'UPDATE' :
|
|
126
|
-
this.operation === 4 ? 'DELETE' : 'UNKNOWN';
|
|
127
|
-
|
|
128
|
-
return {
|
|
129
|
-
table: this.table.tableSchema.name,
|
|
130
|
-
schema: this.table.tableSchema.schemaName,
|
|
131
|
-
operation: opName,
|
|
132
|
-
constraintCount: this.constraintChecks.length,
|
|
133
|
-
constraintNames: this.constraintChecks.map(c => c.constraint.name || '_unnamed'),
|
|
134
|
-
hasOldDescriptor: !!this.oldRowDescriptor,
|
|
135
|
-
hasNewDescriptor: !!this.newRowDescriptor,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { Scope } from '../scopes/scope.js';
|
|
2
|
-
import { PlanNode, type VoidNode, type PhysicalProperties } from './plan-node.js';
|
|
3
|
-
import { PlanNodeType } from './plan-node-type.js';
|
|
4
|
-
import type { VoidType } from '../../common/datatype.js';
|
|
5
|
-
import type * as AST from '../../parser/ast.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Represents creating a global integrity assertion.
|
|
9
|
-
* This is a DDL operation that adds an assertion to the schema.
|
|
10
|
-
*/
|
|
11
|
-
export class CreateAssertionNode extends PlanNode implements VoidNode {
|
|
12
|
-
override readonly nodeType = PlanNodeType.CreateAssertion;
|
|
13
|
-
|
|
14
|
-
constructor(
|
|
15
|
-
scope: Scope,
|
|
16
|
-
public readonly name: string,
|
|
17
|
-
public readonly checkExpression: AST.Expression,
|
|
18
|
-
) {
|
|
19
|
-
super(scope);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
getType(): VoidType {
|
|
23
|
-
return { typeClass: 'void' };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
getChildren(): readonly PlanNode[] {
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
withChildren(newChildren: readonly PlanNode[]): PlanNode {
|
|
31
|
-
if (newChildren.length !== 0) {
|
|
32
|
-
throw new Error(`CreateAssertionNode expects 0 children, got ${newChildren.length}`);
|
|
33
|
-
}
|
|
34
|
-
return this; // No children, so no change
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
override toString(): string {
|
|
38
|
-
return `CREATE ASSERTION ${this.name}`;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
override getLogicalAttributes(): Record<string, unknown> {
|
|
42
|
-
return {
|
|
43
|
-
name: this.name,
|
|
44
|
-
checkExpression: this.checkExpression.toString?.() || 'complex expression',
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
override computePhysical(_children: readonly PhysicalProperties[]): Partial<PhysicalProperties> {
|
|
49
|
-
return { readonly: false };
|
|
50
|
-
}
|
|
51
|
-
}
|