@quereus/quereus 2.9.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (339) hide show
  1. package/README.md +224 -222
  2. package/dist/src/core/database-assertions.d.ts +36 -16
  3. package/dist/src/core/database-assertions.d.ts.map +1 -1
  4. package/dist/src/core/database-assertions.js +222 -118
  5. package/dist/src/core/database-assertions.js.map +1 -1
  6. package/dist/src/core/database-transaction.d.ts +96 -13
  7. package/dist/src/core/database-transaction.d.ts.map +1 -1
  8. package/dist/src/core/database-transaction.js +294 -35
  9. package/dist/src/core/database-transaction.js.map +1 -1
  10. package/dist/src/core/database-watchers.d.ts +58 -0
  11. package/dist/src/core/database-watchers.d.ts.map +1 -0
  12. package/dist/src/core/database-watchers.js +206 -0
  13. package/dist/src/core/database-watchers.js.map +1 -0
  14. package/dist/src/core/database.d.ts +78 -5
  15. package/dist/src/core/database.d.ts.map +1 -1
  16. package/dist/src/core/database.js +120 -20
  17. package/dist/src/core/database.js.map +1 -1
  18. package/dist/src/core/statement.d.ts +9 -0
  19. package/dist/src/core/statement.d.ts.map +1 -1
  20. package/dist/src/core/statement.js +29 -0
  21. package/dist/src/core/statement.js.map +1 -1
  22. package/dist/src/core/table-handle.d.ts +45 -0
  23. package/dist/src/core/table-handle.d.ts.map +1 -0
  24. package/dist/src/core/table-handle.js +54 -0
  25. package/dist/src/core/table-handle.js.map +1 -0
  26. package/dist/src/func/builtins/conversion.d.ts.map +1 -1
  27. package/dist/src/func/builtins/conversion.js +12 -1
  28. package/dist/src/func/builtins/conversion.js.map +1 -1
  29. package/dist/src/func/builtins/explain.d.ts.map +1 -1
  30. package/dist/src/func/builtins/explain.js +22 -8
  31. package/dist/src/func/builtins/explain.js.map +1 -1
  32. package/dist/src/func/builtins/generation.d.ts.map +1 -1
  33. package/dist/src/func/builtins/generation.js +26 -1
  34. package/dist/src/func/builtins/generation.js.map +1 -1
  35. package/dist/src/func/builtins/index.d.ts.map +1 -1
  36. package/dist/src/func/builtins/index.js +5 -1
  37. package/dist/src/func/builtins/index.js.map +1 -1
  38. package/dist/src/func/builtins/json-tvf.d.ts.map +1 -1
  39. package/dist/src/func/builtins/json-tvf.js +16 -2
  40. package/dist/src/func/builtins/json-tvf.js.map +1 -1
  41. package/dist/src/func/builtins/schema.d.ts +4 -0
  42. package/dist/src/func/builtins/schema.d.ts.map +1 -1
  43. package/dist/src/func/builtins/schema.js +270 -11
  44. package/dist/src/func/builtins/schema.js.map +1 -1
  45. package/dist/src/func/registration.d.ts +19 -1
  46. package/dist/src/func/registration.d.ts.map +1 -1
  47. package/dist/src/func/registration.js +8 -3
  48. package/dist/src/func/registration.js.map +1 -1
  49. package/dist/src/index.d.ts +7 -1
  50. package/dist/src/index.d.ts.map +1 -1
  51. package/dist/src/index.js +5 -0
  52. package/dist/src/index.js.map +1 -1
  53. package/dist/src/parser/parser.d.ts.map +1 -1
  54. package/dist/src/parser/parser.js +12 -4
  55. package/dist/src/parser/parser.js.map +1 -1
  56. package/dist/src/planner/analysis/assertion-classifier.d.ts +71 -0
  57. package/dist/src/planner/analysis/assertion-classifier.d.ts.map +1 -0
  58. package/dist/src/planner/analysis/assertion-classifier.js +286 -0
  59. package/dist/src/planner/analysis/assertion-classifier.js.map +1 -0
  60. package/dist/src/planner/analysis/assertion-hoist-cache.d.ts +34 -0
  61. package/dist/src/planner/analysis/assertion-hoist-cache.d.ts.map +1 -0
  62. package/dist/src/planner/analysis/assertion-hoist-cache.js +119 -0
  63. package/dist/src/planner/analysis/assertion-hoist-cache.js.map +1 -0
  64. package/dist/src/planner/analysis/binding-extractor.d.ts +58 -0
  65. package/dist/src/planner/analysis/binding-extractor.d.ts.map +1 -0
  66. package/dist/src/planner/analysis/binding-extractor.js +110 -0
  67. package/dist/src/planner/analysis/binding-extractor.js.map +1 -0
  68. package/dist/src/planner/analysis/change-scope.d.ts +184 -0
  69. package/dist/src/planner/analysis/change-scope.d.ts.map +1 -0
  70. package/dist/src/planner/analysis/change-scope.js +825 -0
  71. package/dist/src/planner/analysis/change-scope.js.map +1 -0
  72. package/dist/src/planner/analysis/check-extraction.d.ts +29 -0
  73. package/dist/src/planner/analysis/check-extraction.d.ts.map +1 -0
  74. package/dist/src/planner/analysis/check-extraction.js +420 -0
  75. package/dist/src/planner/analysis/check-extraction.js.map +1 -0
  76. package/dist/src/planner/analysis/constraint-extractor.d.ts +47 -7
  77. package/dist/src/planner/analysis/constraint-extractor.d.ts.map +1 -1
  78. package/dist/src/planner/analysis/constraint-extractor.js +169 -92
  79. package/dist/src/planner/analysis/constraint-extractor.js.map +1 -1
  80. package/dist/src/planner/analysis/partial-unique-extraction.d.ts +68 -0
  81. package/dist/src/planner/analysis/partial-unique-extraction.d.ts.map +1 -0
  82. package/dist/src/planner/analysis/partial-unique-extraction.js +347 -0
  83. package/dist/src/planner/analysis/partial-unique-extraction.js.map +1 -0
  84. package/dist/src/planner/analysis/predicate-conjuncts.d.ts +14 -0
  85. package/dist/src/planner/analysis/predicate-conjuncts.d.ts.map +1 -0
  86. package/dist/src/planner/analysis/predicate-conjuncts.js +31 -0
  87. package/dist/src/planner/analysis/predicate-conjuncts.js.map +1 -0
  88. package/dist/src/planner/analysis/predicate-shape.d.ts +52 -0
  89. package/dist/src/planner/analysis/predicate-shape.d.ts.map +1 -0
  90. package/dist/src/planner/analysis/predicate-shape.js +119 -0
  91. package/dist/src/planner/analysis/predicate-shape.js.map +1 -0
  92. package/dist/src/planner/analysis/sat-checker.d.ts +43 -0
  93. package/dist/src/planner/analysis/sat-checker.d.ts.map +1 -0
  94. package/dist/src/planner/analysis/sat-checker.js +393 -0
  95. package/dist/src/planner/analysis/sat-checker.js.map +1 -0
  96. package/dist/src/planner/building/table.d.ts.map +1 -1
  97. package/dist/src/planner/building/table.js +1 -1
  98. package/dist/src/planner/building/table.js.map +1 -1
  99. package/dist/src/planner/framework/characteristics.d.ts +10 -1
  100. package/dist/src/planner/framework/characteristics.d.ts.map +1 -1
  101. package/dist/src/planner/framework/characteristics.js +24 -5
  102. package/dist/src/planner/framework/characteristics.js.map +1 -1
  103. package/dist/src/planner/framework/pass.d.ts.map +1 -1
  104. package/dist/src/planner/framework/pass.js +46 -16
  105. package/dist/src/planner/framework/pass.js.map +1 -1
  106. package/dist/src/planner/framework/physical-utils.d.ts +0 -9
  107. package/dist/src/planner/framework/physical-utils.d.ts.map +1 -1
  108. package/dist/src/planner/framework/physical-utils.js +0 -31
  109. package/dist/src/planner/framework/physical-utils.js.map +1 -1
  110. package/dist/src/planner/nodes/aggregate-node.d.ts +25 -0
  111. package/dist/src/planner/nodes/aggregate-node.d.ts.map +1 -1
  112. package/dist/src/planner/nodes/aggregate-node.js +75 -8
  113. package/dist/src/planner/nodes/aggregate-node.js.map +1 -1
  114. package/dist/src/planner/nodes/alias-node.d.ts.map +1 -1
  115. package/dist/src/planner/nodes/alias-node.js +6 -1
  116. package/dist/src/planner/nodes/alias-node.js.map +1 -1
  117. package/dist/src/planner/nodes/asof-scan-node.d.ts.map +1 -1
  118. package/dist/src/planner/nodes/asof-scan-node.js +17 -3
  119. package/dist/src/planner/nodes/asof-scan-node.js.map +1 -1
  120. package/dist/src/planner/nodes/bloom-join-node.d.ts.map +1 -1
  121. package/dist/src/planner/nodes/bloom-join-node.js +19 -9
  122. package/dist/src/planner/nodes/bloom-join-node.js.map +1 -1
  123. package/dist/src/planner/nodes/distinct-node.d.ts.map +1 -1
  124. package/dist/src/planner/nodes/distinct-node.js +10 -6
  125. package/dist/src/planner/nodes/distinct-node.js.map +1 -1
  126. package/dist/src/planner/nodes/empty-relation-node.d.ts +27 -0
  127. package/dist/src/planner/nodes/empty-relation-node.d.ts.map +1 -0
  128. package/dist/src/planner/nodes/empty-relation-node.js +61 -0
  129. package/dist/src/planner/nodes/empty-relation-node.js.map +1 -0
  130. package/dist/src/planner/nodes/filter.d.ts.map +1 -1
  131. package/dist/src/planner/nodes/filter.js +65 -5
  132. package/dist/src/planner/nodes/filter.js.map +1 -1
  133. package/dist/src/planner/nodes/hash-aggregate.d.ts +1 -1
  134. package/dist/src/planner/nodes/hash-aggregate.d.ts.map +1 -1
  135. package/dist/src/planner/nodes/hash-aggregate.js +8 -6
  136. package/dist/src/planner/nodes/hash-aggregate.js.map +1 -1
  137. package/dist/src/planner/nodes/join-node.d.ts.map +1 -1
  138. package/dist/src/planner/nodes/join-node.js +12 -9
  139. package/dist/src/planner/nodes/join-node.js.map +1 -1
  140. package/dist/src/planner/nodes/join-utils.d.ts +24 -1
  141. package/dist/src/planner/nodes/join-utils.d.ts.map +1 -1
  142. package/dist/src/planner/nodes/join-utils.js +86 -0
  143. package/dist/src/planner/nodes/join-utils.js.map +1 -1
  144. package/dist/src/planner/nodes/limit-offset.d.ts.map +1 -1
  145. package/dist/src/planner/nodes/limit-offset.js +6 -1
  146. package/dist/src/planner/nodes/limit-offset.js.map +1 -1
  147. package/dist/src/planner/nodes/merge-join-node.d.ts.map +1 -1
  148. package/dist/src/planner/nodes/merge-join-node.js +19 -9
  149. package/dist/src/planner/nodes/merge-join-node.js.map +1 -1
  150. package/dist/src/planner/nodes/ordinal-slice-node.d.ts.map +1 -1
  151. package/dist/src/planner/nodes/ordinal-slice-node.js +5 -2
  152. package/dist/src/planner/nodes/ordinal-slice-node.js.map +1 -1
  153. package/dist/src/planner/nodes/plan-node-type.d.ts +1 -0
  154. package/dist/src/planner/nodes/plan-node-type.d.ts.map +1 -1
  155. package/dist/src/planner/nodes/plan-node-type.js +1 -0
  156. package/dist/src/planner/nodes/plan-node-type.js.map +1 -1
  157. package/dist/src/planner/nodes/plan-node.d.ts +186 -4
  158. package/dist/src/planner/nodes/plan-node.d.ts.map +1 -1
  159. package/dist/src/planner/nodes/plan-node.js.map +1 -1
  160. package/dist/src/planner/nodes/project-node.d.ts.map +1 -1
  161. package/dist/src/planner/nodes/project-node.js +75 -30
  162. package/dist/src/planner/nodes/project-node.js.map +1 -1
  163. package/dist/src/planner/nodes/reference.d.ts +24 -2
  164. package/dist/src/planner/nodes/reference.d.ts.map +1 -1
  165. package/dist/src/planner/nodes/reference.js +101 -1
  166. package/dist/src/planner/nodes/reference.js.map +1 -1
  167. package/dist/src/planner/nodes/retrieve-node.d.ts +9 -1
  168. package/dist/src/planner/nodes/retrieve-node.d.ts.map +1 -1
  169. package/dist/src/planner/nodes/retrieve-node.js +21 -0
  170. package/dist/src/planner/nodes/retrieve-node.js.map +1 -1
  171. package/dist/src/planner/nodes/returning-node.d.ts.map +1 -1
  172. package/dist/src/planner/nodes/returning-node.js +64 -28
  173. package/dist/src/planner/nodes/returning-node.js.map +1 -1
  174. package/dist/src/planner/nodes/scalar.d.ts +1 -0
  175. package/dist/src/planner/nodes/scalar.d.ts.map +1 -1
  176. package/dist/src/planner/nodes/scalar.js +12 -0
  177. package/dist/src/planner/nodes/scalar.js.map +1 -1
  178. package/dist/src/planner/nodes/set-operation-node.d.ts.map +1 -1
  179. package/dist/src/planner/nodes/set-operation-node.js +15 -0
  180. package/dist/src/planner/nodes/set-operation-node.js.map +1 -1
  181. package/dist/src/planner/nodes/single-row.d.ts.map +1 -1
  182. package/dist/src/planner/nodes/single-row.js +3 -1
  183. package/dist/src/planner/nodes/single-row.js.map +1 -1
  184. package/dist/src/planner/nodes/sort.d.ts.map +1 -1
  185. package/dist/src/planner/nodes/sort.js +10 -3
  186. package/dist/src/planner/nodes/sort.js.map +1 -1
  187. package/dist/src/planner/nodes/stream-aggregate.d.ts +1 -1
  188. package/dist/src/planner/nodes/stream-aggregate.d.ts.map +1 -1
  189. package/dist/src/planner/nodes/stream-aggregate.js +8 -8
  190. package/dist/src/planner/nodes/stream-aggregate.js.map +1 -1
  191. package/dist/src/planner/nodes/table-access-nodes.d.ts +3 -3
  192. package/dist/src/planner/nodes/table-access-nodes.d.ts.map +1 -1
  193. package/dist/src/planner/nodes/table-access-nodes.js +26 -8
  194. package/dist/src/planner/nodes/table-access-nodes.js.map +1 -1
  195. package/dist/src/planner/nodes/table-function-call.d.ts +4 -1
  196. package/dist/src/planner/nodes/table-function-call.d.ts.map +1 -1
  197. package/dist/src/planner/nodes/table-function-call.js +224 -14
  198. package/dist/src/planner/nodes/table-function-call.js.map +1 -1
  199. package/dist/src/planner/nodes/window-node.d.ts.map +1 -1
  200. package/dist/src/planner/nodes/window-node.js +9 -2
  201. package/dist/src/planner/nodes/window-node.js.map +1 -1
  202. package/dist/src/planner/optimizer-tuning.d.ts +29 -1
  203. package/dist/src/planner/optimizer-tuning.d.ts.map +1 -1
  204. package/dist/src/planner/optimizer-tuning.js +3 -0
  205. package/dist/src/planner/optimizer-tuning.js.map +1 -1
  206. package/dist/src/planner/optimizer.d.ts.map +1 -1
  207. package/dist/src/planner/optimizer.js +187 -0
  208. package/dist/src/planner/optimizer.js.map +1 -1
  209. package/dist/src/planner/rules/access/rule-select-access-path.d.ts.map +1 -1
  210. package/dist/src/planner/rules/access/rule-select-access-path.js +22 -7
  211. package/dist/src/planner/rules/access/rule-select-access-path.js.map +1 -1
  212. package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.d.ts +30 -0
  213. package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.d.ts.map +1 -0
  214. package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.js +116 -0
  215. package/dist/src/planner/rules/aggregate/rule-groupby-fd-simplification.js.map +1 -0
  216. package/dist/src/planner/rules/distinct/rule-distinct-elimination.d.ts +7 -7
  217. package/dist/src/planner/rules/distinct/rule-distinct-elimination.d.ts.map +1 -1
  218. package/dist/src/planner/rules/distinct/rule-distinct-elimination.js +18 -16
  219. package/dist/src/planner/rules/distinct/rule-distinct-elimination.js.map +1 -1
  220. package/dist/src/planner/rules/join/rule-join-elimination.d.ts +56 -0
  221. package/dist/src/planner/rules/join/rule-join-elimination.d.ts.map +1 -0
  222. package/dist/src/planner/rules/join/rule-join-elimination.js +326 -0
  223. package/dist/src/planner/rules/join/rule-join-elimination.js.map +1 -0
  224. package/dist/src/planner/rules/join/rule-join-greedy-commute.d.ts.map +1 -1
  225. package/dist/src/planner/rules/join/rule-join-greedy-commute.js +10 -2
  226. package/dist/src/planner/rules/join/rule-join-greedy-commute.js.map +1 -1
  227. package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.d.ts +20 -0
  228. package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.d.ts.map +1 -0
  229. package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.js +181 -0
  230. package/dist/src/planner/rules/predicate/rule-aggregate-predicate-pushdown.js.map +1 -0
  231. package/dist/src/planner/rules/predicate/rule-empty-relation-folding.d.ts +46 -0
  232. package/dist/src/planner/rules/predicate/rule-empty-relation-folding.d.ts.map +1 -0
  233. package/dist/src/planner/rules/predicate/rule-empty-relation-folding.js +156 -0
  234. package/dist/src/planner/rules/predicate/rule-empty-relation-folding.js.map +1 -0
  235. package/dist/src/planner/rules/predicate/rule-filter-contradiction.d.ts +30 -0
  236. package/dist/src/planner/rules/predicate/rule-filter-contradiction.d.ts.map +1 -0
  237. package/dist/src/planner/rules/predicate/rule-filter-contradiction.js +60 -0
  238. package/dist/src/planner/rules/predicate/rule-filter-contradiction.js.map +1 -0
  239. package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.d.ts +45 -0
  240. package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.d.ts.map +1 -0
  241. package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.js +210 -0
  242. package/dist/src/planner/rules/predicate/rule-predicate-inference-equivalence.js.map +1 -0
  243. package/dist/src/planner/rules/predicate/rule-sargable-range-rewrite.d.ts +29 -0
  244. package/dist/src/planner/rules/predicate/rule-sargable-range-rewrite.d.ts.map +1 -0
  245. package/dist/src/planner/rules/predicate/rule-sargable-range-rewrite.js +161 -0
  246. package/dist/src/planner/rules/predicate/rule-sargable-range-rewrite.js.map +1 -0
  247. package/dist/src/planner/rules/sort/rule-orderby-fd-pruning.d.ts +39 -0
  248. package/dist/src/planner/rules/sort/rule-orderby-fd-pruning.d.ts.map +1 -0
  249. package/dist/src/planner/rules/sort/rule-orderby-fd-pruning.js +91 -0
  250. package/dist/src/planner/rules/sort/rule-orderby-fd-pruning.js.map +1 -0
  251. package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.d.ts +35 -0
  252. package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.d.ts.map +1 -0
  253. package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.js +74 -0
  254. package/dist/src/planner/rules/subquery/rule-anti-join-fk-empty.js.map +1 -0
  255. package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.d.ts +27 -0
  256. package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.d.ts.map +1 -0
  257. package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.js +103 -0
  258. package/dist/src/planner/rules/subquery/rule-semi-join-fk-trivial.js.map +1 -0
  259. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.d.ts.map +1 -1
  260. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js +1 -25
  261. package/dist/src/planner/rules/subquery/rule-subquery-decorrelation.js.map +1 -1
  262. package/dist/src/planner/scopes/global.js +2 -2
  263. package/dist/src/planner/scopes/global.js.map +1 -1
  264. package/dist/src/planner/type-utils.d.ts.map +1 -1
  265. package/dist/src/planner/type-utils.js +11 -0
  266. package/dist/src/planner/type-utils.js.map +1 -1
  267. package/dist/src/planner/util/fd-utils.d.ts +245 -0
  268. package/dist/src/planner/util/fd-utils.d.ts.map +1 -0
  269. package/dist/src/planner/util/fd-utils.js +1416 -0
  270. package/dist/src/planner/util/fd-utils.js.map +1 -0
  271. package/dist/src/planner/util/ind-utils.d.ts +79 -0
  272. package/dist/src/planner/util/ind-utils.d.ts.map +1 -0
  273. package/dist/src/planner/util/ind-utils.js +146 -0
  274. package/dist/src/planner/util/ind-utils.js.map +1 -0
  275. package/dist/src/planner/util/key-utils.d.ts +75 -14
  276. package/dist/src/planner/util/key-utils.d.ts.map +1 -1
  277. package/dist/src/planner/util/key-utils.js +234 -57
  278. package/dist/src/planner/util/key-utils.js.map +1 -1
  279. package/dist/src/runtime/delta-executor.d.ts +134 -0
  280. package/dist/src/runtime/delta-executor.d.ts.map +1 -0
  281. package/dist/src/runtime/delta-executor.js +382 -0
  282. package/dist/src/runtime/delta-executor.js.map +1 -0
  283. package/dist/src/runtime/emit/alter-table.d.ts.map +1 -1
  284. package/dist/src/runtime/emit/alter-table.js +52 -16
  285. package/dist/src/runtime/emit/alter-table.js.map +1 -1
  286. package/dist/src/runtime/emit/create-assertion.d.ts.map +1 -1
  287. package/dist/src/runtime/emit/create-assertion.js +3 -2
  288. package/dist/src/runtime/emit/create-assertion.js.map +1 -1
  289. package/dist/src/runtime/emit/dml-executor.d.ts.map +1 -1
  290. package/dist/src/runtime/emit/dml-executor.js +40 -13
  291. package/dist/src/runtime/emit/dml-executor.js.map +1 -1
  292. package/dist/src/runtime/emit/drop-assertion.js +1 -1
  293. package/dist/src/runtime/emit/drop-assertion.js.map +1 -1
  294. package/dist/src/runtime/emit/empty-relation.d.ts +5 -0
  295. package/dist/src/runtime/emit/empty-relation.d.ts.map +1 -0
  296. package/dist/src/runtime/emit/empty-relation.js +11 -0
  297. package/dist/src/runtime/emit/empty-relation.js.map +1 -0
  298. package/dist/src/runtime/foreign-key-actions.d.ts +16 -0
  299. package/dist/src/runtime/foreign-key-actions.d.ts.map +1 -1
  300. package/dist/src/runtime/foreign-key-actions.js +81 -1
  301. package/dist/src/runtime/foreign-key-actions.js.map +1 -1
  302. package/dist/src/runtime/register.d.ts.map +1 -1
  303. package/dist/src/runtime/register.js +2 -0
  304. package/dist/src/runtime/register.js.map +1 -1
  305. package/dist/src/schema/assertion.d.ts +8 -0
  306. package/dist/src/schema/assertion.d.ts.map +1 -1
  307. package/dist/src/schema/change-events.d.ts +5 -1
  308. package/dist/src/schema/change-events.d.ts.map +1 -1
  309. package/dist/src/schema/change-events.js.map +1 -1
  310. package/dist/src/schema/function.d.ts +65 -1
  311. package/dist/src/schema/function.d.ts.map +1 -1
  312. package/dist/src/schema/function.js +31 -0
  313. package/dist/src/schema/function.js.map +1 -1
  314. package/dist/src/schema/manager.d.ts +33 -0
  315. package/dist/src/schema/manager.d.ts.map +1 -1
  316. package/dist/src/schema/manager.js +95 -4
  317. package/dist/src/schema/manager.js.map +1 -1
  318. package/dist/src/schema/rename-rewriter.d.ts.map +1 -1
  319. package/dist/src/schema/rename-rewriter.js +303 -102
  320. package/dist/src/schema/rename-rewriter.js.map +1 -1
  321. package/dist/src/schema/table.d.ts +21 -2
  322. package/dist/src/schema/table.d.ts.map +1 -1
  323. package/dist/src/schema/table.js +17 -8
  324. package/dist/src/schema/table.js.map +1 -1
  325. package/dist/src/types/temporal-types.d.ts.map +1 -1
  326. package/dist/src/types/temporal-types.js +32 -0
  327. package/dist/src/types/temporal-types.js.map +1 -1
  328. package/dist/src/vtab/events.d.ts +9 -0
  329. package/dist/src/vtab/events.d.ts.map +1 -1
  330. package/dist/src/vtab/events.js +19 -0
  331. package/dist/src/vtab/events.js.map +1 -1
  332. package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
  333. package/dist/src/vtab/memory/layer/manager.js +24 -5
  334. package/dist/src/vtab/memory/layer/manager.js.map +1 -1
  335. package/dist/src/vtab/memory/utils/predicate.d.ts +2 -1
  336. package/dist/src/vtab/memory/utils/predicate.d.ts.map +1 -1
  337. package/dist/src/vtab/memory/utils/predicate.js +32 -1
  338. package/dist/src/vtab/memory/utils/predicate.js.map +1 -1
  339. package/package.json +3 -3
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Rule: GROUP BY FD simplification
3
+ *
4
+ * Drops GROUP BY columns that are functionally determined by other remaining
5
+ * GROUP BY columns under the aggregate-output FDs and equivalence classes.
6
+ * Each dropped column is re-emitted as a `MIN(<original-column>)` picker
7
+ * aggregate so the output attribute IDs (and therefore downstream binding)
8
+ * are preserved.
9
+ *
10
+ * The aggregate's own `physical.fds` and `physical.equivClasses` are already
11
+ * projected onto its output column indices by `propagateAggregateFds`, so
12
+ * the rule reasons in aggregate-output space directly:
13
+ *
14
+ * - candidate set = bare `ColumnReferenceNode` GROUP BY output indices
15
+ * - ECs expand to bi-directional FDs over those indices
16
+ * - `minimalCover` returns the surviving indices; the rest are dropped
17
+ *
18
+ * Soundness: aggregate-output FDs only survive for bare-column GROUP BYs
19
+ * (per `propagateAggregateFds`), and EC-derived FDs from `WHERE a = b` are
20
+ * sound because every surviving row has equal values on the EC members.
21
+ *
22
+ * Rewrite preserves the output schema (positions may shift, attribute IDs do
23
+ * not): kept GROUP BYs come first, then the picker MIN aggregates re-emitting
24
+ * the dropped columns at their original attribute IDs (via
25
+ * `preserveAttributeIds`), then the original aggregate expressions.
26
+ */
27
+ import { createLogger } from '../../../common/logger.js';
28
+ import { AggregateNode } from '../../nodes/aggregate-node.js';
29
+ import { AggregateFunctionCallNode } from '../../nodes/aggregate-function.js';
30
+ import { ColumnReferenceNode } from '../../nodes/reference.js';
31
+ import { expandEcsToFds, minimalCover } from '../../util/fd-utils.js';
32
+ import { isAggregateFunctionSchema } from '../../../schema/function.js';
33
+ const log = createLogger('optimizer:rule:groupby-fd-simplification');
34
+ export function ruleGroupByFdSimplification(node, context) {
35
+ if (!(node instanceof AggregateNode))
36
+ return null;
37
+ if (node.groupBy.length <= 1)
38
+ return null;
39
+ const aggAttrs = node.getAttributes();
40
+ // Build the set of candidate output indices: bare-column GROUP BYs only.
41
+ // Map outIdx → original ColumnReferenceNode so we can wire pickers later.
42
+ const candidateExprs = new Map();
43
+ for (let i = 0; i < node.groupBy.length; i++) {
44
+ const gb = node.groupBy[i];
45
+ if (gb instanceof ColumnReferenceNode) {
46
+ candidateExprs.set(i, gb);
47
+ }
48
+ }
49
+ if (candidateExprs.size <= 1)
50
+ return null;
51
+ const candidateSet = new Set(candidateExprs.keys());
52
+ const sourceFds = node.physical.fds ?? [];
53
+ const ecs = node.physical.equivClasses ?? [];
54
+ const combinedFds = expandEcsToFds(ecs, sourceFds);
55
+ const cover = minimalCover(candidateSet, combinedFds);
56
+ if (cover.size === candidateSet.size)
57
+ return null;
58
+ const dropped = new Set();
59
+ for (const idx of candidateSet) {
60
+ if (!cover.has(idx))
61
+ dropped.add(idx);
62
+ }
63
+ if (dropped.size === 0)
64
+ return null;
65
+ // Build new groupBy: keep non-candidates (expressions) AND kept candidates,
66
+ // preserving original relative order. Track the new output index each old
67
+ // index maps to so we can rebuild preserveAttributeIds correctly.
68
+ const keptGroupBy = [];
69
+ const keptGroupByOldIdx = [];
70
+ const droppedOldIdx = [];
71
+ for (let i = 0; i < node.groupBy.length; i++) {
72
+ if (candidateSet.has(i) && !cover.has(i)) {
73
+ droppedOldIdx.push(i);
74
+ }
75
+ else {
76
+ keptGroupBy.push(node.groupBy[i]);
77
+ keptGroupByOldIdx.push(i);
78
+ }
79
+ }
80
+ // Synthesize picker MIN aggregates for each dropped column, in original order.
81
+ const minSchema = context.db._findFunction('min', 1);
82
+ if (!minSchema || !isAggregateFunctionSchema(minSchema)) {
83
+ log('min/1 not registered as aggregate; skipping');
84
+ return null;
85
+ }
86
+ const pickerAggregates = [];
87
+ for (const oldIdx of droppedOldIdx) {
88
+ const colRef = candidateExprs.get(oldIdx);
89
+ const origAttr = aggAttrs[oldIdx];
90
+ const minExpr = {
91
+ type: 'function',
92
+ name: 'min',
93
+ args: [colRef.expression],
94
+ distinct: false,
95
+ };
96
+ const inferredType = minSchema.inferReturnType
97
+ ? minSchema.inferReturnType([colRef.getType().logicalType])
98
+ : undefined;
99
+ const pickerCall = new AggregateFunctionCallNode(node.scope, minExpr, 'min', minSchema, [colRef], false, undefined, undefined, inferredType);
100
+ pickerAggregates.push({ expression: pickerCall, alias: origAttr.name });
101
+ }
102
+ // Rebuild preserveAttributeIds in the new physical order:
103
+ // [kept-gb attrs..., dropped-gb attrs (as picker outputs)..., orig-agg attrs...]
104
+ const groupByCount = node.groupBy.length;
105
+ const newAttrs = [];
106
+ for (const oldIdx of keptGroupByOldIdx)
107
+ newAttrs.push(aggAttrs[oldIdx]);
108
+ for (const oldIdx of droppedOldIdx)
109
+ newAttrs.push(aggAttrs[oldIdx]);
110
+ for (let i = groupByCount; i < aggAttrs.length; i++)
111
+ newAttrs.push(aggAttrs[i]);
112
+ const newAggregates = [...pickerAggregates, ...node.aggregates];
113
+ log('Dropped %d/%d GROUP BY column(s); picker aggregates: %d', dropped.size, candidateSet.size, pickerAggregates.length);
114
+ return new AggregateNode(node.scope, node.source, keptGroupBy, newAggregates, undefined, newAttrs);
115
+ }
116
+ //# sourceMappingURL=rule-groupby-fd-simplification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-groupby-fd-simplification.js","sourceRoot":"","sources":["../../../../../src/planner/rules/aggregate/rule-groupby-fd-simplification.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,aAAa,EAA4B,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAGxE,MAAM,GAAG,GAAG,YAAY,CAAC,0CAA0C,CAAC,CAAC;AAErE,MAAM,UAAU,2BAA2B,CAAC,IAAc,EAAE,OAAmB;IAC9E,IAAI,CAAC,CAAC,IAAI,YAAY,aAAa,CAAC;QAAE,OAAO,IAAI,CAAC;IAClD,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAE1C,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;IAEtC,yEAAyE;IACzE,0EAA0E;IAC1E,MAAM,cAAc,GAAG,IAAI,GAAG,EAA+B,C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rule: DISTINCT Elimination
5
5
  *
