@quereus/quereus 0.6.12 → 0.7.1
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/dist/src/parser/lexer.d.ts +6 -0
- package/dist/src/parser/lexer.d.ts.map +1 -1
- package/dist/src/parser/lexer.js +33 -1
- package/dist/src/parser/lexer.js.map +1 -1
- package/dist/src/parser/parser.d.ts.map +1 -1
- package/dist/src/parser/parser.js +28 -24
- package/dist/src/parser/parser.js.map +1 -1
- package/dist/src/planner/building/select-aggregates.d.ts +6 -1
- package/dist/src/planner/building/select-aggregates.d.ts.map +1 -1
- package/dist/src/planner/building/select-aggregates.js +23 -4
- package/dist/src/planner/building/select-aggregates.js.map +1 -1
- package/dist/src/planner/building/select-modifiers.js +7 -2
- package/dist/src/planner/building/select-modifiers.js.map +1 -1
- package/dist/src/planner/building/select.d.ts.map +1 -1
- package/dist/src/planner/building/select.js +2 -2
- package/dist/src/planner/building/select.js.map +1 -1
- package/dist/src/planner/building/update.d.ts.map +1 -1
- package/dist/src/planner/building/update.js +8 -4
- package/dist/src/planner/building/update.js.map +1 -1
- package/dist/src/planner/nodes/join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/join-node.js +6 -1
- package/dist/src/planner/nodes/join-node.js.map +1 -1
- package/dist/src/planner/rules/access/rule-select-access-path.js +15 -2
- package/dist/src/planner/rules/access/rule-select-access-path.js.map +1 -1
- package/dist/src/schema/manager.d.ts +30 -0
- package/dist/src/schema/manager.d.ts.map +1 -1
- package/dist/src/schema/manager.js +205 -0
- package/dist/src/schema/manager.js.map +1 -1
- package/dist/src/vtab/best-access-plan.d.ts +2 -0
- package/dist/src/vtab/best-access-plan.d.ts.map +1 -1
- package/dist/src/vtab/best-access-plan.js.map +1 -1
- package/dist/src/vtab/memory/layer/scan-plan.js +2 -2
- package/dist/src/vtab/memory/layer/scan-plan.js.map +1 -1
- package/dist/src/vtab/memory/module.d.ts +1 -1
- package/dist/src/vtab/memory/module.d.ts.map +1 -1
- package/dist/src/vtab/memory/module.js +2 -1
- package/dist/src/vtab/memory/module.js.map +1 -1
- package/dist/src/vtab/module.d.ts +2 -1
- package/dist/src/vtab/module.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/parser/lexer.ts +806 -771
- package/src/parser/parser.ts +3352 -3347
- package/src/planner/building/select-aggregates.ts +30 -5
- package/src/planner/building/select-modifiers.ts +8 -2
- package/src/planner/building/select.ts +567 -560
- package/src/planner/building/update.ts +9 -5
- package/src/planner/nodes/join-node.ts +6 -1
- package/src/planner/rules/access/rule-select-access-path.ts +399 -384
- package/src/schema/manager.ts +235 -1
- package/src/vtab/best-access-plan.ts +2 -0
- package/src/vtab/memory/layer/scan-plan.ts +2 -2
- package/src/vtab/memory/module.ts +2 -1
- package/src/vtab/module.ts +162 -160
|
@@ -28,6 +28,8 @@ export function buildAggregatePhase(
|
|
|
28
28
|
aggregateScope?: RegisteredScope;
|
|
29
29
|
needsFinalProjection: boolean;
|
|
30
30
|
preAggregateSort: boolean;
|
|
31
|
+
aggregateNode?: RelationalPlanNode;
|
|
32
|
+
groupByExpressions?: ScalarPlanNode[];
|
|
31
33
|
} {
|
|
32
34
|
const hasGroupBy = stmt.groupBy && stmt.groupBy.length > 0;
|
|
33
35
|
|
|
@@ -69,8 +71,9 @@ export function buildAggregatePhase(
|
|
|
69
71
|
const groupByExpressions = stmt.groupBy ?
|
|
70
72
|
stmt.groupBy.map(expr => buildExpression(selectContext, expr, false)) : [];
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
// Create AggregateNode
|
|
75
|
+
const aggregateNode = new AggregateNode(selectContext.scope, currentInput, groupByExpressions, aggregates);
|
|
76
|
+
currentInput = aggregateNode;
|
|
74
77
|
|
|
75
78
|
// Create aggregate output scope
|
|
76
79
|
const aggregateOutputScope = createAggregateOutputScope(
|
|
@@ -93,7 +96,9 @@ export function buildAggregatePhase(
|
|
|
93
96
|
output: currentInput,
|
|
94
97
|
aggregateScope: aggregateOutputScope,
|
|
95
98
|
needsFinalProjection,
|
|
96
|
-
preAggregateSort
|
|
99
|
+
preAggregateSort,
|
|
100
|
+
aggregateNode,
|
|
101
|
+
groupByExpressions
|
|
97
102
|
};
|
|
98
103
|
}
|
|
99
104
|
|
|
@@ -266,14 +271,34 @@ function checkNeedsFinalProjection(projections: Projection[]): boolean {
|
|
|
266
271
|
export function buildFinalAggregateProjections(
|
|
267
272
|
stmt: AST.SelectStmt,
|
|
268
273
|
selectContext: PlanningContext,
|
|
269
|
-
aggregateOutputScope: RegisteredScope
|
|
274
|
+
aggregateOutputScope: RegisteredScope,
|
|
275
|
+
aggregateNode: RelationalPlanNode,
|
|
276
|
+
aggregates: { expression: ScalarPlanNode; alias: string }[],
|
|
277
|
+
groupByExpressions: ScalarPlanNode[]
|
|
270
278
|
): Projection[] {
|
|
271
279
|
const finalProjections: Projection[] = [];
|
|
280
|
+
const aggregateAttributes = aggregateNode.getAttributes();
|
|
281
|
+
|
|
282
|
+
// Build context with aggregates so buildFunctionCall can resolve aggregate references
|
|
283
|
+
const aggregatesContext = aggregates.map((agg, index) => {
|
|
284
|
+
const columnIndex = groupByExpressions.length + index;
|
|
285
|
+
const attr = aggregateAttributes[columnIndex];
|
|
286
|
+
return {
|
|
287
|
+
expression: agg.expression,
|
|
288
|
+
alias: agg.alias,
|
|
289
|
+
columnIndex,
|
|
290
|
+
attributeId: attr.id
|
|
291
|
+
};
|
|
292
|
+
});
|
|
272
293
|
|
|
273
294
|
for (const column of stmt.columns) {
|
|
274
295
|
if (column.type === 'column') {
|
|
275
296
|
// Re-build the expression in the context of the aggregate output
|
|
276
|
-
const finalContext: PlanningContext = {
|
|
297
|
+
const finalContext: PlanningContext = {
|
|
298
|
+
...selectContext,
|
|
299
|
+
scope: aggregateOutputScope,
|
|
300
|
+
aggregates: aggregatesContext
|
|
301
|
+
};
|
|
277
302
|
const scalarNode = buildExpression(finalContext, column.expr, true);
|
|
278
303
|
|
|
279
304
|
let attrId: number | undefined = undefined;
|
|
@@ -220,8 +220,14 @@ function isIdentityProjection(projections: Projection[], source: RelationalPlanN
|
|
|
220
220
|
return false;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
//
|
|
224
|
-
|
|
223
|
+
// Determine the effective output column name:
|
|
224
|
+
// - If there's an explicit alias, use it
|
|
225
|
+
// - Otherwise, use the column reference's name (from the SELECT expression)
|
|
226
|
+
const effectiveOutputName = proj.alias || colRef.expression.name;
|
|
227
|
+
|
|
228
|
+
// The effective output name must match the source attribute name
|
|
229
|
+
// If they differ, we need a ProjectNode to rename the column
|
|
230
|
+
if (effectiveOutputName.toLowerCase() !== sourceAttr.name.toLowerCase()) {
|
|
225
231
|
return false;
|
|
226
232
|
}
|
|
227
233
|
}
|