@quereus/quereus 0.7.2 → 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,337 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rule: Grow Retrieve
|
|
3
|
-
*
|
|
4
|
-
* Structural sliding rule that maximizes the query segment each virtual table module can execute.
|
|
5
|
-
* This is a bottom-up transformation that slides RetrieveNode boundaries upward to encompass
|
|
6
|
-
* as much of the query pipeline as each module can handle.
|
|
7
|
-
*
|
|
8
|
-
* Applied When:
|
|
9
|
-
* - Node is a unary relational operation (Filter, Project, Sort, LimitOffset)
|
|
10
|
-
* - Child is a RetrieveNode
|
|
11
|
-
* - Virtual table module supports executing the expanded pipeline
|
|
12
|
-
*
|
|
13
|
-
* Benefits:
|
|
14
|
-
* - Maximizes push-down opportunities for query-based modules
|
|
15
|
-
* - Provides fallback support for index-style modules via constraint extraction
|
|
16
|
-
* - Establishes optimal module execution boundaries before cost-based optimization
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import { createLogger } from '../../../common/logger.js';
|
|
20
|
-
import { isRelationalNode, type PlanNode, type RelationalPlanNode } from '../../nodes/plan-node.js';
|
|
21
|
-
import type { OptContext } from '../../framework/context.js';
|
|
22
|
-
import { RetrieveNode } from '../../nodes/retrieve-node.js';
|
|
23
|
-
import { FilterNode } from '../../nodes/filter.js';
|
|
24
|
-
import type { TableReferenceNode } from '../../nodes/reference.js';
|
|
25
|
-
import { PlanNodeType } from '../../nodes/plan-node-type.js';
|
|
26
|
-
import type { SupportAssessment } from '../../../vtab/module.js';
|
|
27
|
-
import type { BestAccessPlanRequest, BestAccessPlanResult, PredicateConstraint } from '../../../vtab/best-access-plan.js';
|
|
28
|
-
import { extractConstraints, createTableInfoFromNode, type TableInfo } from '../../analysis/constraint-extractor.js';
|
|
29
|
-
import { normalizePredicate } from '../../analysis/predicate-normalizer.js';
|
|
30
|
-
import { seqScanCost } from '../../cost/index.js';
|
|
31
|
-
import { SortNode } from '../../nodes/sort.js';
|
|
32
|
-
import { extractOrderingFromSortKeys } from '../../framework/physical-utils.js';
|
|
33
|
-
import { LimitOffsetNode } from '../../nodes/limit-offset.js';
|
|
34
|
-
import { PlanNode as _PlanNode } from '../../nodes/plan-node.js';
|
|
35
|
-
import { PlanNodeType as _PlanNodeType } from '../../nodes/plan-node-type.js';
|
|
36
|
-
import { LiteralNode } from '../../nodes/scalar.js';
|
|
37
|
-
import { collectBindingsInPlan } from '../../analysis/binding-collector.js';
|
|
38
|
-
|
|
39
|
-
const log = createLogger('optimizer:rule:grow-retrieve');
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Context data stored in RetrieveNode.moduleCtx for index-style fallback
|
|
43
|
-
*/
|
|
44
|
-
interface IndexStyleContext {
|
|
45
|
-
kind: 'index-style';
|
|
46
|
-
accessPlan: BestAccessPlanResult;
|
|
47
|
-
residualPredicate?: PlanNode;
|
|
48
|
-
originalConstraints: PredicateConstraint[];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function isIndexStyleContext(ctx: unknown): ctx is IndexStyleContext {
|
|
52
|
-
return !!ctx && typeof ctx === 'object' && (ctx as any).kind === 'index-style';
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function ruleGrowRetrieve(node: PlanNode, context: OptContext): PlanNode | null {
|
|
56
|
-
// This rule runs in a TOP-DOWN pass, looking for any relational operation
|
|
57
|
-
// above a RetrieveNode that can be pushed into the module's execution boundary
|
|
58
|
-
|
|
59
|
-
// Must be a relational node to be growable
|
|
60
|
-
if (!isRelationalNode(node)) {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Find the RetrieveNode child (if any)
|
|
65
|
-
const retrieveChild = findRetrieveChild(node);
|
|
66
|
-
if (!retrieveChild) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const tableRef = retrieveChild.tableRef;
|
|
71
|
-
|
|
72
|
-
// Guard: ensure we have required properties
|
|
73
|
-
if (!tableRef?.tableSchema) {
|
|
74
|
-
log('RetrieveNode missing tableRef or tableSchema');
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const tableSchema = tableRef.tableSchema;
|
|
79
|
-
const vtabModule = tableRef.vtabModule;
|
|
80
|
-
|
|
81
|
-
log('Evaluating growth for %s over table %s', node.nodeType, tableSchema.name);
|
|
82
|
-
|
|
83
|
-
// If no vtabModule, can't grow
|
|
84
|
-
if (!vtabModule) {
|
|
85
|
-
log('No vtabModule available for table %s', tableSchema.name);
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Create candidate pipeline by sliding the operation into the retrieve boundary
|
|
90
|
-
// This replaces the RetrieveNode child with its source in the parent operation
|
|
91
|
-
const candidatePipeline = replaceRetrieveWithSource(node, retrieveChild);
|
|
92
|
-
|
|
93
|
-
// Try module's supports() method first (if available)
|
|
94
|
-
let assessment: SupportAssessment | undefined;
|
|
95
|
-
|
|
96
|
-
if (vtabModule.supports && typeof vtabModule.supports === 'function') {
|
|
97
|
-
// Query-based module: let it decide if it can handle the pipeline
|
|
98
|
-
log('Testing module.supports() for %s pipeline', node.nodeType);
|
|
99
|
-
assessment = vtabModule.supports(candidatePipeline);
|
|
100
|
-
|
|
101
|
-
if (assessment) {
|
|
102
|
-
log('Module supports expanded pipeline (cost: %d)', assessment.cost);
|
|
103
|
-
} else {
|
|
104
|
-
log('Module declined expanded pipeline');
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// If module doesn't have supports() or declined, try index-style fallback
|
|
109
|
-
// but ONLY for operations we know can be translated to index constraints
|
|
110
|
-
if (!assessment && vtabModule.getBestAccessPlan && typeof vtabModule.getBestAccessPlan === 'function') {
|
|
111
|
-
if (canTranslateToIndexConstraints(node)) {
|
|
112
|
-
log('Testing index-style fallback for %s', node.nodeType);
|
|
113
|
-
assessment = fallbackIndexSupports(node, candidatePipeline, context, tableRef);
|
|
114
|
-
|
|
115
|
-
if (assessment) {
|
|
116
|
-
log('Index-style fallback supports pipeline (cost: %d)', assessment.cost);
|
|
117
|
-
} else {
|
|
118
|
-
log('Index-style fallback declined pipeline');
|
|
119
|
-
}
|
|
120
|
-
} else {
|
|
121
|
-
log('Node type %s cannot be translated to index constraints', node.nodeType);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (!assessment) {
|
|
126
|
-
// Module cannot handle the expanded pipeline
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Determine how to slide depending on assessment origin
|
|
131
|
-
let newPipeline: RelationalPlanNode;
|
|
132
|
-
let newBindings = [...(retrieveChild.bindings ?? []), ...collectBindingsInPlan(node, retrieveChild.tableRef)];
|
|
133
|
-
|
|
134
|
-
if (isIndexStyleContext(assessment.ctx)) {
|
|
135
|
-
// Index-style fallback: only place supported fragments under Retrieve; keep residuals above
|
|
136
|
-
newPipeline = candidatePipeline as RelationalPlanNode;
|
|
137
|
-
if (node instanceof FilterNode) {
|
|
138
|
-
const tableInfo: TableInfo = createTableInfoFromNode(retrieveChild.tableRef, tableSchema.name);
|
|
139
|
-
const extraction = extractConstraints(normalizePredicate(node.predicate), [tableInfo]);
|
|
140
|
-
const supported = extraction.supportedPredicateByTable?.get(tableInfo.relationKey);
|
|
141
|
-
if (supported) {
|
|
142
|
-
newPipeline = new FilterNode(
|
|
143
|
-
retrieveChild.source.scope,
|
|
144
|
-
(candidatePipeline as FilterNode).source,
|
|
145
|
-
supported
|
|
146
|
-
) as unknown as RelationalPlanNode;
|
|
147
|
-
newBindings = [...(retrieveChild.bindings ?? []), ...collectBindingsInPlan(newPipeline, retrieveChild.tableRef)];
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
} else {
|
|
151
|
-
// Query-based module with supports(): move the entire node into the module boundary
|
|
152
|
-
newPipeline = candidatePipeline as RelationalPlanNode;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const grownRetrieve = new RetrieveNode(
|
|
156
|
-
node.scope,
|
|
157
|
-
newPipeline,
|
|
158
|
-
retrieveChild.tableRef,
|
|
159
|
-
assessment.ctx,
|
|
160
|
-
newBindings
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
log('Grew retrieve pipeline for table %s: %s → %s',
|
|
164
|
-
tableSchema.name, retrieveChild.source.nodeType, candidatePipeline.nodeType);
|
|
165
|
-
|
|
166
|
-
return grownRetrieve;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Find a RetrieveNode among the children of this node
|
|
171
|
-
*/
|
|
172
|
-
function findRetrieveChild(node: PlanNode): RetrieveNode | undefined {
|
|
173
|
-
const children = node.getChildren();
|
|
174
|
-
for (const child of children) {
|
|
175
|
-
if (child instanceof RetrieveNode) {
|
|
176
|
-
return child;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return undefined;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Replace the RetrieveNode child with its source in the parent operation
|
|
184
|
-
*/
|
|
185
|
-
function replaceRetrieveWithSource(parent: PlanNode, retrieveNode: RetrieveNode): PlanNode {
|
|
186
|
-
const children = parent.getChildren();
|
|
187
|
-
const newChildren = children.map(child =>
|
|
188
|
-
child === retrieveNode ? retrieveNode.source : child
|
|
189
|
-
);
|
|
190
|
-
return parent.withChildren(newChildren);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Check if this node type can be translated to index constraints
|
|
195
|
-
* This is used for the fallback when modules don't implement supports()
|
|
196
|
-
*/
|
|
197
|
-
function canTranslateToIndexConstraints(node: PlanNode): boolean {
|
|
198
|
-
switch (node.nodeType) {
|
|
199
|
-
case PlanNodeType.Filter:
|
|
200
|
-
// Filters can be translated to predicates
|
|
201
|
-
return true;
|
|
202
|
-
case PlanNodeType.Sort:
|
|
203
|
-
// Sort can be translated to ordering requirements
|
|
204
|
-
return true;
|
|
205
|
-
case PlanNodeType.LimitOffset:
|
|
206
|
-
// Limit can be passed to index access
|
|
207
|
-
return true;
|
|
208
|
-
default:
|
|
209
|
-
// Other operations (Project, Aggregate, etc.) can't be
|
|
210
|
-
// meaningfully translated to index constraints
|
|
211
|
-
return false;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Fallback assessment for index-style modules using getBestAccessPlan
|
|
217
|
-
* Translates various operations to index constraints
|
|
218
|
-
*/
|
|
219
|
-
function fallbackIndexSupports(
|
|
220
|
-
node: PlanNode,
|
|
221
|
-
candidatePipeline: PlanNode,
|
|
222
|
-
context: OptContext,
|
|
223
|
-
tableRef: TableReferenceNode
|
|
224
|
-
): SupportAssessment | undefined {
|
|
225
|
-
|
|
226
|
-
const vtabModule = tableRef.vtabModule;
|
|
227
|
-
const tableSchema = tableRef.tableSchema;
|
|
228
|
-
|
|
229
|
-
// Build BestAccessPlanRequest based on node type
|
|
230
|
-
const request: BestAccessPlanRequest = {
|
|
231
|
-
columns: tableSchema.columns.map((col, index) => ({
|
|
232
|
-
index,
|
|
233
|
-
name: col.name,
|
|
234
|
-
type: col.logicalType,
|
|
235
|
-
isPrimaryKey: col.primaryKey || false,
|
|
236
|
-
isUnique: col.primaryKey || false
|
|
237
|
-
})),
|
|
238
|
-
filters: [],
|
|
239
|
-
requiredOrdering: undefined,
|
|
240
|
-
limit: undefined,
|
|
241
|
-
estimatedRows: tableRef.estimatedRows ?? context.stats.tableRows(tableSchema) ?? 1000
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
// Extract information based on node type
|
|
245
|
-
let residualPredicate: PlanNode | undefined;
|
|
246
|
-
|
|
247
|
-
if (node instanceof FilterNode) {
|
|
248
|
-
// Extract constraints from filter predicate
|
|
249
|
-
const tableInfo: TableInfo = createTableInfoFromNode(tableRef, tableSchema.name);
|
|
250
|
-
const normalizedPredicate = normalizePredicate(node.predicate);
|
|
251
|
-
const extraction = extractConstraints(normalizedPredicate, [tableInfo]);
|
|
252
|
-
|
|
253
|
-
if (extraction.allConstraints.length === 0) {
|
|
254
|
-
log('No extractable constraints from filter predicate');
|
|
255
|
-
return undefined;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
request.filters = extraction.allConstraints;
|
|
259
|
-
residualPredicate = extraction.residualPredicate;
|
|
260
|
-
log('Extracted %d constraints from Filter', extraction.allConstraints.length);
|
|
261
|
-
|
|
262
|
-
} else if (node.nodeType === PlanNodeType.Sort) {
|
|
263
|
-
// Extract ordering requirements from Sort node
|
|
264
|
-
const sort = node as unknown as SortNode;
|
|
265
|
-
const ordering = extractOrderingFromSortKeys(sort.getSortKeys(), sort.source.getAttributes());
|
|
266
|
-
if (!ordering) {
|
|
267
|
-
log('Sort node has non-trivial expressions; cannot translate to ordering spec');
|
|
268
|
-
return undefined;
|
|
269
|
-
}
|
|
270
|
-
request.requiredOrdering = ordering.map(o => ({ columnIndex: o.column, desc: o.desc }));
|
|
271
|
-
log('Extracted ordering requirement of length %d', request.requiredOrdering.length);
|
|
272
|
-
|
|
273
|
-
} else if (node.nodeType === PlanNodeType.LimitOffset) {
|
|
274
|
-
// Extract limit from LimitOffset node when constant
|
|
275
|
-
const lim = node as unknown as LimitOffsetNode;
|
|
276
|
-
if (lim.limit && lim.limit.nodeType === _PlanNodeType.Literal) {
|
|
277
|
-
const limitVal = (lim.limit as unknown as LiteralNode).expression.value;
|
|
278
|
-
if (typeof limitVal === 'number') {
|
|
279
|
-
request.limit = Math.max(0, Math.floor(limitVal));
|
|
280
|
-
log('Extracted limit value: %d', request.limit);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
// We ignore OFFSET for now (modules can implement it internally if desired)
|
|
284
|
-
if (!request.limit) {
|
|
285
|
-
log('No usable constant LIMIT found');
|
|
286
|
-
return undefined;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
} else {
|
|
290
|
-
log('Node type %s not supported by index-style fallback', node.nodeType);
|
|
291
|
-
return undefined;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
log('Built access plan request: %d filters, ordering: %s, limit: %s',
|
|
295
|
-
request.filters.length,
|
|
296
|
-
request.requiredOrdering ? 'yes' : 'no',
|
|
297
|
-
request.limit ?? 'none');
|
|
298
|
-
|
|
299
|
-
// Get access plan from module
|
|
300
|
-
const accessPlan = vtabModule.getBestAccessPlan!(context.db, tableSchema, request);
|
|
301
|
-
|
|
302
|
-
// Check if the plan is beneficial
|
|
303
|
-
const handlesAnyFilter = request.filters.length > 0 &&
|
|
304
|
-
accessPlan.handledFilters.some(handled => handled);
|
|
305
|
-
const providesOrdering = request.requiredOrdering &&
|
|
306
|
-
accessPlan.providesOrdering;
|
|
307
|
-
|
|
308
|
-
// Calculate baseline cost
|
|
309
|
-
const estimatedRows = request.estimatedRows ?? 1000;
|
|
310
|
-
const seqCost = seqScanCost(estimatedRows);
|
|
311
|
-
|
|
312
|
-
// Accept the plan if it handles filters OR provides required ordering
|
|
313
|
-
if (!handlesAnyFilter && !providesOrdering) {
|
|
314
|
-
log('Access plan provides no benefit');
|
|
315
|
-
return undefined;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
if (accessPlan.cost >= seqCost && !providesOrdering) {
|
|
319
|
-
log('Access plan cost (%d) not better than sequential scan (%d)', accessPlan.cost, seqCost);
|
|
320
|
-
return undefined;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
log('Index-style fallback beneficial: cost %d vs %d seq scan', accessPlan.cost, seqCost);
|
|
324
|
-
|
|
325
|
-
// Store context for later use in ruleSelectAccessPath
|
|
326
|
-
const indexCtx: IndexStyleContext = {
|
|
327
|
-
kind: 'index-style',
|
|
328
|
-
accessPlan,
|
|
329
|
-
residualPredicate,
|
|
330
|
-
originalConstraints: [...request.filters] // Copy to satisfy mutable type
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
return {
|
|
334
|
-
cost: accessPlan.cost,
|
|
335
|
-
ctx: indexCtx
|
|
336
|
-
};
|
|
337
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { PlanNode } from "../nodes/plan-node.js";
|
|
2
|
-
import type { Scope } from "./scope.js";
|
|
3
|
-
import { Ambiguous } from "./scope.js";
|
|
4
|
-
import * as AST from "../../parser/ast.js";
|
|
5
|
-
import { BaseScope } from "./base.js";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* A Scope that aliases a parent scope.
|
|
9
|
-
*
|
|
10
|
-
* @param parent The parent scope, assumed to already be populated with symbols..
|
|
11
|
-
*/
|
|
12
|
-
export class AliasedScope extends BaseScope {
|
|
13
|
-
private readonly _parentName: string;
|
|
14
|
-
private readonly _alias: string;
|
|
15
|
-
|
|
16
|
-
constructor(
|
|
17
|
-
public readonly parent: Scope,
|
|
18
|
-
parentName: string,
|
|
19
|
-
alias: string
|
|
20
|
-
) {
|
|
21
|
-
super();
|
|
22
|
-
this._parentName = parentName.toLowerCase();
|
|
23
|
-
this._alias = alias.toLowerCase();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
resolveSymbol(symbolKey: string, expression: AST.Expression): PlanNode | typeof Ambiguous | undefined {
|
|
27
|
-
const parts = symbolKey.split('.');
|
|
28
|
-
|
|
29
|
-
// Handle schema-qualified symbols like "main.j.value"
|
|
30
|
-
if (parts.length === 3 && parts[1].toLowerCase() === this._alias) {
|
|
31
|
-
// Replace alias with parent name: "main.j.value" -> "main..value" -> "main.value" (if parent name is empty)
|
|
32
|
-
if (this._parentName === '') {
|
|
33
|
-
// For table-valued functions, remove the alias entirely: "main.j.value" -> "value"
|
|
34
|
-
return this.parent.resolveSymbol(parts[2], expression);
|
|
35
|
-
} else {
|
|
36
|
-
parts[1] = this._parentName;
|
|
37
|
-
return this.parent.resolveSymbol(parts.join('.'), expression);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
// Handle qualified symbols like "j.value"
|
|
41
|
-
else if (parts.length === 2 && parts[0].toLowerCase() === this._alias) {
|
|
42
|
-
// For both cases (table-valued functions and regular tables),
|
|
43
|
-
// just use the column name since the parent scope knows what table it represents
|
|
44
|
-
return this.parent.resolveSymbol(parts[1], expression);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// For all other symbols (including unqualified columns), delegate to parent
|
|
48
|
-
return this.parent.resolveSymbol(symbolKey, expression);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { PlanNode } from '../nodes/plan-node.js';
|
|
2
|
-
import * as AST from '../../parser/ast.js';
|
|
3
|
-
import { type Scope, Ambiguous } from './scope.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Scope that tracks references.
|
|
7
|
-
*/
|
|
8
|
-
export abstract class BaseScope implements Scope {
|
|
9
|
-
abstract resolveSymbol(symbolKey: string, expression: AST.Expression): PlanNode | typeof Ambiguous | undefined;
|
|
10
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as AST from '../../parser/ast.js';
|
|
2
|
-
import type { PlanNode } from '../nodes/plan-node.js';
|
|
3
|
-
import { type Scope, Ambiguous } from './scope.js';
|
|
4
|
-
|
|
5
|
-
/** Scope that contains no symbols. */
|
|
6
|
-
export class EmptyScope implements Scope {
|
|
7
|
-
resolveSymbol(_symbolKey: string, _expression: AST.Expression): PlanNode | typeof Ambiguous | undefined {
|
|
8
|
-
return undefined;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
static readonly instance = new EmptyScope();
|
|
12
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { BaseScope } from "./base.js";
|
|
2
|
-
import type { SchemaManager } from "../../schema/manager.js";
|
|
3
|
-
import type { PlanNode } from "../nodes/plan-node.js";
|
|
4
|
-
import * as AST from "../../parser/ast.js";
|
|
5
|
-
import { FunctionReferenceNode, TableReferenceNode } from "../nodes/reference.js";
|
|
6
|
-
import { Ambiguous } from "./scope.js";
|
|
7
|
-
import type { ScalarType } from "../../common/datatype.js";
|
|
8
|
-
import { isScalarFunctionSchema } from "../../schema/function.js";
|
|
9
|
-
import { REAL_TYPE } from "../../types/builtin-types.js";
|
|
10
|
-
|
|
11
|
-
export class GlobalScope extends BaseScope {
|
|
12
|
-
constructor(public readonly manager: SchemaManager) {
|
|
13
|
-
super();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
resolveSymbol(symbolKey: string, _expression: AST.Expression): PlanNode | typeof Ambiguous | undefined {
|
|
17
|
-
if (symbolKey.includes('/')) {// Function: [schema.]name/nArgs
|
|
18
|
-
const [name, nArgsStr] = symbolKey.split('/');
|
|
19
|
-
const nArgs = parseInt(nArgsStr);
|
|
20
|
-
const func = this.manager.findFunction(name, nArgs);
|
|
21
|
-
if (!func) {
|
|
22
|
-
return undefined;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Get the proper scalar type from the function schema
|
|
26
|
-
const scalarType: ScalarType = isScalarFunctionSchema(func)
|
|
27
|
-
? func.returnType
|
|
28
|
-
: { typeClass: 'scalar', logicalType: REAL_TYPE, nullable: true, isReadOnly: true };
|
|
29
|
-
|
|
30
|
-
return new FunctionReferenceNode(this, func, scalarType);
|
|
31
|
-
}
|
|
32
|
-
// Table: [schema.]table
|
|
33
|
-
const [first, second] = symbolKey.split('.');
|
|
34
|
-
const schema = second ? first : undefined;
|
|
35
|
-
const table = second ? second : first;
|
|
36
|
-
const tableSchema = this.manager.findTable(table, schema);
|
|
37
|
-
if (!tableSchema) {
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
// Note: GlobalScope can't resolve vtab modules without a planning context
|
|
41
|
-
// This path is mainly used for constraint checking where we don't need full resolution
|
|
42
|
-
const vtabModule = this.manager.getModule(tableSchema.vtabModuleName);
|
|
43
|
-
if (!vtabModule) {
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
|
-
return new TableReferenceNode(this, tableSchema, vtabModule.module, vtabModule.auxData);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
findUnqualifiedName(name: string): PlanNode | typeof Ambiguous | undefined {
|
|
50
|
-
// Functions have priority over tables.
|
|
51
|
-
// Check for zero-argument functions first
|
|
52
|
-
const func = this.manager.findFunction(name, 0);
|
|
53
|
-
if (func) {
|
|
54
|
-
// Get the proper scalar type from the function schema
|
|
55
|
-
const scalarType: ScalarType = isScalarFunctionSchema(func)
|
|
56
|
-
? func.returnType
|
|
57
|
-
: { typeClass: 'scalar', logicalType: REAL_TYPE, nullable: true, isReadOnly: true };
|
|
58
|
-
|
|
59
|
-
return new FunctionReferenceNode(this, func, scalarType);
|
|
60
|
-
}
|
|
61
|
-
// Table: [schema.]table
|
|
62
|
-
const table = this.manager.findTable(name);
|
|
63
|
-
if (table) {
|
|
64
|
-
// TODO: Create a proper ColumnScope to allow column references
|
|
65
|
-
const vtabModule = this.manager.getModule(table.vtabModuleName);
|
|
66
|
-
if (!vtabModule) {
|
|
67
|
-
return undefined;
|
|
68
|
-
}
|
|
69
|
-
return new TableReferenceNode(this, table, vtabModule.module, vtabModule.auxData);
|
|
70
|
-
}
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Ambiguous } from "./scope.js";
|
|
2
|
-
import * as AST from "../../parser/ast.js";
|
|
3
|
-
import { QuereusError } from "../../common/errors.js";
|
|
4
|
-
import { StatusCode } from "../../common/types.js";
|
|
5
|
-
import type { PlanNode } from "../nodes/plan-node.js";
|
|
6
|
-
import type { Scope } from "./scope.js";
|
|
7
|
-
import { BaseScope } from "./base.js";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* A Scope that contains multiple other scopes.
|
|
11
|
-
* Symbols are resolved in order, and the first match is used.
|
|
12
|
-
* If a symbol is found in multiple scopes, an error is thrown.
|
|
13
|
-
*/
|
|
14
|
-
export class MultiScope extends BaseScope {
|
|
15
|
-
constructor(
|
|
16
|
-
public readonly scopes: Scope[]
|
|
17
|
-
) {
|
|
18
|
-
super();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
registerSymbol(_symbolKey: string, _getReference: (expression: AST.Expression, currentScope: Scope) => PlanNode): void {
|
|
22
|
-
throw new QuereusError('MultiScope does not support registering symbols.', StatusCode.ERROR);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
resolveSymbol(symbolKey: string, expression: AST.Expression): PlanNode | typeof Ambiguous | undefined {
|
|
26
|
-
// In SQL, inner scopes shadow outer scopes for unqualified names
|
|
27
|
-
// Return the first match, don't treat multiple matches as ambiguous
|
|
28
|
-
for (const scope of this.scopes) {
|
|
29
|
-
const result = scope.resolveSymbol(symbolKey, expression);
|
|
30
|
-
if (result === Ambiguous) {
|
|
31
|
-
return Ambiguous;
|
|
32
|
-
}
|
|
33
|
-
if (result) {
|
|
34
|
-
return result;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return undefined;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import type * as AST from '../../parser/ast.js';
|
|
2
|
-
import { ParameterReferenceNode } from '../nodes/reference.js'; // Corrected import
|
|
3
|
-
import { BaseScope } from './base.js';
|
|
4
|
-
import { Ambiguous, type Scope } from './scope.js';
|
|
5
|
-
import type { ScalarType } from '../../common/datatype.js';
|
|
6
|
-
import type { PlanNode } from '../nodes/plan-node.js';
|
|
7
|
-
import { TEXT_TYPE } from '../../types/builtin-types.js';
|
|
8
|
-
|
|
9
|
-
// Default type for parameters when not otherwise specified.
|
|
10
|
-
const DEFAULT_PARAMETER_TYPE: ScalarType = {
|
|
11
|
-
typeClass: 'scalar',
|
|
12
|
-
logicalType: TEXT_TYPE,
|
|
13
|
-
nullable: true,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* A scope that resolves query parameters (e.g., :name, :1, ?).
|
|
18
|
-
* It makes these parameters available via an accessor.
|
|
19
|
-
*/
|
|
20
|
-
export class ParameterScope extends BaseScope {
|
|
21
|
-
private _nextAnonymousIndex: number = 1;
|
|
22
|
-
private readonly _parameters: Map<string | number, ParameterReferenceNode> = new Map();
|
|
23
|
-
private readonly _parameterTypes: ReadonlyMap<string | number, ScalarType>;
|
|
24
|
-
|
|
25
|
-
constructor(
|
|
26
|
-
public readonly parentScope: Scope,
|
|
27
|
-
parameterTypes?: ReadonlyMap<string | number, ScalarType>
|
|
28
|
-
) {
|
|
29
|
-
super();
|
|
30
|
-
this._parameterTypes = parameterTypes || new Map();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
resolveSymbol(symbolKey: string, expression: AST.Expression): PlanNode | typeof Ambiguous | undefined {
|
|
34
|
-
let identifier: string | number;
|
|
35
|
-
let parameterNode: ParameterReferenceNode | undefined;
|
|
36
|
-
|
|
37
|
-
// The expression should be an AST.ParameterExpr when symbolKey indicates a parameter
|
|
38
|
-
const parameterExpression = expression as AST.ParameterExpr;
|
|
39
|
-
let resolvedType = DEFAULT_PARAMETER_TYPE;
|
|
40
|
-
|
|
41
|
-
if (symbolKey === '?') {
|
|
42
|
-
// Use the current _nextAnonymousIndex as the potential identifier for this '?'
|
|
43
|
-
const currentAnonymousId = this._nextAnonymousIndex;
|
|
44
|
-
|
|
45
|
-
// Check if this specific anonymous parameter (by its future index) has a declared type
|
|
46
|
-
if (this._parameterTypes.has(currentAnonymousId)) {
|
|
47
|
-
resolvedType = this._parameterTypes.get(currentAnonymousId)!;
|
|
48
|
-
}
|
|
49
|
-
// Note: We don't check _parameters here for '?' because each '?' AST node should resolve,
|
|
50
|
-
// potentially creating a new ParameterReferenceNode if it's a new '?' instance in the query,
|
|
51
|
-
// even if it gets the same numeric index as a previous one *if* they were different AST nodes.
|
|
52
|
-
// The _parameters map is more for caching resolved nodes per unique AST node or name.
|
|
53
|
-
// For '?', the ParameterReferenceNode constructor expects the numeric index.
|
|
54
|
-
// We use currentAnonymousId as the identifier and increment after creation.
|
|
55
|
-
identifier = currentAnonymousId;
|
|
56
|
-
parameterNode = new ParameterReferenceNode(this, parameterExpression, identifier, resolvedType);
|
|
57
|
-
this._parameters.set(identifier, parameterNode); // Cache it by its assigned numeric ID
|
|
58
|
-
this._nextAnonymousIndex++; // Increment for the *next* '?'
|
|
59
|
-
} else if (symbolKey.startsWith(':')) {
|
|
60
|
-
const nameOrIndex = symbolKey.substring(1);
|
|
61
|
-
const numIndex = parseInt(nameOrIndex, 10);
|
|
62
|
-
identifier = isNaN(numIndex) ? nameOrIndex : numIndex;
|
|
63
|
-
|
|
64
|
-
if (this._parameters.has(identifier)) {
|
|
65
|
-
parameterNode = this._parameters.get(identifier)!;
|
|
66
|
-
// If already exists, its type was set at creation
|
|
67
|
-
} else {
|
|
68
|
-
if (this._parameterTypes.has(identifier)) {
|
|
69
|
-
resolvedType = this._parameterTypes.get(identifier)!;
|
|
70
|
-
}
|
|
71
|
-
parameterNode = new ParameterReferenceNode(this, parameterExpression, identifier, resolvedType);
|
|
72
|
-
this._parameters.set(identifier, parameterNode);
|
|
73
|
-
}
|
|
74
|
-
} else {
|
|
75
|
-
// Not a parameter symbol, delegate to parent scope
|
|
76
|
-
return this.parentScope.resolveSymbol(symbolKey, expression);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return parameterNode;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Returns all parameters resolved by this scope.
|
|
84
|
-
*/
|
|
85
|
-
getParameters(): ReadonlyMap<string | number, ParameterReferenceNode> {
|
|
86
|
-
return this._parameters;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Gets the next available anonymous parameter index (1-based) for assigning to new ' ? ' params.
|
|
91
|
-
*/
|
|
92
|
-
// getNextAnonymousIndex(): number { // This method might be misleading as index is auto-assigned.
|
|
93
|
-
// return this._nextAnonymousIndex;
|
|
94
|
-
// }
|
|
95
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { StatusCode } from '../../common/types.js';
|
|
2
|
-
import { QuereusError } from '../../common/errors.js';
|
|
3
|
-
import type { PlanNode } from '../nodes/plan-node.js';
|
|
4
|
-
import * as AST from '../../parser/ast.js';
|
|
5
|
-
import { type ReferenceCallback, type Scope, Ambiguous } from './scope.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The Scope object provides context for symbol resolution during query planning.
|
|
9
|
-
* It encapsulates the logic for looking up columns, parameters, functions, and CTEs
|
|
10
|
-
* based on the current position in the PlanNode tree.
|
|
11
|
-
*/
|
|
12
|
-
export class RegisteredScope implements Scope {
|
|
13
|
-
/** Symbols that have been registered in this scope. */
|
|
14
|
-
private registeredSymbols: Map<string, ReferenceCallback> = new Map();
|
|
15
|
-
|
|
16
|
-
constructor(
|
|
17
|
-
/** The parent scope, if any. The root scope of a query has no parent. */
|
|
18
|
-
public readonly parent?: Scope,
|
|
19
|
-
) { }
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Registers a symbol (like a table alias, CTE name, or parameter) with a factory function
|
|
23
|
-
* that can produce a ReferenceNode for it when encountered in an expression.
|
|
24
|
-
*
|
|
25
|
-
* @param symbolKey The unique string key for this symbol in the current scope.
|
|
26
|
-
* For tables/aliases: lower-case name.
|
|
27
|
-
* For qualified schema.table: "schema.table" (lower-case).
|
|
28
|
-
* For parameters: ":name" or ":index".
|
|
29
|
-
* @param getReference A factory function that takes the matching symbol and the current Scope,
|
|
30
|
-
* and returns an appropriate ReferenceNode.
|
|
31
|
-
*/
|
|
32
|
-
registerSymbol(symbolKey: string, getReference: ReferenceCallback): void {
|
|
33
|
-
const lowerSymbolKey = symbolKey.toLowerCase();
|
|
34
|
-
if (this.registeredSymbols.has(lowerSymbolKey)) {
|
|
35
|
-
throw new QuereusError(`Symbol '${lowerSymbolKey}' already exists in the same scope.`, StatusCode.ERROR);
|
|
36
|
-
}
|
|
37
|
-
this.registeredSymbols.set(lowerSymbolKey, getReference);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
subscribeFactory(symbolKey: string, factory: ReferenceCallback): void {
|
|
41
|
-
const lower = symbolKey.toLowerCase();
|
|
42
|
-
if (this.registeredSymbols.has(lower)) {
|
|
43
|
-
throw new QuereusError(`Symbol '${lower}' already exists in the same scope.`, StatusCode.ERROR);
|
|
44
|
-
}
|
|
45
|
-
this.registeredSymbols.set(lower, factory);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
resolveSymbol(symbolKey: string, expression: AST.Expression): PlanNode | typeof Ambiguous | undefined {
|
|
49
|
-
const reference = this.registeredSymbols.get(symbolKey.toLowerCase());
|
|
50
|
-
if (reference) {
|
|
51
|
-
return reference(expression, this);
|
|
52
|
-
}
|
|
53
|
-
if (this.parent) {
|
|
54
|
-
return this.parent.resolveSymbol(symbolKey, expression);
|
|
55
|
-
}
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Returns all symbols that have been registered in this scope.
|
|
61
|
-
*
|
|
62
|
-
* @returns An array of all [symbolKey, ReferenceCallback].
|
|
63
|
-
*/
|
|
64
|
-
getSymbols(): readonly [string, ReferenceCallback][] {
|
|
65
|
-
return Array.from(this.registeredSymbols.entries());
|
|
66
|
-
}
|
|
67
|
-
}
|