6
- * When a DistinctNode's source already guarantees unique rows (via logical keys
7
- * from RelationType or physical uniqueKeys), the DISTINCT is redundant and can
8
- * be removed.
6
+ * When a DistinctNode's source already guarantees unique rows, the DISTINCT is
7
+ * redundant and can be removed.
9
8
  *
10
- * Checks both:
11
- * 1. Physical uniqueKeys (from computePhysical, available after physical pass)
12
- * 2. Logical keys (from RelationType.keys, available at any time)
9
+ * Sources of uniqueness proof:
10
+ * 1. Logical keys (`RelationType.keys`) — schema-declared, available at any time.
11
+ * 2. Physical FD set — encodes derived keys as `K all_other_cols` FDs, plus
12
+ * the singleton `∅ → all_cols` for at-most-one-row claims.
13
13
  *
14
- * A key that is present in the source proves it already produces unique rows —
14
+ * A non-empty key proof on the source proves it already produces unique rows —
15
15
  * DISTINCT is a no-op.
16
16
  */
17
17
  export declare function ruleDistinctElimination(node: PlanNode, _context: OptContext): PlanNode | null;
@@ -1 +1 @@
1
- {"version":3,"file":"rule-distinct-elimination.d.ts","sourceRoot":"","sources":["../../../../../src/planner/rules/distinct/rule-distinct-elimination.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAK7D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,GAAG,QAAQ,GAAG,IAAI,CAoB7F"}
1
+ {"version":3,"file":"rule-distinct-elimination.d.ts","sourceRoot":"","sources":["../../../../../src/planner/rules/distinct/rule-distinct-elimination.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAM7D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,GAAG,QAAQ,GAAG,IAAI,CAqB7F"}
@@ -1,37 +1,39 @@
1
1
  import { createLogger } from '../../../common/logger.js';
2
2
  import { DistinctNode } from '../../nodes/distinct-node.js';
3
+ import { hasAnyKey, hasSingletonFd } from '../../util/fd-utils.js';
3
4
  const log = createLogger('optimizer:rule:distinct-elimination');
4
5
  /**
5
6
  * Rule: DISTINCT Elimination
6
7
  *
7
- * When a DistinctNode's source already guarantees unique rows (via logical keys
8
- * from RelationType or physical uniqueKeys), the DISTINCT is redundant and can
9
- * be removed.
8
+ * When a DistinctNode's source already guarantees unique rows, the DISTINCT is
9
+ * redundant and can be removed.
10
10
  *
11
- * Checks both:
12
- * 1. Physical uniqueKeys (from computePhysical, available after physical pass)
13
- * 2. Logical keys (from RelationType.keys, available at any time)
11
+ * Sources of uniqueness proof:
12
+ * 1. Logical keys (`RelationType.keys`) — schema-declared, available at any time.
13
+ * 2. Physical FD set — encodes derived keys as `K all_other_cols` FDs, plus
14
+ * the singleton `∅ → all_cols` for at-most-one-row claims.
14
15
  *
15
- * A key that is present in the source proves it already produces unique rows —
16
+ * A non-empty key proof on the source proves it already produces unique rows —
16
17
  * DISTINCT is a no-op.
17
18
  */
18
19
  export function ruleDistinctElimination(node, _context) {
19
20
  if (!(node instanceof DistinctNode))
20
21
  return null;
21
- // Check physical uniqueKeys (available if physical pass has run or compute is triggered)
22
- const sourcePhys = node.source.physical;
23
- if (sourcePhys?.uniqueKeys && sourcePhys.uniqueKeys.length > 0) {
24
- log('Eliminating redundant DISTINCT: source has physical uniqueKeys %j', sourcePhys.uniqueKeys);
25
- return node.source;
26
- }
27
- // Check logical keys from RelationType
28
- // If the source's logical type declares any key, the source already produces
29
- // unique rows (since any superset of a key is also unique).
22
+ // Logical keys (RelationType.keys) are the schema-level claim.
30
23
  const sourceType = node.source.getType();
31
24
  if (sourceType.keys && sourceType.keys.length > 0) {
32
25
  log('Eliminating redundant DISTINCT: source has logical keys %j', sourceType.keys);
33
26
  return node.source;
34
27
  }
28
+ // Physical FDs: an FD whose determinants form a non-trivial superkey of the
29
+ // source columns proves uniqueness; the singleton `∅ → all_cols` proves
30
+ // at-most-one-row (also unique).
31
+ const sourcePhys = node.source.physical;
32
+ const colCount = node.source.getAttributes().length;
33
+ if (hasAnyKey(sourcePhys?.fds, colCount) || hasSingletonFd(sourcePhys?.fds, colCount)) {
34
+ log('Eliminating redundant DISTINCT: source FDs imply unique rows');
35
+ return node.source;
36
+ }
35
37
  return null;
36
38
  }
37
39
  //# sourceMappingURL=rule-distinct-elimination.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rule-distinct-elimination.js","sourceRoot":"","sources":["../../../../../src/planner/rules/distinct/rule-distinct-elimination.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,MAAM,GAAG,GAAG,YAAY,CAAC,qCAAqC,CAAC,CAAC;AAEhE;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAc,EAAE,QAAoB;IAC3E,IAAI,CAAC,CAAC,IAAI,YAAY,YAAY,CAAC;QAAE,OAAO,IAAI,CAAC;IAEjD,yFAAyF;IACzF,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;IACxC,IAAI,UAAU,EAAE,UAAU,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChE,GAAG,CAAC,mEAAmE,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;QAChG,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,uCAAuC;IACvC,6EAA6E;IAC7E,4DAA4D;IAC5D,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IACzC,IAAI,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnD,GAAG,CAAC,4DAA4D,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;QACnF,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC"}
1
+ {"version":3,"file":"rule-distinct-elimination.js","sourceRoot":"","sources":["../../../../../src/planner/rules/distinct/rule-distinct-elimination.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEnE,MAAM,GAAG,GAAG,YAAY,CAAC,qCAAqC,CAAC,CAAC;AAEhE;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAc,EAAE,QAAoB;IAC3E,IAAI,CAAC,CAAC,IAAI,YAAY,YAAY,CAAC;QAAE,OAAO,IAAI,CAAC;IAEjD,+DAA+D;IAC/D,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IACzC,IAAI,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnD,GAAG,CAAC,4DAA4D,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;QACnF,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,4EAA4E;IAC5E,wEAAwE;IACxE,iCAAiC;IACjC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;IACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,MAAM,CAAC;IACpD,IAAI,SAAS,CAAC,UAAU,EAAE,GAAG,EAAE,QAAQ,CAAC,IAAI,cAAc,CAAC,UAAU,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC;QACvF,GAAG,CAAC,8DAA8D,CAAC,CAAC;QACpE,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Rule: Join Elimination (FK→PK)
3
+ *
4
+ * Eliminates a join whose non-preserved side is never referenced above the join
5
+ * and is guaranteed at-most-one-matching per FK→PK alignment.
6
+ *
7
+ * The rule fires on ProjectNode and walks down through a whitelist of
8
+ * pass-through nodes (Filter, Sort, LimitOffset, Distinct, Alias) collecting
9
+ * the set of attribute IDs that any caller above the join still demands. When
10
+ * the walk reaches a JoinNode, the demanded set is final for that chain:
11
+ *
12
+ * - If the demanded set only references the preserved side and the equi-join
13
+ * condition aligns FK columns on the preserved side with the PK on the
14
+ * other side, the join is rewritten away.
15
+ * - For LEFT/RIGHT outer joins, only the non-preserved side may be eliminated
16
+ * (the preserved side is required by SQL semantics).
17
+ * - For INNER joins, either side may be eliminated, but additionally the FK
18
+ * columns must be NOT NULL — otherwise NULL FK rows that wouldn't have
19
+ * matched on the join would now survive.
20
+ *
21
+ * Non-equi residual conjuncts in the ON-clause disqualify the rewrite (they
22
+ * may alter cardinality beyond the FK→PK guarantee).
23
+ */
24
+ import type { PlanNode, ScalarPlanNode } from '../../nodes/plan-node.js';
25
+ import type { OptContext } from '../../framework/context.js';
26
+ export declare function ruleJoinElimination(node: PlanNode, _context: OptContext): PlanNode | null;
27
+ /**
28
+ * AND-of-equalities check: every conjunct must be `colRef = colRef`. Any other
29
+ * predicate shape (range comparison, non-equality, OR, function calls, …)
30
+ * disqualifies the rewrite — those residuals can change row counts beyond what
31
+ * the FK→PK guarantee covers.
32
+ */
33
+ export declare function isAndOfColumnEqualities(expr: ScalarPlanNode): boolean;
34
+ /**
35
+ * Aggregate counterpart of `ruleJoinElimination`: when an Aggregate sits over
36
+ * a chain ending in an FK-covered inner join and the aggregate's payload only
37
+ * depends on the FK (left) side, drop the join.
38
+ *
39
+ * Why correct for `count(*)` and similar cardinality-only aggregates: a
40
+ * non-null FK with the IND `L.fk ⊆ R.pk` and an unfiltered R guarantees
41
+ * `|L ⋈ R| == |L|`, so `count(*)` over the join equals `count(*)` over L.
42
+ * More generally, when no aggregate argument or group key references R, the
43
+ * inner join's only effect is to gate L by `fk IS NOT NULL`, which the
44
+ * NOT-NULL precondition already rules out.
45
+ *
46
+ * Implementation mirrors the Project entrypoint: collect attribute IDs the
47
+ * Aggregate demands (group-key expressions + every aggregate expression),
48
+ * walk the wrapper chain to find the Join, run the same FK-PK alignment +
49
+ * row-preserving checks as the inner-join case, then rebuild the chain on
50
+ * the preserved side.
51
+ *
52
+ * Only `inner` joins are eligible here — outer joins reduce to inner in this
53
+ * context only when both sides demand attrs, which we'd have rejected already.
54
+ */
55
+ export declare function ruleJoinEliminationUnderAggregate(node: PlanNode, _context: OptContext): PlanNode | null;
56
+ //# sourceMappingURL=rule-join-elimination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-join-elimination.d.ts","sourceRoot":"","sources":["../../../../../src/planner/rules/join/rule-join-elimination.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAsB,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE7F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AA6B7D,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,GAAG,QAAQ,GAAG,IAAI,CAuDzF;AA+DD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAgBrE;AA8ED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,GAAG,QAAQ,GAAG,IAAI,CAwDvG"}
@@ -0,0 +1,326 @@
1
+ /**
2
+ * Rule: Join Elimination (FK→PK)
3
+ *
4
+ * Eliminates a join whose non-preserved side is never referenced above the join
5
+ * and is guaranteed at-most-one-matching per FK→PK alignment.
6
+ *
7
+ * The rule fires on ProjectNode and walks down through a whitelist of
8
+ * pass-through nodes (Filter, Sort, LimitOffset, Distinct, Alias) collecting
9
+ * the set of attribute IDs that any caller above the join still demands. When
10
+ * the walk reaches a JoinNode, the demanded set is final for that chain:
11
+ *
12
+ * - If the demanded set only references the preserved side and the equi-join
13
+ * condition aligns FK columns on the preserved side with the PK on the
14
+ * other side, the join is rewritten away.
15
+ * - For LEFT/RIGHT outer joins, only the non-preserved side may be eliminated
16
+ * (the preserved side is required by SQL semantics).
17
+ * - For INNER joins, either side may be eliminated, but additionally the FK
18
+ * columns must be NOT NULL — otherwise NULL FK rows that wouldn't have
19
+ * matched on the join would now survive.
20
+ *
21
+ * Non-equi residual conjuncts in the ON-clause disqualify the rewrite (they
22
+ * may alter cardinality beyond the FK→PK guarantee).
23
+ */
24
+ import { createLogger } from '../../../common/logger.js';
25
+ import { isRelationalNode } from '../../nodes/plan-node.js';
26
+ import { ProjectNode } from '../../nodes/project-node.js';
27
+ import { FilterNode } from '../../nodes/filter.js';
28
+ import { SortNode } from '../../nodes/sort.js';
29
+ import { LimitOffsetNode } from '../../nodes/limit-offset.js';
30
+ import { DistinctNode } from '../../nodes/distinct-node.js';
31
+ import { AliasNode } from '../../nodes/alias-node.js';
32
+ import { AggregateNode } from '../../nodes/aggregate-node.js';
33
+ import { JoinNode, extractEquiPairsFromCondition } from '../../nodes/join-node.js';
34
+ import { ColumnReferenceNode } from '../../nodes/reference.js';
35
+ import { BinaryOpNode } from '../../nodes/scalar.js';
36
+ import { normalizePredicate } from '../../analysis/predicate-normalizer.js';
37
+ import { checkFkPkAlignment, extractTableSchema } from '../../util/key-utils.js';
38
+ import { lookupCoveringFK, isRowPreservingPathToTable } from '../../util/ind-utils.js';
39
+ const log = createLogger('optimizer:rule:join-elimination');
40
+ export function ruleJoinElimination(node, _context) {
41
+ if (!(node instanceof ProjectNode))
42
+ return null;
43
+ const demanded = new Set();
44
+ for (const proj of node.projections) {
45
+ collectAttrIds(proj.node, demanded);
46
+ }
47
+ const walk = walkChain(node.source, demanded);
48
+ if (!walk)
49
+ return null;
50
+ const { join, chain } = walk;
51
+ if (join.joinType !== 'left' && join.joinType !== 'right' && join.joinType !== 'inner')
52
+ return null;
53
+ if (!join.condition)
54
+ return null;
55
+ const leftAttrs = join.left.getAttributes();
56
+ const rightAttrs = join.right.getAttributes();
57
+ const pairs = extractEquiPairsFromCondition(join.condition, leftAttrs, rightAttrs);
58
+ if (pairs.length === 0)
59
+ return null;
60
+ const normalized = normalizePredicate(join.condition);
61
+ if (!isAndOfColumnEqualities(normalized))
62
+ return null;
63
+ const leftIds = new Set(leftAttrs.map(a => a.id));
64
+ const rightIds = new Set(rightAttrs.map(a => a.id));
65
+ const usesLeft = setsIntersect(demanded, leftIds);
66
+ const usesRight = setsIntersect(demanded, rightIds);
67
+ let preserved = null;
68
+ switch (join.joinType) {
69
+ case 'left':
70
+ if (usesRight)
71
+ return null;
72
+ preserved = tryEliminate(join, 'right', pairs);
73
+ break;
74
+ case 'right':
75
+ if (usesLeft)
76
+ return null;
77
+ preserved = tryEliminate(join, 'left', pairs);
78
+ break;
79
+ case 'inner':
80
+ if (!usesRight) {
81
+ preserved = tryEliminate(join, 'right', pairs);
82
+ }
83
+ if (!preserved && !usesLeft) {
84
+ preserved = tryEliminate(join, 'left', pairs);
85
+ }
86
+ break;
87
+ }
88
+ if (!preserved)
89
+ return null;
90
+ log('Eliminating %s join under Project; preserved side has %d attrs', join.joinType, preserved.getAttributes().length);
91
+ const newSource = rebuildChain(chain, preserved);
92
+ return rebuildProject(node, newSource);
93
+ }
94
+ function collectAttrIds(expr, out) {
95
+ if (expr instanceof ColumnReferenceNode) {
96
+ out.add(expr.attributeId);
97
+ return;
98
+ }
99
+ for (const child of expr.getChildren()) {
100
+ collectAttrIds(child, out);
101
+ }
102
+ }
103
+ function walkChain(root, demanded) {
104
+ const chain = [];
105
+ let current = root;
106
+ while (true) {
107
+ if (current instanceof JoinNode) {
108
+ return { join: current, chain };
109
+ }
110
+ if (current instanceof FilterNode) {
111
+ collectAttrIds(current.predicate, demanded);
112
+ chain.push({ kind: 'filter', node: current });
113
+ current = current.source;
114
+ continue;
115
+ }
116
+ if (current instanceof SortNode) {
117
+ for (const k of current.sortKeys) {
118
+ collectAttrIds(k.expression, demanded);
119
+ }
120
+ chain.push({ kind: 'sort', node: current });
121
+ current = current.source;
122
+ continue;
123
+ }
124
+ if (current instanceof LimitOffsetNode) {
125
+ chain.push({ kind: 'limit', node: current });
126
+ current = current.source;
127
+ continue;
128
+ }
129
+ if (current instanceof DistinctNode) {
130
+ // DISTINCT collapses duplicates that the join (with at-most-one matching)
131
+ // would never have produced anyway; safe to walk through.
132
+ chain.push({ kind: 'distinct', node: current });
133
+ current = current.source;
134
+ continue;
135
+ }
136
+ if (current instanceof AliasNode) {
137
+ chain.push({ kind: 'alias', node: current });
138
+ current = current.source;
139
+ continue;
140
+ }
141
+ return null;
142
+ }
143
+ }
144
+ function setsIntersect(a, b) {
145
+ const [small, large] = a.size <= b.size ? [a, b] : [b, a];
146
+ for (const v of small) {
147
+ if (large.has(v))
148
+ return true;
149
+ }
150
+ return false;
151
+ }
152
+ /**
153
+ * AND-of-equalities check: every conjunct must be `colRef = colRef`. Any other
154
+ * predicate shape (range comparison, non-equality, OR, function calls, …)
155
+ * disqualifies the rewrite — those residuals can change row counts beyond what
156
+ * the FK→PK guarantee covers.
157
+ */
158
+ export function isAndOfColumnEqualities(expr) {
159
+ if (!(expr instanceof BinaryOpNode))
160
+ return false;
161
+ const stack = [expr];
162
+ while (stack.length > 0) {
163
+ const n = stack.pop();
164
+ if (!(n instanceof BinaryOpNode))
165
+ return false;
166
+ const op = n.expression.operator;
167
+ if (op === 'AND') {
168
+ stack.push(n.left, n.right);
169
+ continue;
170
+ }
171
+ if (op !== '=')
172
+ return false;
173
+ if (!(n.left instanceof ColumnReferenceNode))
174
+ return false;
175
+ if (!(n.right instanceof ColumnReferenceNode))
176
+ return false;
177
+ }
178
+ return true;
179
+ }
180
+ /**
181
+ * Validate FK→PK alignment for eliminating `sideToRemove` and return the
182
+ * preserved side relational node when safe.
183
+ */
184
+ function tryEliminate(join, sideToRemove, pairs) {
185
+ const leftSchema = extractTableSchema(join.left);
186
+ const rightSchema = extractTableSchema(join.right);
187
+ if (!leftSchema || !rightSchema)
188
+ return null;
189
+ // FK side is the preserved side; PK side is the side being removed.
190
+ const fkSchema = sideToRemove === 'right' ? leftSchema : rightSchema;
191
+ const pkSchema = sideToRemove === 'right' ? rightSchema : leftSchema;
192
+ const fkEquiCols = pairs.map(p => sideToRemove === 'right' ? p.left : p.right);
193
+ const pkEquiCols = pairs.map(p => sideToRemove === 'right' ? p.right : p.left);
194
+ if (!checkFkPkAlignment(fkSchema, pkSchema, fkEquiCols, pkEquiCols))
195
+ return null;
196
+ // INNER joins additionally require:
197
+ // 1. NOT NULL on every FK column — with nullable FK, rows with NULL FKs
198
+ // wouldn't survive the inner join but would survive elimination.
199
+ // 2. The eliminable side must produce the underlying PK table's full row
200
+ // set — any row-reducing wrapper (Filter, LimitOffset, Distinct,
201
+ // RetrieveNode with a non-trivial pipeline) between the join and the
202
+ // base table would have dropped rows that the FK→PK guarantee assumes
203
+ // are present, so eliminating would silently survive orphaned FK rows.
204
+ if (join.joinType === 'inner') {
205
+ const match = lookupCoveringFK(fkSchema, pkSchema, fkEquiCols, pkEquiCols);
206
+ if (!match)
207
+ return null;
208
+ if (match.nullable)
209
+ return null;
210
+ const eliminableSide = sideToRemove === 'right' ? join.right : join.left;
211
+ if (!isRowPreservingPathToTable(eliminableSide))
212
+ return null;
213
+ }
214
+ return (sideToRemove === 'right' ? join.left : join.right);
215
+ }
216
+ function rebuildChain(chain, bottom) {
217
+ let current = bottom;
218
+ // Chain was collected top→bottom (root pushed first); rebuild bottom→top.
219
+ for (let i = chain.length - 1; i >= 0; i--) {
220
+ const entry = chain[i];
221
+ switch (entry.kind) {
222
+ case 'filter': {
223
+ current = new FilterNode(entry.node.scope, current, entry.node.predicate);
224
+ break;
225
+ }
226
+ case 'sort': {
227
+ current = new SortNode(entry.node.scope, current, entry.node.sortKeys);
228
+ break;
229
+ }
230
+ case 'limit': {
231
+ current = new LimitOffsetNode(entry.node.scope, current, entry.node.limit, entry.node.offset);
232
+ break;
233
+ }
234
+ case 'distinct': {
235
+ current = new DistinctNode(entry.node.scope, current);
236
+ break;
237
+ }
238
+ case 'alias': {
239
+ current = new AliasNode(entry.node.scope, current, entry.node.alias);
240
+ break;
241
+ }
242
+ }
243
+ }
244
+ return current;
245
+ }
246
+ /**
247
+ * Aggregate counterpart of `ruleJoinElimination`: when an Aggregate sits over
248
+ * a chain ending in an FK-covered inner join and the aggregate's payload only
249
+ * depends on the FK (left) side, drop the join.
250
+ *
251
+ * Why correct for `count(*)` and similar cardinality-only aggregates: a
252
+ * non-null FK with the IND `L.fk ⊆ R.pk` and an unfiltered R guarantees
253
+ * `|L ⋈ R| == |L|`, so `count(*)` over the join equals `count(*)` over L.
254
+ * More generally, when no aggregate argument or group key references R, the
255
+ * inner join's only effect is to gate L by `fk IS NOT NULL`, which the
256
+ * NOT-NULL precondition already rules out.
257
+ *
258
+ * Implementation mirrors the Project entrypoint: collect attribute IDs the
259
+ * Aggregate demands (group-key expressions + every aggregate expression),
260
+ * walk the wrapper chain to find the Join, run the same FK-PK alignment +
261
+ * row-preserving checks as the inner-join case, then rebuild the chain on
262
+ * the preserved side.
263
+ *
264
+ * Only `inner` joins are eligible here — outer joins reduce to inner in this
265
+ * context only when both sides demand attrs, which we'd have rejected already.
266
+ */
267
+ export function ruleJoinEliminationUnderAggregate(node, _context) {
268
+ if (!(node instanceof AggregateNode))
269
+ return null;
270
+ const demanded = new Set();
271
+ for (const groupExpr of node.groupBy) {
272
+ collectAttrIds(groupExpr, demanded);
273
+ }
274
+ for (const agg of node.aggregates) {
275
+ collectAttrIds(agg.expression, demanded);
276
+ }
277
+ const walk = walkChain(node.source, demanded);
278
+ if (!walk)
279
+ return null;
280
+ const { join, chain } = walk;
281
+ // Only inner-eliminable shapes — see `ruleJoinElimination` notes.
282
+ if (join.joinType !== 'inner')
283
+ return null;
284
+ if (!join.condition)
285
+ return null;
286
+ const leftAttrs = join.left.getAttributes();
287
+ const rightAttrs = join.right.getAttributes();
288
+ const pairs = extractEquiPairsFromCondition(join.condition, leftAttrs, rightAttrs);
289
+ if (pairs.length === 0)
290
+ return null;
291
+ const normalized = normalizePredicate(join.condition);
292
+ if (!isAndOfColumnEqualities(normalized))
293
+ return null;
294
+ const leftIds = new Set(leftAttrs.map(a => a.id));
295
+ const rightIds = new Set(rightAttrs.map(a => a.id));
296
+ const usesLeft = setsIntersect(demanded, leftIds);
297
+ const usesRight = setsIntersect(demanded, rightIds);
298
+ let preserved = null;
299
+ if (!usesRight) {
300
+ preserved = tryEliminate(join, 'right', pairs);
301
+ }
302
+ if (!preserved && !usesLeft) {
303
+ preserved = tryEliminate(join, 'left', pairs);
304
+ }
305
+ if (!preserved)
306
+ return null;
307
+ log('Eliminating inner join under Aggregate; preserved side has %d attrs', preserved.getAttributes().length);
308
+ const newSource = rebuildChain(chain, preserved);
309
+ if (!isRelationalNode(newSource)) {
310
+ throw new Error('rule-join-elimination-aggregate: rebuilt source must be relational');
311
+ }
312
+ return new AggregateNode(node.scope, newSource, node.groupBy, node.aggregates, undefined, node.getAttributes());
313
+ }
314
+ function rebuildProject(project, newSource) {
315
+ const attributes = project.getAttributes();
316
+ const newProjections = project.projections.map((p, i) => ({
317
+ node: p.node,
318
+ alias: p.alias,
319
+ attributeId: attributes[i].id,
320
+ }));
321
+ if (!isRelationalNode(newSource)) {
322
+ throw new Error('rule-join-elimination: rebuilt source must be relational');
323
+ }
324
+ return new ProjectNode(project.scope, newSource, newProjections, undefined, attributes, project.preserveInputColumns);
325
+ }
326
+ //# sourceMappingURL=rule-join-elimination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-join-elimination.js","sourceRoot":"","sources":["../../../../../src/planner/rules/join/rule-join-elimination.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAEvF,MAAM,GAAG,GAAG,YAAY,CAAC,iCAAiC,CAAC,CAAC;AAc5D,MAAM,UAAU,mBAAmB,CAAC,IAAc,EAAE,QAAoB;IACvE,IAAI,CAAC,CAAC,IAAI,YAAY,WAAW,CAAC;QAAE,OAAO,IAAI,CAAC;IAEhD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IACnC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C,CAAC,CAAC,CAAC,EAAE;KAC7B,CAAC,CAAC,CAAC;IACJ,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,IAAI,WAAW,CACrB,OAAO,CAAC,KAAK,EACb,SAAS,EACT,cAAc,EACd,SAAS,EACT,UAAU,EACV,OAAO,CAAC,oBAAoB,CAC5B,CAAC;AACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"rule-join-greedy-commute.d.ts","sourceRoot":"","sources":["../../../../../src/planner/rules/join/rule-join-greedy-commute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAsB,MAAM,0BAA0B,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAK7D;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,GAAG,QAAQ,GAAG,IAAI,CA4B3F"}
1
+ {"version":3,"file":"rule-join-greedy-commute.d.ts","sourceRoot":"","sources":["../../../../../src/planner/rules/join/rule-join-greedy-commute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAsB,MAAM,0BAA0B,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAa7D;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,GAAG,QAAQ,GAAG,IAAI,CA4B3F"}