@quereus/quereus 4.20.0 → 4.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/src/common/types.d.ts +4 -4
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/schema/catalog-rendering.js +13 -1
- package/dist/src/schema/catalog-rendering.js.map +1 -1
- package/dist/src/schema/catalog.d.ts +35 -2
- package/dist/src/schema/catalog.d.ts.map +1 -1
- package/dist/src/schema/catalog.js +42 -33
- package/dist/src/schema/catalog.js.map +1 -1
- package/dist/src/schema/schema-differ.d.ts +1 -1
- package/dist/src/schema/schema-differ.d.ts.map +1 -1
- package/dist/src/schema/schema-differ.js +195 -33
- package/dist/src/schema/schema-differ.js.map +1 -1
- package/dist/src/schema/unique-enforcement.d.ts +23 -1
- package/dist/src/schema/unique-enforcement.d.ts.map +1 -1
- package/dist/src/schema/unique-enforcement.js +43 -1
- package/dist/src/schema/unique-enforcement.js.map +1 -1
- package/dist/src/vtab/memory/layer/manager.d.ts +15 -12
- package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/manager.js +87 -100
- package/dist/src/vtab/memory/layer/manager.js.map +1 -1
- package/package.json +7 -4
- package/test/README.md +173 -0
- package/test/logic/01-basic.sqllogic +39 -0
- package/test/logic/01.1-select-projection-extras.sqllogic +130 -0
- package/test/logic/01.2-strings.sqllogic +43 -0
- package/test/logic/01.5-insert-select.sqllogic +237 -0
- package/test/logic/01.6-update-extras.sqllogic +118 -0
- package/test/logic/01.7-update-from.sqllogic +67 -0
- package/test/logic/01.8-delete-extras.sqllogic +122 -0
- package/test/logic/01.8.1-delete-range-cow.sqllogic +115 -0
- package/test/logic/01.9-query-expr-dml-gates.sqllogic +32 -0
- package/test/logic/01.9-query-expr-dml.sqllogic +171 -0
- package/test/logic/01.9-query-expr-values.sqllogic +111 -0
- package/test/logic/01.9.1-limit-over-dml-subquery.sqllogic +119 -0
- package/test/logic/02-filters.sqllogic +54 -0
- package/test/logic/02-smoke.sqllogic +62 -0
- package/test/logic/02.1-bind-parameters.sqllogic +223 -0
- package/test/logic/03-expressions.sqllogic +190 -0
- package/test/logic/03.1-quoted-identifiers.sqllogic +55 -0
- package/test/logic/03.4-defaults.sqllogic +554 -0
- package/test/logic/03.4.1-default-edge-cases.sqllogic +99 -0
- package/test/logic/03.5-tvf.sqllogic +61 -0
- package/test/logic/03.6-type-system.sqllogic +544 -0
- package/test/logic/03.6.1-numeric-text-comparison-coercion.sqllogic +244 -0
- package/test/logic/03.6.2-value-to-text.sqllogic +224 -0
- package/test/logic/03.7-bigint-mixed-arithmetic.sqllogic +65 -0
- package/test/logic/03.8-not-precedence.sqllogic +255 -0
- package/test/logic/03.9-is-bool-predicate.sqllogic +150 -0
- package/test/logic/03.9.1-is-bool-predicate-partial-index.sqllogic +34 -0
- package/test/logic/04-order-by.sqllogic +38 -0
- package/test/logic/04-transactions.sqllogic +239 -0
- package/test/logic/04a-savepoint-lazy-attach.sqllogic +122 -0
- package/test/logic/05-vtab_memory.sqllogic +50 -0
- package/test/logic/05.0.1-vtab-memory-unique-index-collation.sqllogic +34 -0
- package/test/logic/05.1-composite-pk-range-scan.sqllogic +147 -0
- package/test/logic/05.1.1-secondary-index-range-scan.sqllogic +56 -0
- package/test/logic/05.2-cast-seek-correctness.sqllogic +124 -0
- package/test/logic/06-builtin_functions.sqllogic +149 -0
- package/test/logic/06.1-string-functions.sqllogic +92 -0
- package/test/logic/06.1.3-like-glob-edges.sqllogic +53 -0
- package/test/logic/06.2-math-functions.sqllogic +82 -0
- package/test/logic/06.3-schema.sqllogic +48 -0
- package/test/logic/06.3.1-schema-all-schemas.sqllogic +39 -0
- package/test/logic/06.3.2-schema-foreign-keys.sqllogic +208 -0
- package/test/logic/06.3.3-introspection-tags.sqllogic +202 -0
- package/test/logic/06.3.3.1-introspection-tags-index.sqllogic +74 -0
- package/test/logic/06.3.4-view-info.sqllogic +378 -0
- package/test/logic/06.3.5-column-info.sqllogic +347 -0
- package/test/logic/06.3.6-schema-views.sqllogic +29 -0
- package/test/logic/06.4-schema-search-path.sqllogic +354 -0
- package/test/logic/06.4.1-schema-case-insensitive.sqllogic +83 -0
- package/test/logic/06.4.2-collation-extras.sqllogic +472 -0
- package/test/logic/06.4.2.1-collation-index-access-paths.sqllogic +140 -0
- package/test/logic/06.4.3-write-path-collation.sqllogic +99 -0
- package/test/logic/06.4.4-comparison-collation-precedence.sqllogic +342 -0
- package/test/logic/06.4.5-any-collate-declared-keys.sqllogic +92 -0
- package/test/logic/06.5-polymorphic-types.sqllogic +169 -0
- package/test/logic/06.5.1-conversion-functions.sqllogic +173 -0
- package/test/logic/06.5.2-scalar-minmax.sqllogic +16 -0
- package/test/logic/06.5.3-undeclared-return-type-comparison.sqllogic +244 -0
- package/test/logic/06.5.4-declared-return-type-builtins.sqllogic +288 -0
- package/test/logic/06.6-aggregate-extended.sqllogic +78 -0
- package/test/logic/06.7-json-extended.sqllogic +53 -0
- package/test/logic/06.8-json-path-operators.sqllogic +99 -0
- package/test/logic/06.9-json-canonical-key.sqllogic +65 -0
- package/test/logic/06.9.1-json-coerce-once.sqllogic +417 -0
- package/test/logic/06.9.1.1-json-coerce-once-index.sqllogic +39 -0
- package/test/logic/06.9.2-json-structural-equality.sqllogic +382 -0
- package/test/logic/06.9.2.1-json-structural-equality-index.sqllogic +76 -0
- package/test/logic/06.9.3-json-index-range-seek.sqllogic +205 -0
- package/test/logic/07-aggregates.sqllogic +193 -0
- package/test/logic/07.1-aggregate-filter-clause.sqllogic +12 -0
- package/test/logic/07.2-aggregate-order-by.sqllogic +11 -0
- package/test/logic/07.3-group-by-extras.sqllogic +602 -0
- package/test/logic/07.3.1-group-by-order-by-key.sqllogic +164 -0
- package/test/logic/07.3.2-grouped-select-list-shape.sqllogic +231 -0
- package/test/logic/07.4-group-by-filter-composite-pk.sqllogic +120 -0
- package/test/logic/07.5-sum-mixed-exact-and-float.sqllogic +151 -0
- package/test/logic/07.5-window.sqllogic +1941 -0
- package/test/logic/07.5.1-window-named.sqllogic +13 -0
- package/test/logic/07.5.2-window-nth-value.sqllogic +13 -0
- package/test/logic/07.6-subqueries.sqllogic +78 -0
- package/test/logic/07.6.1-subquery-extras.sqllogic +93 -0
- package/test/logic/07.7-and-or-short-circuit.sqllogic +58 -0
- package/test/logic/07.7-in-subquery-caching.sqllogic +174 -0
- package/test/logic/07.7-scalar-agg-decorrelation.sqllogic +197 -0
- package/test/logic/07.7.1-in-extras.sqllogic +158 -0
- package/test/logic/07.7.1-scalar-agg-decorrelation-filter.sqllogic +105 -0
- package/test/logic/07.7.2-scalar-agg-decorrelation-nested.sqllogic +115 -0
- package/test/logic/07.7.3-exists-in-select-decorrelation.sqllogic +107 -0
- package/test/logic/07.7.4-where-conjunct-ordering.sqllogic +121 -0
- package/test/logic/07.7.5-filter-lost-under-index-order.sqllogic +134 -0
- package/test/logic/07.7.6-correlated-predicate-scope.sqllogic +178 -0
- package/test/logic/07.7.7-join-source-scope-shadowing.sqllogic +137 -0
- package/test/logic/07.7.8-correlated-ref-to-computed-column.sqllogic +165 -0
- package/test/logic/07.7.9-conjunct-monotonicity.sqllogic +200 -0
- package/test/logic/07.8-correlated-subquery-edges.sqllogic +71 -0
- package/test/logic/07.8.1-correlated-in-decorrelation-gates.sqllogic +156 -0
- package/test/logic/07.9-in-value-list.sqllogic +154 -0
- package/test/logic/07.9.1-in-value-list-composite-index.sqllogic +38 -0
- package/test/logic/08-views.sqllogic +64 -0
- package/test/logic/08.1-semi-anti-join.sqllogic +191 -0
- package/test/logic/08.1-view-edge-cases.sqllogic +118 -0
- package/test/logic/08.1.1-uncorrelated-in-semijoin.sqllogic +251 -0
- package/test/logic/08.2-existence-flag-semijoin-recovery.sqllogic +197 -0
- package/test/logic/08.3-existence-flag-inner-recovery.sqllogic +102 -0
- package/test/logic/08.4-key-set-semi-join.sqllogic +447 -0
- package/test/logic/09-set_operations.sqllogic +244 -0
- package/test/logic/09.1-set-op-cross-collation.sqllogic +230 -0
- package/test/logic/10-distinct_datatypes.sqllogic +127 -0
- package/test/logic/10.1-ddl-lifecycle.sqllogic +203 -0
- package/test/logic/10.1.1-create-table-syntax-edges.sqllogic +47 -0
- package/test/logic/10.1.2-ddl-in-transaction.sqllogic +143 -0
- package/test/logic/10.1.2.1-add-constraint-in-transaction.sqllogic +59 -0
- package/test/logic/10.1.3-ddl-drop-in-transaction.sqllogic +187 -0
- package/test/logic/10.1.3.1-drop-constraint-in-transaction.sqllogic +45 -0
- package/test/logic/10.1.4-create-table-duplicate-constraint-names.sqllogic +149 -0
- package/test/logic/10.1.4-ddl-transaction-policy.sqllogic +314 -0
- package/test/logic/10.1.5-alter-add-constraint-minted-name-disambiguation.sqllogic +219 -0
- package/test/logic/10.1.5-create-index-lifecycle.sqllogic +72 -0
- package/test/logic/10.1.6-ddl-transaction-policy-index.sqllogic +143 -0
- package/test/logic/10.1.7-create-table-default-type-check.sqllogic +119 -0
- package/test/logic/10.1.8-alter-add-check-existing-rows.sqllogic +117 -0
- package/test/logic/10.2-column-features.sqllogic +365 -0
- package/test/logic/10.2.1-table-options-rejection.sqllogic +63 -0
- package/test/logic/10.2.2-default-collation-memory.sqllogic +30 -0
- package/test/logic/10.3-function-features.sqllogic +247 -0
- package/test/logic/10.4-schema-scale.sqllogic +168 -0
- package/test/logic/10.4.1-schema-scale-indexes.sqllogic +121 -0
- package/test/logic/10.5-indexes.sqllogic +164 -0
- package/test/logic/10.5.1-partial-indexes.sqllogic +526 -0
- package/test/logic/10.5.2-expression-indexes.sqllogic +34 -0
- package/test/logic/10.5.3-desc-index-ordering.sqllogic +130 -0
- package/test/logic/10.5.4-composite-pk-index-update-phantom.sqllogic +55 -0
- package/test/logic/10.5.5-index-name-uniqueness.sqllogic +76 -0
- package/test/logic/10.5.6-minmax-index-boundary.sqllogic +204 -0
- package/test/logic/10.5.7-implicit-unique-index-lifecycle.sqllogic +1216 -0
- package/test/logic/10.6-distinct-edge-cases.sqllogic +119 -0
- package/test/logic/100-predicate-normalization-edge-cases.sqllogic +238 -0
- package/test/logic/100.1-where-extras.sqllogic +163 -0
- package/test/logic/100.1.1-where-join-on-order-indexed.sqllogic +35 -0
- package/test/logic/101-builtin-mutation-kills.sqllogic +974 -0
- package/test/logic/101-transaction-edge-cases.sqllogic +395 -0
- package/test/logic/102-schema-catalog-edge-cases.sqllogic +252 -0
- package/test/logic/102-unique-constraints.sqllogic +145 -0
- package/test/logic/102.0.1-schema-catalog-indexed-table.sqllogic +32 -0
- package/test/logic/102.1-unique-edge-cases.sqllogic +111 -0
- package/test/logic/102.1.1-unique-index-creation-edge-cases.sqllogic +75 -0
- package/test/logic/102.2-unique-collation.sqllogic +181 -0
- package/test/logic/102.2.1-unique-collation-index-derived.sqllogic +305 -0
- package/test/logic/103-database-options-edge-cases.sqllogic +108 -0
- package/test/logic/103.1-pragma-boolean-values.sqllogic +126 -0
- package/test/logic/104-emit-mutation-kills.sqllogic +236 -0
- package/test/logic/105-vtab-memory-mutation-kills.sqllogic +754 -0
- package/test/logic/105.1-vtab-memory-index-mutation-kills.sqllogic +540 -0
- package/test/logic/106-constraint-extractor-mutation-kills.sqllogic +350 -0
- package/test/logic/107-temporal-arithmetic-mutation-kills.sqllogic +833 -0
- package/test/logic/108-cardinality-estimation.sqllogic +146 -0
- package/test/logic/108.1-analyze-name-resolution.sqllogic +102 -0
- package/test/logic/109-aggregate-physical-selection.sqllogic +103 -0
- package/test/logic/11-joins.sqllogic +86 -0
- package/test/logic/11.1-join-using.sqllogic +267 -0
- package/test/logic/11.2-comma-join.sqllogic +35 -0
- package/test/logic/11.3-index-nested-loop-join.sqllogic +305 -0
- package/test/logic/11.3-mismatched-collation-join.sqllogic +74 -0
- package/test/logic/11.4-hash-join-side-swap.sqllogic +118 -0
- package/test/logic/110-scan-emitter-mutation-kills.sqllogic +121 -0
- package/test/logic/110.1-scan-emitter-index-scan-kills.sqllogic +47 -0
- package/test/logic/12-empty-primary-key.sqllogic +124 -0
- package/test/logic/12-join_padding_order.sqllogic +58 -0
- package/test/logic/12.1-orderby-index-consumption.sqllogic +40 -0
- package/test/logic/13-cte.sqllogic +137 -0
- package/test/logic/13.1-cte-multiple-recursive.sqllogic +104 -0
- package/test/logic/13.10-cte-qualified-name.sqllogic +136 -0
- package/test/logic/13.11-unreferenced-dml-cte.sqllogic +414 -0
- package/test/logic/13.12-nested-dml-cte-rejected.sqllogic +280 -0
- package/test/logic/13.2-cte-bind-params.sqllogic +98 -0
- package/test/logic/13.3-cte-edge-cases.sqllogic +120 -0
- package/test/logic/13.4-cte-extras.sqllogic +98 -0
- package/test/logic/13.5-cte-join-order.sqllogic +166 -0
- package/test/logic/13.6-cte-dml-runs-once.sqllogic +318 -0
- package/test/logic/13.7-cte-sibling-visibility.sqllogic +227 -0
- package/test/logic/13.8-insert-with-clause-visibility.sqllogic +254 -0
- package/test/logic/13.9-schema-authored-cte-isolation.sqllogic +328 -0
- package/test/logic/13.9.1-schema-authored-schema-path-isolation.sqllogic +408 -0
- package/test/logic/14-utilities.sqllogic +168 -0
- package/test/logic/15-timespan.sqllogic +279 -0
- package/test/logic/15.1-semantic-ordering.sqllogic +960 -0
- package/test/logic/15.1.1-json-check-coercion.sqllogic +178 -0
- package/test/logic/15.1.2-semantic-ordering-index.sqllogic +41 -0
- package/test/logic/15.1.3-declared-form-write-contract.sqllogic +519 -0
- package/test/logic/16-epoch.sqllogic +187 -0
- package/test/logic/17-weekday-modifier.sqllogic +78 -0
- package/test/logic/18-json-string-escapes.sqllogic +86 -0
- package/test/logic/18-strftime-extended-formats.sqllogic +68 -0
- package/test/logic/20-empty-single-row.sqllogic +261 -0
- package/test/logic/21-null-edge-cases.sqllogic +227 -0
- package/test/logic/21.1-where-null-comparisons.sqllogic +151 -0
- package/test/logic/21.1.1-where-null-comparisons-secondary-index.sqllogic +35 -0
- package/test/logic/21.2-between-edges.sqllogic +157 -0
- package/test/logic/22-boundary-values.sqllogic +175 -0
- package/test/logic/23-self-joins-duplicates.sqllogic +74 -0
- package/test/logic/24-builtin-branches.sqllogic +611 -0
- package/test/logic/24.1-substr-extras.sqllogic +75 -0
- package/test/logic/24.2-random-extras.sqllogic +39 -0
- package/test/logic/25-aggregate-edge-cases.sqllogic +289 -0
- package/test/logic/25.1-nested-aggregates.sqllogic +74 -0
- package/test/logic/25.2-having-edge-cases.sqllogic +318 -0
- package/test/logic/25.3-aggregate-isnull-empty.sqllogic +16 -0
- package/test/logic/25.4-groupby-fd-constant-empty.sqllogic +55 -0
- package/test/logic/25.5-ungrouped-aggregate-column-free-select-item.sqllogic +196 -0
- package/test/logic/26-join-edge-cases.sqllogic +333 -0
- package/test/logic/26.1-left-join-isnull-on-notnull.sqllogic +26 -0
- package/test/logic/26.2-left-join-on-vs-where.sqllogic +67 -0
- package/test/logic/26.3-join-on-constants.sqllogic +61 -0
- package/test/logic/26.4-join-on-is-null-nullable.sqllogic +44 -0
- package/test/logic/27-window-edge-cases.sqllogic +206 -0
- package/test/logic/27.1-window-groups-frame.sqllogic +13 -0
- package/test/logic/27.2-window-exclude.sqllogic +13 -0
- package/test/logic/27.3-window-json-aggregation.sqllogic +66 -0
- package/test/logic/28-set-ops-sort-edge-cases.sqllogic +444 -0
- package/test/logic/28.1-compound-limit-offset.sqllogic +143 -0
- package/test/logic/28.2-orderby-expression-extras.sqllogic +698 -0
- package/test/logic/28.2-set-op-branch-types.sqllogic +217 -0
- package/test/logic/29-constraint-edge-cases.sqllogic +442 -0
- package/test/logic/29.1-column-level-conflict-clause.sqllogic +171 -0
- package/test/logic/29.2-table-level-pk-conflict-clause.sqllogic +113 -0
- package/test/logic/40-constraints.sqllogic +418 -0
- package/test/logic/40.1-pk-desc-direction.sqllogic +76 -0
- package/test/logic/40.2-check-extras.sqllogic +683 -0
- package/test/logic/41-alter-table.sqllogic +191 -0
- package/test/logic/41-fk-cascade-conflict-and-self-ref.sqllogic +263 -0
- package/test/logic/41-fk-cross-schema.sqllogic +155 -0
- package/test/logic/41-fk-extended-targets.sqllogic +173 -0
- package/test/logic/41-foreign-keys.sqllogic +1001 -0
- package/test/logic/41-generated-column-errors.sqllogic +225 -0
- package/test/logic/41-generated-column-extras.sqllogic +598 -0
- package/test/logic/41-generated-column-scope.sqllogic +329 -0
- package/test/logic/41-generated-columns.sqllogic +361 -0
- package/test/logic/41.1-alter-pk.sqllogic +230 -0
- package/test/logic/41.1-fk-collation-conflict.sqllogic +277 -0
- package/test/logic/41.10-alter-drop-column-foreign-key.sqllogic +274 -0
- package/test/logic/41.10.1-alter-drop-column-unique-index.sqllogic +169 -0
- package/test/logic/41.10.2-alter-drop-column-check-and-assertion.sqllogic +1616 -0
- package/test/logic/41.10.3-alter-drop-column-referencing-fk.sqllogic +292 -0
- package/test/logic/41.10.4-drop-object-expression-dependents.sqllogic +602 -0
- package/test/logic/41.11-deferred-fk-with-rename.sqllogic +232 -0
- package/test/logic/41.12-alter-default-coercion.sqllogic +200 -0
- package/test/logic/41.13-alter-add-column-generated-backfill.sqllogic +566 -0
- package/test/logic/41.14-alter-add-column-subquery-backfill.sqllogic +129 -0
- package/test/logic/41.15-alter-column-default-type-check.sqllogic +178 -0
- package/test/logic/41.16-fk-unenforceable.sqllogic +364 -0
- package/test/logic/41.2-alter-column.sqllogic +382 -0
- package/test/logic/41.2.1-alter-column-retype-deleted-row-memory.sqllogic +32 -0
- package/test/logic/41.2.2-alter-column-retype-index-rebuild.sqllogic +77 -0
- package/test/logic/41.2.3-alter-column-set-not-null-pk-backfill.sqllogic +310 -0
- package/test/logic/41.2.3.1-alter-column-set-not-null-pk-backfill-secondary-index.sqllogic +37 -0
- package/test/logic/41.3-alter-add-column-unique.sqllogic +184 -0
- package/test/logic/41.3-alter-rename-propagation.sqllogic +2352 -0
- package/test/logic/41.3.1-alter-rename-index-propagation.sqllogic +94 -0
- package/test/logic/41.4-alter-add-column-constraints.sqllogic +855 -0
- package/test/logic/41.5-alter-misc.sqllogic +48 -0
- package/test/logic/41.5-cross-schema-foreign-keys.sqllogic +253 -0
- package/test/logic/41.6-alter-drop-rename-constraint.sqllogic +354 -0
- package/test/logic/41.6.1-alter-drop-constraint-index-derived.sqllogic +22 -0
- package/test/logic/41.7-alter-column-collate.sqllogic +105 -0
- package/test/logic/41.7.1-alter-column-collate-unique.sqllogic +45 -0
- package/test/logic/41.7.2-alter-column-collate-unique-store.sqllogic +208 -0
- package/test/logic/41.7.2.1-alter-column-collate-unique-index-store.sqllogic +114 -0
- package/test/logic/41.7.3-alter-column-retype-unique.sqllogic +293 -0
- package/test/logic/41.7.3.1-alter-column-retype-staged-rows-memory.sqllogic +41 -0
- package/test/logic/41.7.3.2-alter-column-retype-unique-index.sqllogic +72 -0
- package/test/logic/41.7.4-alter-column-retype-semantic-memory.sqllogic +445 -0
- package/test/logic/41.7.4.1-alter-column-retype-semantic-index-memory.sqllogic +91 -0
- package/test/logic/41.7.5-alter-column-collate-pk-staged-delete-memory.sqllogic +106 -0
- package/test/logic/41.8-alter-add-constraint-unique-fk.sqllogic +275 -0
- package/test/logic/41.8-alter-savepoint-staged-rows.sqllogic +443 -0
- package/test/logic/41.8.1-alter-rename-savepoint-staged-rows.sqllogic +408 -0
- package/test/logic/41.9-alter-constraint-body-change.sqllogic +180 -0
- package/test/logic/41.9-fk-restrict-batched.sqllogic +290 -0
- package/test/logic/42-committed-snapshot.sqllogic +254 -0
- package/test/logic/42-returning.sqllogic +159 -0
- package/test/logic/42.1-returning-extras.sqllogic +232 -0
- package/test/logic/42.2-returning-stored-row.sqllogic +165 -0
- package/test/logic/43-default-nullability.sqllogic +131 -0
- package/test/logic/43-transition-constraints.sqllogic +341 -0
- package/test/logic/43.1-default-collation.sqllogic +140 -0
- package/test/logic/43.1-notnull-or-conflict.sqllogic +79 -0
- package/test/logic/43.2-deferred-check-new-on-delete.sqllogic +95 -0
- package/test/logic/43.3-nullable-primary-key.sqllogic +587 -0
- package/test/logic/44-determinism-validation.sqllogic +164 -0
- package/test/logic/44-orthogonality.sqllogic +146 -0
- package/test/logic/44.1-nondeterministic-schema.sqllogic +316 -0
- package/test/logic/45-udf-determinism.sqllogic +39 -0
- package/test/logic/46-mutation-context.sqllogic +595 -0
- package/test/logic/47-upsert.sqllogic +255 -0
- package/test/logic/47.1-upsert-conflict-targets.sqllogic +169 -0
- package/test/logic/47.2-replace-and-or-clauses.sqllogic +164 -0
- package/test/logic/47.2.1-pk-replace-secondary-unique.sqllogic +374 -0
- package/test/logic/47.3-engine-or-fail.sqllogic +122 -0
- package/test/logic/47.3-upsert-conflict-target-collation.sqllogic +139 -0
- package/test/logic/47.3.1-upsert-conflict-index-derived-collation.sqllogic +25 -0
- package/test/logic/47.4-upsert-conflict-target-affinity.sqllogic +59 -0
- package/test/logic/47.5-upsert-do-update-constraints.sqllogic +440 -0
- package/test/logic/47.6-upsert-do-update-decomposed.sqllogic +100 -0
- package/test/logic/49-reference-graph.sqllogic +84 -0
- package/test/logic/50-declarative-schema.sqllogic +2550 -0
- package/test/logic/50-metadata-tags.sqllogic +1033 -0
- package/test/logic/50.0.1-metadata-tags-index.sqllogic +141 -0
- package/test/logic/50.1-declare-schema-pk.sqllogic +150 -0
- package/test/logic/50.2-declare-schema-renames.sqllogic +949 -0
- package/test/logic/50.2.1-declare-schema-index-renames.sqllogic +173 -0
- package/test/logic/50.3-declare-schema-duplicate-names.sqllogic +280 -0
- package/test/logic/50.4-declare-schema-apply-restore.sqllogic +192 -0
- package/test/logic/51-lens-foundation.sqllogic +147 -0
- package/test/logic/51-materialized-views.sqllogic +376 -0
- package/test/logic/51.5-materialized-views-coarsened-key.sqllogic +198 -0
- package/test/logic/51.7-maintained-table-attach-detach.sqllogic +468 -0
- package/test/logic/51.8-maintained-table-declared-constraints.sqllogic +440 -0
- package/test/logic/51.85-maintained-table-parent-fk.sqllogic +103 -0
- package/test/logic/51.9-maintained-table-secondary-unique.sqllogic +237 -0
- package/test/logic/51.9.1-maintained-table-partial-unique.sqllogic +36 -0
- package/test/logic/52-lens-overrides.sqllogic +566 -0
- package/test/logic/53-materialized-views-rowtime.sqllogic +1601 -0
- package/test/logic/53-reserved-tags.sqllogic +252 -0
- package/test/logic/53.1-materialized-view-write-through.sqllogic +329 -0
- package/test/logic/53.2-materialized-view-rename-propagation.sqllogic +483 -0
- package/test/logic/53.3-materialized-view-constraint-only-ddl.sqllogic +409 -0
- package/test/logic/53.3.1-materialized-view-index-ddl-irrelevance.sqllogic +29 -0
- package/test/logic/53.4-materialized-view-structural-alter-restore.sqllogic +436 -0
- package/test/logic/54-covering-mv-enforcement.sqllogic +314 -0
- package/test/logic/54.1-covering-mv-partial-enforcement.sqllogic +34 -0
- package/test/logic/55-internal-eviction-reporting.sqllogic +89 -0
- package/test/logic/55-lens-prover.sqllogic +202 -0
- package/test/logic/55.1-eviction-restrict-fk.sqllogic +148 -0
- package/test/logic/55.5-lens-authored-inverse.sqllogic +1468 -0
- package/test/logic/80-grow-retrieve-pass.sqllogic +79 -0
- package/test/logic/81-quickpick.sqllogic +24 -0
- package/test/logic/82-bloom-join.sqllogic +185 -0
- package/test/logic/83-merge-join.sqllogic +280 -0
- package/test/logic/84-asof-scan.sqllogic +238 -0
- package/test/logic/84-key-cardinality.sqllogic +50 -0
- package/test/logic/85-relational-const-folding.sqllogic +51 -0
- package/test/logic/86-scalar-cse.sqllogic +42 -0
- package/test/logic/90-error_paths.sqllogic +114 -0
- package/test/logic/90.1-parse-errors.sqllogic +77 -0
- package/test/logic/90.2-alter-table-errors.sqllogic +53 -0
- package/test/logic/90.2.1-alter-extra-errors.sqllogic +51 -0
- package/test/logic/90.3-expression-errors.sqllogic +43 -0
- package/test/logic/90.4-dml-errors.sqllogic +47 -0
- package/test/logic/90.5-unsupported-join-types.sqllogic +37 -0
- package/test/logic/90.5.1-right-full-join-read.sqllogic +157 -0
- package/test/logic/90.6-select-error-paths.sqllogic +57 -0
- package/test/logic/91-merge-join-edge-cases.sqllogic +159 -0
- package/test/logic/92-hash-aggregate-edge-cases.sqllogic +139 -0
- package/test/logic/93-ddl-view-edge-cases.sqllogic +104 -0
- package/test/logic/93.1-view-error-paths.sqllogic +74 -0
- package/test/logic/93.2-view-mutation-pending.sqllogic +108 -0
- package/test/logic/93.3-view-mutation-or-clause.sqllogic +60 -0
- package/test/logic/93.4-view-mutation.sqllogic +4881 -0
- package/test/logic/93.4.1-view-mutation-partial-unique-cardinality.sqllogic +31 -0
- package/test/logic/93.5-authored-inverse.sqllogic +415 -0
- package/test/logic/93.6-set-op-flagless-write.sqllogic +862 -0
- package/test/logic/94-tvf-edge-cases.sqllogic +58 -0
- package/test/logic/94.1-limit-offset-edge-cases.sqllogic +109 -0
- package/test/logic/94.2-limit-offset-extras.sqllogic +98 -0
- package/test/logic/95-assertions.sqllogic +1417 -0
- package/test/logic/96-subquery-edge-cases.sqllogic +276 -0
- package/test/logic/97-json-function-edge-cases.sqllogic +633 -0
- package/test/logic/97.1-json-blob-and-special-values.sqllogic +92 -0
- package/test/logic/98-temporal-edge-cases.sqllogic +515 -0
- package/test/logic/99-conversion-edge-cases.sqllogic +325 -0
- package/test/logic/99.0.1-schema-index-listing.sqllogic +21 -0
- package/test/logic/99.1-cast-syntax-extras.sqllogic +167 -0
- package/test/logic/drop-unique-index.sqllogic +88 -0
- package/test/logic/pushdown-test.sqllogic +36 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
-- Window Function Edge Cases
|
|
2
|
+
-- Tests targeting frame boundary corner cases, partition edge behavior,
|
|
3
|
+
-- and composition scenarios not covered by 07.5-window.sqllogic
|
|
4
|
+
|
|
5
|
+
-- =============================================================================
|
|
6
|
+
-- Setup
|
|
7
|
+
-- =============================================================================
|
|
8
|
+
|
|
9
|
+
CREATE TABLE w (id INTEGER PRIMARY KEY, val INTEGER, grp TEXT);
|
|
10
|
+
INSERT INTO w VALUES
|
|
11
|
+
(1, 10, 'A'), (2, 20, 'A'), (3, 30, 'A'), (4, 40, 'B'), (5, 50, 'B');
|
|
12
|
+
|
|
13
|
+
-- =============================================================================
|
|
14
|
+
-- Zero-width frame: ROWS BETWEEN 0 PRECEDING AND 0 FOLLOWING
|
|
15
|
+
-- Should include only the current row
|
|
16
|
+
-- =============================================================================
|
|
17
|
+
|
|
18
|
+
SELECT id, val,
|
|
19
|
+
sum(val) OVER (ORDER BY id ROWS BETWEEN 0 PRECEDING AND 0 FOLLOWING) as s,
|
|
20
|
+
count(*) OVER (ORDER BY id ROWS BETWEEN 0 PRECEDING AND 0 FOLLOWING) as c
|
|
21
|
+
FROM w ORDER BY id;
|
|
22
|
+
→ [{"id":1,"val":10,"s":10,"c":1},{"id":2,"val":20,"s":20,"c":1},{"id":3,"val":30,"s":30,"c":1},{"id":4,"val":40,"s":40,"c":1},{"id":5,"val":50,"s":50,"c":1}]
|
|
23
|
+
|
|
24
|
+
-- =============================================================================
|
|
25
|
+
-- Frame excluding current row: ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING
|
|
26
|
+
-- Frame is exactly the one row before the current row
|
|
27
|
+
-- =============================================================================
|
|
28
|
+
|
|
29
|
+
SELECT id, val,
|
|
30
|
+
sum(val) OVER (ORDER BY id ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) as prev_sum
|
|
31
|
+
FROM w ORDER BY id;
|
|
32
|
+
→ [{"id":1,"val":10,"prev_sum":null},{"id":2,"val":20,"prev_sum":10},{"id":3,"val":30,"prev_sum":20},{"id":4,"val":40,"prev_sum":30},{"id":5,"val":50,"prev_sum":40}]
|
|
33
|
+
|
|
34
|
+
-- Similarly for FOLLOWING: ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING
|
|
35
|
+
SELECT id, val,
|
|
36
|
+
sum(val) OVER (ORDER BY id ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING) as next_sum
|
|
37
|
+
FROM w ORDER BY id;
|
|
38
|
+
→ [{"id":1,"val":10,"next_sum":20},{"id":2,"val":20,"next_sum":30},{"id":3,"val":30,"next_sum":40},{"id":4,"val":40,"next_sum":50},{"id":5,"val":50,"next_sum":null}]
|
|
39
|
+
|
|
40
|
+
-- =============================================================================
|
|
41
|
+
-- Empty partition: WHERE filter removes all rows for a partition key value
|
|
42
|
+
-- No phantom partition should appear
|
|
43
|
+
-- =============================================================================
|
|
44
|
+
|
|
45
|
+
SELECT id, val,
|
|
46
|
+
row_number() OVER (PARTITION BY grp ORDER BY id) as rn,
|
|
47
|
+
count(*) OVER (PARTITION BY grp) as cnt
|
|
48
|
+
FROM w WHERE grp = 'C' ORDER BY id;
|
|
49
|
+
→ []
|
|
50
|
+
|
|
51
|
+
-- =============================================================================
|
|
52
|
+
-- Single-row partition with all window functions
|
|
53
|
+
-- =============================================================================
|
|
54
|
+
|
|
55
|
+
CREATE TABLE single (id INTEGER PRIMARY KEY, val INTEGER);
|
|
56
|
+
INSERT INTO single VALUES (1, 42);
|
|
57
|
+
|
|
58
|
+
SELECT val,
|
|
59
|
+
row_number() OVER (ORDER BY id) as rn,
|
|
60
|
+
rank() OVER (ORDER BY id) as rnk,
|
|
61
|
+
dense_rank() OVER (ORDER BY id) as drnk,
|
|
62
|
+
lag(val) OVER (ORDER BY id) as lg,
|
|
63
|
+
lead(val) OVER (ORDER BY id) as ld,
|
|
64
|
+
sum(val) OVER (ORDER BY id) as s,
|
|
65
|
+
percent_rank() OVER (ORDER BY id) as pr,
|
|
66
|
+
cume_dist() OVER (ORDER BY id) as cd
|
|
67
|
+
FROM single;
|
|
68
|
+
→ [{"val":42,"rn":1,"rnk":1,"drnk":1,"lg":null,"ld":null,"s":42,"pr":0,"cd":1}]
|
|
69
|
+
|
|
70
|
+
DROP TABLE single;
|
|
71
|
+
|
|
72
|
+
-- =============================================================================
|
|
73
|
+
-- Mixed ASC/DESC in window ORDER BY
|
|
74
|
+
-- Verify frame boundaries respect the composite ordering
|
|
75
|
+
-- =============================================================================
|
|
76
|
+
|
|
77
|
+
CREATE TABLE mixed_order (id INTEGER PRIMARY KEY, a INTEGER, b INTEGER, val INTEGER);
|
|
78
|
+
INSERT INTO mixed_order VALUES
|
|
79
|
+
(1, 1, 30, 100),
|
|
80
|
+
(2, 1, 20, 200),
|
|
81
|
+
(3, 1, 10, 300),
|
|
82
|
+
(4, 2, 30, 400),
|
|
83
|
+
(5, 2, 20, 500);
|
|
84
|
+
|
|
85
|
+
-- ORDER BY a ASC, b DESC means: (1,30), (1,20), (1,10), (2,30), (2,20)
|
|
86
|
+
SELECT id, a, b, val,
|
|
87
|
+
row_number() OVER (ORDER BY a ASC, b DESC) as rn,
|
|
88
|
+
sum(val) OVER (ORDER BY a ASC, b DESC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as running
|
|
89
|
+
FROM mixed_order ORDER BY a ASC, b DESC;
|
|
90
|
+
→ [{"id":1,"a":1,"b":30,"val":100,"rn":1,"running":100},{"id":2,"a":1,"b":20,"val":200,"rn":2,"running":300},{"id":3,"a":1,"b":10,"val":300,"rn":3,"running":600},{"id":4,"a":2,"b":30,"val":400,"rn":4,"running":1000},{"id":5,"a":2,"b":20,"val":500,"rn":5,"running":1500}]
|
|
91
|
+
|
|
92
|
+
-- Verify lag/lead follow the composite ordering
|
|
93
|
+
SELECT id, a, b, val,
|
|
94
|
+
lag(val) OVER (ORDER BY a ASC, b DESC) as prev_val,
|
|
95
|
+
lead(val) OVER (ORDER BY a ASC, b DESC) as next_val
|
|
96
|
+
FROM mixed_order ORDER BY a ASC, b DESC;
|
|
97
|
+
→ [{"id":1,"a":1,"b":30,"val":100,"prev_val":null,"next_val":200},{"id":2,"a":1,"b":20,"val":200,"prev_val":100,"next_val":300},{"id":3,"a":1,"b":10,"val":300,"prev_val":200,"next_val":400},{"id":4,"a":2,"b":30,"val":400,"prev_val":300,"next_val":500},{"id":5,"a":2,"b":20,"val":500,"prev_val":400,"next_val":null}]
|
|
98
|
+
|
|
99
|
+
DROP TABLE mixed_order;
|
|
100
|
+
|
|
101
|
+
-- =============================================================================
|
|
102
|
+
-- Large LAG/LEAD offsets beyond partition
|
|
103
|
+
-- Should return default value (NULL) when offset exceeds partition size
|
|
104
|
+
-- =============================================================================
|
|
105
|
+
|
|
106
|
+
SELECT id, val, grp,
|
|
107
|
+
lag(val, 100) OVER (PARTITION BY grp ORDER BY id) as lag100,
|
|
108
|
+
lead(val, 100) OVER (PARTITION BY grp ORDER BY id) as lead100
|
|
109
|
+
FROM w ORDER BY id;
|
|
110
|
+
→ [{"id":1,"val":10,"grp":"A","lag100":null,"lead100":null},{"id":2,"val":20,"grp":"A","lag100":null,"lead100":null},{"id":3,"val":30,"grp":"A","lag100":null,"lead100":null},{"id":4,"val":40,"grp":"B","lag100":null,"lead100":null},{"id":5,"val":50,"grp":"B","lag100":null,"lead100":null}]
|
|
111
|
+
|
|
112
|
+
-- Large offset with explicit default value
|
|
113
|
+
SELECT id, val,
|
|
114
|
+
lag(val, 100, -1) OVER (ORDER BY id) as lag_def,
|
|
115
|
+
lead(val, 100, -1) OVER (ORDER BY id) as lead_def
|
|
116
|
+
FROM w ORDER BY id;
|
|
117
|
+
→ [{"id":1,"val":10,"lag_def":-1,"lead_def":-1},{"id":2,"val":20,"lag_def":-1,"lead_def":-1},{"id":3,"val":30,"lag_def":-1,"lead_def":-1},{"id":4,"val":40,"lag_def":-1,"lead_def":-1},{"id":5,"val":50,"lag_def":-1,"lead_def":-1}]
|
|
118
|
+
|
|
119
|
+
-- =============================================================================
|
|
120
|
+
-- RANGE frame with peers
|
|
121
|
+
-- RANGE BETWEEN CURRENT ROW AND CURRENT ROW on data with duplicate order keys
|
|
122
|
+
-- Should include all peer rows, not just the current row
|
|
123
|
+
-- =============================================================================
|
|
124
|
+
|
|
125
|
+
CREATE TABLE peers (id INTEGER PRIMARY KEY, val INTEGER, score INTEGER);
|
|
126
|
+
INSERT INTO peers VALUES
|
|
127
|
+
(1, 10, 100),
|
|
128
|
+
(2, 10, 200),
|
|
129
|
+
(3, 20, 300),
|
|
130
|
+
(4, 20, 400),
|
|
131
|
+
(5, 20, 500),
|
|
132
|
+
(6, 30, 600);
|
|
133
|
+
|
|
134
|
+
SELECT id, val, score,
|
|
135
|
+
count(*) OVER (ORDER BY val RANGE BETWEEN CURRENT ROW AND CURRENT ROW) as peer_count,
|
|
136
|
+
sum(score) OVER (ORDER BY val RANGE BETWEEN CURRENT ROW AND CURRENT ROW) as peer_sum
|
|
137
|
+
FROM peers ORDER BY id;
|
|
138
|
+
→ [{"id":1,"val":10,"score":100,"peer_count":2,"peer_sum":300},{"id":2,"val":10,"score":200,"peer_count":2,"peer_sum":300},{"id":3,"val":20,"score":300,"peer_count":3,"peer_sum":1200},{"id":4,"val":20,"score":400,"peer_count":3,"peer_sum":1200},{"id":5,"val":20,"score":500,"peer_count":3,"peer_sum":1200},{"id":6,"val":30,"score":600,"peer_count":1,"peer_sum":600}]
|
|
139
|
+
|
|
140
|
+
-- Contrast with ROWS which should only include the current row
|
|
141
|
+
SELECT id, val, score,
|
|
142
|
+
count(*) OVER (ORDER BY val ROWS BETWEEN CURRENT ROW AND CURRENT ROW) as row_count,
|
|
143
|
+
sum(score) OVER (ORDER BY val ROWS BETWEEN CURRENT ROW AND CURRENT ROW) as row_sum
|
|
144
|
+
FROM peers ORDER BY id;
|
|
145
|
+
→ [{"id":1,"val":10,"score":100,"row_count":1,"row_sum":100},{"id":2,"val":10,"score":200,"row_count":1,"row_sum":200},{"id":3,"val":20,"score":300,"row_count":1,"row_sum":300},{"id":4,"val":20,"score":400,"row_count":1,"row_sum":400},{"id":5,"val":20,"score":500,"row_count":1,"row_sum":500},{"id":6,"val":30,"score":600,"row_count":1,"row_sum":600}]
|
|
146
|
+
|
|
147
|
+
DROP TABLE peers;
|
|
148
|
+
|
|
149
|
+
-- =============================================================================
|
|
150
|
+
-- Window function over zero rows
|
|
151
|
+
-- Should return zero rows, not error
|
|
152
|
+
-- =============================================================================
|
|
153
|
+
|
|
154
|
+
SELECT row_number() OVER (ORDER BY id) as rn FROM w WHERE 1 = 0;
|
|
155
|
+
→ []
|
|
156
|
+
|
|
157
|
+
SELECT sum(val) OVER (ORDER BY id) as s,
|
|
158
|
+
count(*) OVER (ORDER BY id) as c,
|
|
159
|
+
rank() OVER (ORDER BY id) as r
|
|
160
|
+
FROM w WHERE 1 = 0;
|
|
161
|
+
→ []
|
|
162
|
+
|
|
163
|
+
-- =============================================================================
|
|
164
|
+
-- Multiple different window definitions in one query
|
|
165
|
+
-- Each OVER clause has different PARTITION BY and ORDER BY — verify independence
|
|
166
|
+
-- =============================================================================
|
|
167
|
+
|
|
168
|
+
SELECT id, val, grp,
|
|
169
|
+
row_number() OVER (ORDER BY id) as global_rn,
|
|
170
|
+
row_number() OVER (PARTITION BY grp ORDER BY id) as grp_rn,
|
|
171
|
+
sum(val) OVER (PARTITION BY grp) as grp_total,
|
|
172
|
+
sum(val) OVER () as grand_total,
|
|
173
|
+
lag(val) OVER (PARTITION BY grp ORDER BY id) as grp_prev,
|
|
174
|
+
lag(val) OVER (ORDER BY id) as global_prev
|
|
175
|
+
FROM w ORDER BY id;
|
|
176
|
+
→ [{"id":1,"val":10,"grp":"A","global_rn":1,"grp_rn":1,"grp_total":60,"grand_total":150,"grp_prev":null,"global_prev":null},{"id":2,"val":20,"grp":"A","global_rn":2,"grp_rn":2,"grp_total":60,"grand_total":150,"grp_prev":10,"global_prev":10},{"id":3,"val":30,"grp":"A","global_rn":3,"grp_rn":3,"grp_total":60,"grand_total":150,"grp_prev":20,"global_prev":20},{"id":4,"val":40,"grp":"B","global_rn":4,"grp_rn":1,"grp_total":90,"grand_total":150,"grp_prev":null,"global_prev":30},{"id":5,"val":50,"grp":"B","global_rn":5,"grp_rn":2,"grp_total":90,"grand_total":150,"grp_prev":40,"global_prev":40}]
|
|
177
|
+
|
|
178
|
+
-- =============================================================================
|
|
179
|
+
-- Window function in subquery used in outer aggregate
|
|
180
|
+
-- Composition of window + aggregate
|
|
181
|
+
-- =============================================================================
|
|
182
|
+
|
|
183
|
+
-- sum of row_numbers: 1+2+3+4+5 = 15
|
|
184
|
+
SELECT sum(rn) as total_rn FROM (
|
|
185
|
+
SELECT row_number() OVER (ORDER BY id) as rn FROM w
|
|
186
|
+
);
|
|
187
|
+
→ [{"total_rn":15}]
|
|
188
|
+
|
|
189
|
+
-- avg of per-group row_numbers: group A has rn 1,2,3 → avg 2; group B has 1,2 → avg 1.5
|
|
190
|
+
-- overall avg of (1,2,3,1,2) = 9/5 = 1.8
|
|
191
|
+
SELECT avg(grp_rn) as avg_rn FROM (
|
|
192
|
+
SELECT row_number() OVER (PARTITION BY grp ORDER BY id) as grp_rn FROM w
|
|
193
|
+
);
|
|
194
|
+
→ [{"avg_rn":1.8}]
|
|
195
|
+
|
|
196
|
+
-- max of running sums
|
|
197
|
+
SELECT max(rs) as max_running FROM (
|
|
198
|
+
SELECT sum(val) OVER (ORDER BY id ROWS UNBOUNDED PRECEDING) as rs FROM w
|
|
199
|
+
);
|
|
200
|
+
→ [{"max_running":150}]
|
|
201
|
+
|
|
202
|
+
-- =============================================================================
|
|
203
|
+
-- Cleanup
|
|
204
|
+
-- =============================================================================
|
|
205
|
+
|
|
206
|
+
DROP TABLE w;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
-- adapted from SQLite test/window1.test, test/window2.test, test/window7.test, test/window8.test
|
|
2
|
+
-- GROUPS frame mode is not yet supported by the Quereus parser. Document
|
|
3
|
+
-- the rejection.
|
|
4
|
+
|
|
5
|
+
create table gf (id integer primary key, val integer);
|
|
6
|
+
insert into gf values (1, 10), (2, 10), (3, 20);
|
|
7
|
+
|
|
8
|
+
select id, val,
|
|
9
|
+
count(*) over (order by val groups current row) as peer_count
|
|
10
|
+
from gf order by id;
|
|
11
|
+
-- error: groups
|
|
12
|
+
|
|
13
|
+
drop table gf;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
-- adapted from SQLite test/window1.test, test/window2.test, test/window5.test, test/window8.test
|
|
2
|
+
-- EXCLUDE clause modifiers (NO OTHERS / CURRENT ROW / GROUP / TIES) are not
|
|
3
|
+
-- yet supported by the Quereus parser. Document the rejection.
|
|
4
|
+
|
|
5
|
+
create table ex (id integer primary key, val integer);
|
|
6
|
+
insert into ex values (1, 10), (2, 20);
|
|
7
|
+
|
|
8
|
+
select id, val,
|
|
9
|
+
sum(val) over (order by val rows between unbounded preceding and unbounded following exclude no others) as s
|
|
10
|
+
from ex order by id;
|
|
11
|
+
-- error: exclude
|
|
12
|
+
|
|
13
|
+
drop table ex;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
-- 27.3-window-json-aggregation.sqllogic
|
|
2
|
+
-- adapted from SQLite test/json103.test (json103-400, json103-410)
|
|
3
|
+
-- json_group_array() and json_group_object() used as window functions over a frame.
|
|
4
|
+
-- Per Quereus design (see AGENTS.md / framework notes): json_group_array and
|
|
5
|
+
-- json_group_object are registered via createAggregateFunction only and are not
|
|
6
|
+
-- invocable as window functions; the planner rejects the OVER form.
|
|
7
|
+
|
|
8
|
+
CREATE TABLE w_jagg (id INTEGER PRIMARY KEY, x TEXT);
|
|
9
|
+
INSERT INTO w_jagg VALUES
|
|
10
|
+
(1, '1'),
|
|
11
|
+
(2, 'a,b'),
|
|
12
|
+
(3, '3'),
|
|
13
|
+
(4, 'x"y'),
|
|
14
|
+
(5, '5'),
|
|
15
|
+
(6, '6'),
|
|
16
|
+
(7, '7');
|
|
17
|
+
-- run
|
|
18
|
+
|
|
19
|
+
-- json_group_array as window aggregate is rejected
|
|
20
|
+
SELECT id, json_group_array(x) OVER (ORDER BY id ROWS 2 PRECEDING) as ga FROM w_jagg ORDER BY id;
|
|
21
|
+
-- error: Unknown window function: json_group_array
|
|
22
|
+
|
|
23
|
+
-- json_group_object as window aggregate is rejected
|
|
24
|
+
SELECT id, json_group_object(cast(id as text), x) OVER (ORDER BY id ROWS 2 PRECEDING) as go FROM w_jagg ORDER BY id;
|
|
25
|
+
-- error: Unknown window function: json_group_object
|
|
26
|
+
|
|
27
|
+
-- json_group_array with PARTITION BY also rejected
|
|
28
|
+
CREATE TABLE w_jagg_part (grp TEXT, val INTEGER);
|
|
29
|
+
INSERT INTO w_jagg_part VALUES
|
|
30
|
+
('a', 10),
|
|
31
|
+
('a', 20),
|
|
32
|
+
('a', 30),
|
|
33
|
+
('b', 100),
|
|
34
|
+
('b', 200);
|
|
35
|
+
-- run
|
|
36
|
+
|
|
37
|
+
SELECT grp, val, json_group_array(val) OVER (PARTITION BY grp ORDER BY val ROWS UNBOUNDED PRECEDING) as ga
|
|
38
|
+
FROM w_jagg_part ORDER BY grp, val;
|
|
39
|
+
-- error: Unknown window function: json_group_array
|
|
40
|
+
|
|
41
|
+
-- json_group_array as plain (non-window) aggregate, GROUP BY — supported
|
|
42
|
+
SELECT grp, json_group_array(val) as ga FROM w_jagg_part GROUP BY grp ORDER BY grp;
|
|
43
|
+
→ [{"grp":"a","ga":[10,20,30]},{"grp":"b","ga":[100,200]}]
|
|
44
|
+
|
|
45
|
+
DROP TABLE w_jagg;
|
|
46
|
+
DROP TABLE w_jagg_part;
|
|
47
|
+
|
|
48
|
+
-- Window min()/max() over a JSON column rank structurally, matching the plain
|
|
49
|
+
-- aggregate and ORDER BY (docs/types.md "Semantic ordering"). Canonical-text order
|
|
50
|
+
-- would report mn=[10], mx=[9].
|
|
51
|
+
CREATE TABLE w_jmm (id INTEGER PRIMARY KEY, d JSON);
|
|
52
|
+
INSERT INTO w_jmm VALUES (1, '[8,1]'), (2, '[9]'), (3, '[10]');
|
|
53
|
+
-- run
|
|
54
|
+
|
|
55
|
+
SELECT id, d FROM w_jmm ORDER BY d;
|
|
56
|
+
→ [{"id":1,"d":[8,1]},{"id":2,"d":[9]},{"id":3,"d":[10]}]
|
|
57
|
+
|
|
58
|
+
SELECT DISTINCT min(d) OVER () AS mn, max(d) OVER () AS mx FROM w_jmm;
|
|
59
|
+
→ [{"mn":[8,1],"mx":[10]}]
|
|
60
|
+
|
|
61
|
+
-- Sliding frame: each window ranks structurally on its own.
|
|
62
|
+
SELECT id, min(d) OVER (ORDER BY id ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS mn
|
|
63
|
+
FROM w_jmm ORDER BY id;
|
|
64
|
+
→ [{"id":1,"mn":[8,1]},{"id":2,"mn":[8,1]},{"id":3,"mn":[9]}]
|
|
65
|
+
|
|
66
|
+
DROP TABLE w_jmm;
|