@docstack/client 0.0.3 → 0.0.5
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/lib/core/attribute.js +406 -0
- package/lib/core/attribute.js.map +1 -0
- package/lib/core/class.d.ts +13 -14
- package/lib/core/class.js +761 -0
- package/lib/core/class.js.map +1 -0
- package/lib/core/crypto-engine/index.js +229 -0
- package/lib/core/crypto-engine/index.js.map +1 -0
- package/lib/core/crypto-engine/utils.js +88 -0
- package/lib/core/crypto-engine/utils.js.map +1 -0
- package/lib/core/datamodel/index.js +1308 -0
- package/lib/core/datamodel/index.js.map +1 -0
- package/lib/core/domain.js +423 -0
- package/lib/core/domain.js.map +1 -0
- package/lib/core/index.js +520 -0
- package/lib/core/index.js.map +1 -0
- package/lib/core/job-engine/index.js +220 -0
- package/lib/core/job-engine/index.js.map +1 -0
- package/lib/core/policy-engine/index.js +232 -0
- package/lib/core/policy-engine/index.js.map +1 -0
- package/lib/core/query-engine/accumulators.js +258 -0
- package/lib/core/query-engine/accumulators.js.map +1 -0
- package/lib/core/query-engine/evaluator.js +179 -0
- package/lib/core/query-engine/evaluator.js.map +1 -0
- package/lib/core/query-engine/executor.js +405 -0
- package/lib/core/query-engine/executor.js.map +1 -0
- package/lib/core/query-engine/index.js +4 -0
- package/lib/core/query-engine/index.js.map +1 -0
- package/lib/core/query-engine/parser.js +515 -0
- package/lib/core/query-engine/parser.js.map +1 -0
- package/lib/core/query-engine/planner.js +330 -0
- package/lib/core/query-engine/planner.js.map +1 -0
- package/lib/core/stack.js +1817 -0
- package/lib/core/stack.js.map +1 -0
- package/lib/core/test-utils/docstack.js +222 -0
- package/lib/core/test-utils/docstack.js.map +1 -0
- package/lib/core/trigger/index.js +81 -0
- package/lib/core/trigger/index.js.map +1 -0
- package/lib/index.js +10 -4
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +10 -4
- package/lib/plugins/pouchdb.js +368 -0
- package/lib/plugins/pouchdb.js.map +1 -0
- package/lib/utils/crypto/index.js +34 -0
- package/lib/utils/crypto/index.js.map +1 -0
- package/lib/utils/index.js +58 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/logger/index.js +20 -0
- package/lib/utils/logger/index.js.map +1 -0
- package/lib/utils/logger/transport.js +28 -0
- package/lib/utils/logger/transport.js.map +1 -0
- package/lib/workers/dataModel.js +48 -0
- package/lib/workers/dataModel.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { evalExpression } from './evaluator';
|
|
3
|
+
/**
|
|
4
|
+
* Accumulator for the SUM() aggregate function.
|
|
5
|
+
*/
|
|
6
|
+
class Sum {
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} alias The result alias for this aggregate.
|
|
9
|
+
* @param {object} expr The expression to be summed.
|
|
10
|
+
* @param {string} fromAlias The alias of the FROM table.
|
|
11
|
+
* @param {object} joinAliases A map of join table aliases.
|
|
12
|
+
*/
|
|
13
|
+
constructor(alias, expr, fromAlias, joinAliases) {
|
|
14
|
+
this.alias = alias;
|
|
15
|
+
this.expr = expr;
|
|
16
|
+
this.fromAlias = fromAlias;
|
|
17
|
+
this.joinAliases = joinAliases;
|
|
18
|
+
this.sum = 0;
|
|
19
|
+
this.seen = false;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Adds a row's value to the sum.
|
|
23
|
+
* @param {object} row The row to process.
|
|
24
|
+
*/
|
|
25
|
+
async add(row) {
|
|
26
|
+
const val = await evalExpression(row, this.expr, this.fromAlias, this.joinAliases);
|
|
27
|
+
if (val != null && typeof val === 'number') {
|
|
28
|
+
this.sum += val;
|
|
29
|
+
this.seen = true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns the final sum.
|
|
34
|
+
* @returns {number|null} The total sum, or null if no values were added.
|
|
35
|
+
*/
|
|
36
|
+
result() { return this.seen ? this.sum : null; }
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Accumulator for the COUNT() aggregate function.
|
|
40
|
+
*/
|
|
41
|
+
class Count {
|
|
42
|
+
/**
|
|
43
|
+
* @param {string} alias The result alias for this aggregate.
|
|
44
|
+
* @param {object} expr The expression to be counted.
|
|
45
|
+
* @param {string} fromAlias The alias of the FROM table.
|
|
46
|
+
* @param {object} joinAliases A map of join table aliases.
|
|
47
|
+
*/
|
|
48
|
+
constructor(alias, expr, fromAlias, joinAliases) {
|
|
49
|
+
this.alias = alias;
|
|
50
|
+
this.expr = expr;
|
|
51
|
+
this.fromAlias = fromAlias;
|
|
52
|
+
this.joinAliases = joinAliases;
|
|
53
|
+
this.count = 0;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Increments the count for a row. For COUNT(column), it only counts non-null values.
|
|
57
|
+
* For COUNT(*), it counts all rows.
|
|
58
|
+
* @param {object} row The row to process.
|
|
59
|
+
*/
|
|
60
|
+
async add(row) {
|
|
61
|
+
if (this.expr.type === 'star') {
|
|
62
|
+
this.count++;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
const val = await evalExpression(row, this.expr, this.fromAlias, this.joinAliases);
|
|
66
|
+
if (val != null) {
|
|
67
|
+
this.count++;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Returns the final count.
|
|
73
|
+
* @returns {number} The total count.
|
|
74
|
+
*/
|
|
75
|
+
result() { return this.count; }
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Accumulator for the AVG() aggregate function.
|
|
79
|
+
*/
|
|
80
|
+
class Avg {
|
|
81
|
+
/**
|
|
82
|
+
* @param {string} alias The result alias for this aggregate.
|
|
83
|
+
* @param {object} expr The expression to be averaged.
|
|
84
|
+
* @param {string} fromAlias The alias of the FROM table.
|
|
85
|
+
* @param {object} joinAliases A map of join table aliases.
|
|
86
|
+
*/
|
|
87
|
+
constructor(alias, expr, fromAlias, joinAliases) {
|
|
88
|
+
this.alias = alias;
|
|
89
|
+
this.expr = expr;
|
|
90
|
+
this.fromAlias = fromAlias;
|
|
91
|
+
this.joinAliases = joinAliases;
|
|
92
|
+
this.sum = 0;
|
|
93
|
+
this.count = 0;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Adds a row's value to the running sum and increments the count.
|
|
97
|
+
* @param {object} row The row to process.
|
|
98
|
+
*/
|
|
99
|
+
async add(row) {
|
|
100
|
+
const val = await evalExpression(row, this.expr, this.fromAlias, this.joinAliases);
|
|
101
|
+
if (val != null && typeof val === 'number') {
|
|
102
|
+
this.sum += val;
|
|
103
|
+
this.count++;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Returns the final average.
|
|
108
|
+
* @returns {number|null} The average, or null if no values were added.
|
|
109
|
+
*/
|
|
110
|
+
result() { return this.count > 0 ? this.sum / this.count : null; }
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Accumulator for the MIN() aggregate function.
|
|
114
|
+
*/
|
|
115
|
+
class Min {
|
|
116
|
+
/**
|
|
117
|
+
* @param {string} alias The result alias for this aggregate.
|
|
118
|
+
* @param {object} expr The expression to find the minimum of.
|
|
119
|
+
* @param {string} fromAlias The alias of the FROM table.
|
|
120
|
+
* @param {object} joinAliases A map of join table aliases.
|
|
121
|
+
*/
|
|
122
|
+
constructor(alias, expr, fromAlias, joinAliases) {
|
|
123
|
+
this.alias = alias;
|
|
124
|
+
this.expr = expr;
|
|
125
|
+
this.fromAlias = fromAlias;
|
|
126
|
+
this.joinAliases = joinAliases;
|
|
127
|
+
this.min = null;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Updates the minimum value based on the current row.
|
|
131
|
+
* @param {object} row The row to process.
|
|
132
|
+
*/
|
|
133
|
+
async add(row) {
|
|
134
|
+
const val = await evalExpression(row, this.expr, this.fromAlias, this.joinAliases);
|
|
135
|
+
if (val != null) {
|
|
136
|
+
if (this.min === null || val < this.min) {
|
|
137
|
+
this.min = val;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Returns the final minimum value.
|
|
143
|
+
* @returns {*} The minimum value, or null if no values were processed.
|
|
144
|
+
*/
|
|
145
|
+
result() { return this.min; }
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Accumulator for the MAX() aggregate function.
|
|
149
|
+
*/
|
|
150
|
+
class Max {
|
|
151
|
+
/**
|
|
152
|
+
* @param {string} alias The result alias for this aggregate.
|
|
153
|
+
* @param {object} expr The expression to find the maximum of.
|
|
154
|
+
* @param {string} fromAlias The alias of the FROM table.
|
|
155
|
+
* @param {object} joinAliases A map of join table aliases.
|
|
156
|
+
*/
|
|
157
|
+
constructor(alias, expr, fromAlias, joinAliases) {
|
|
158
|
+
this.alias = alias;
|
|
159
|
+
this.expr = expr;
|
|
160
|
+
this.fromAlias = fromAlias;
|
|
161
|
+
this.joinAliases = joinAliases;
|
|
162
|
+
this.max = null;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Updates the maximum value based on the current row.
|
|
166
|
+
* @param {object} row The row to process.
|
|
167
|
+
*/
|
|
168
|
+
async add(row) {
|
|
169
|
+
const val = await evalExpression(row, this.expr, this.fromAlias, this.joinAliases);
|
|
170
|
+
if (val != null) {
|
|
171
|
+
if (this.max === null || val > this.max) {
|
|
172
|
+
this.max = val;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Returns the final maximum value.
|
|
178
|
+
* @returns {*} The maximum value, or null if no values were processed.
|
|
179
|
+
*/
|
|
180
|
+
result() { return this.max; }
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* A wrapper class that adds DISTINCT functionality to another accumulator.
|
|
184
|
+
* It ensures that the inner accumulator only processes unique values.
|
|
185
|
+
*/
|
|
186
|
+
class DistinctWrapper {
|
|
187
|
+
/**
|
|
188
|
+
* @param {object} innerAccumulator The accumulator to wrap (e.g., Count, Sum).
|
|
189
|
+
*/
|
|
190
|
+
constructor(innerAccumulator) {
|
|
191
|
+
this.inner = innerAccumulator;
|
|
192
|
+
this.seen = new Set();
|
|
193
|
+
this.alias = this.inner.alias;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Adds a row's value to the inner accumulator only if it hasn't been seen before.
|
|
197
|
+
* @param {object} row The row to process.
|
|
198
|
+
*/
|
|
199
|
+
async add(row) {
|
|
200
|
+
const val = await evalExpression(row, this.inner.expr, this.inner.fromAlias, this.inner.joinAliases);
|
|
201
|
+
const key = JSON.stringify(val); // Use JSON to handle objects/arrays as keys
|
|
202
|
+
if (!this.seen.has(key)) {
|
|
203
|
+
this.seen.add(key);
|
|
204
|
+
// Delegate to the inner accumulator, which will re-evaluate, but only for unique values
|
|
205
|
+
await this.inner.add(row);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Returns the result from the inner accumulator.
|
|
210
|
+
* @returns {*} The final aggregated result.
|
|
211
|
+
*/
|
|
212
|
+
result() {
|
|
213
|
+
return this.inner.result();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Creates an array of accumulator instances based on the aggregate functions in the query plan.
|
|
218
|
+
* @param {Array<object>} aggregates A list of aggregate function definitions from the plan.
|
|
219
|
+
* @param {string} fromAlias The alias for the FROM table.
|
|
220
|
+
* @param {object} joinAliases A map of join aliases.
|
|
221
|
+
* @returns {Array<object>} An array of initialized accumulator instances.
|
|
222
|
+
* @throws {Error} If an unsupported aggregate function is specified.
|
|
223
|
+
*/
|
|
224
|
+
export function createAccumulators(aggregates, fromAlias, joinAliases) {
|
|
225
|
+
return aggregates.map(agg => {
|
|
226
|
+
const alias = agg.as || agg.expr.name;
|
|
227
|
+
const expr = agg.expr.args.expr;
|
|
228
|
+
const isDistinct = agg.expr.args.distinct;
|
|
229
|
+
let accumulator;
|
|
230
|
+
switch (agg.expr.name) {
|
|
231
|
+
case 'COUNT':
|
|
232
|
+
accumulator = new Count(alias, expr, fromAlias, joinAliases);
|
|
233
|
+
break;
|
|
234
|
+
case 'SUM':
|
|
235
|
+
accumulator = new Sum(alias, expr, fromAlias, joinAliases);
|
|
236
|
+
break;
|
|
237
|
+
case 'AVG':
|
|
238
|
+
accumulator = new Avg(alias, expr, fromAlias, joinAliases);
|
|
239
|
+
break;
|
|
240
|
+
case 'MIN':
|
|
241
|
+
accumulator = new Min(alias, expr, fromAlias, joinAliases);
|
|
242
|
+
break;
|
|
243
|
+
case 'MAX':
|
|
244
|
+
accumulator = new Max(alias, expr, fromAlias, joinAliases);
|
|
245
|
+
break;
|
|
246
|
+
default:
|
|
247
|
+
throw new Error(`Unsupported aggregate function: ${agg.expr.name}`);
|
|
248
|
+
}
|
|
249
|
+
if (isDistinct) {
|
|
250
|
+
// COUNT(*) should not be distinct
|
|
251
|
+
if (expr.type === 'star')
|
|
252
|
+
return accumulator;
|
|
253
|
+
return new DistinctWrapper(accumulator);
|
|
254
|
+
}
|
|
255
|
+
return accumulator;
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
//# sourceMappingURL=accumulators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accumulators.js","sourceRoot":"","sources":["../../../src/core/query-engine/accumulators.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,GAAG;IACL;;;;;OAKG;IACH,YAAY,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW;QAC3C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC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
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* Creates a function that evaluates a predicate AST node against a row.
|
|
4
|
+
* This is useful for filtering operations (e.g., in WHERE or JOIN ON clauses).
|
|
5
|
+
* The returned function is async to handle subqueries.
|
|
6
|
+
* @param {object} astNode The predicate AST node.
|
|
7
|
+
* @param {object} stack The ClientStack instance.
|
|
8
|
+
* @param {function} executePlan The main query execution function.
|
|
9
|
+
* @param {object} outerRow The row from the parent query context.
|
|
10
|
+
* @param {object} outerAliases The aliases from the parent query context.
|
|
11
|
+
* @returns {function(object): Promise<boolean>} An async function that takes a row and returns true if it matches the predicate.
|
|
12
|
+
*/
|
|
13
|
+
export function createRowEvaluator(astNode, stack, executePlan, outerRow, outerAliases) {
|
|
14
|
+
return async (row) => {
|
|
15
|
+
// Determine aliases from the current row context
|
|
16
|
+
const fromAlias = Object.keys(row).find(k => row[k] !== null) || Object.keys(row)[0];
|
|
17
|
+
const joinAliases = Object.keys(row).reduce((acc, key) => {
|
|
18
|
+
if (key !== fromAlias)
|
|
19
|
+
acc[key] = key; // simplified alias mapping
|
|
20
|
+
return acc;
|
|
21
|
+
}, {});
|
|
22
|
+
// The row being evaluated is the inner context, and we pass the captured outer context.
|
|
23
|
+
return await evalExpression(row, astNode, fromAlias, joinAliases, stack, executePlan, outerRow, outerAliases);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Evaluates an AST expression node against a data row. This function is async
|
|
28
|
+
* to handle scalar subqueries which require executing a separate query plan.
|
|
29
|
+
* @param {object} row The data row to evaluate against.
|
|
30
|
+
* @param {object} expr The AST expression node.
|
|
31
|
+
* @param {string} fromAlias The alias for the main FROM table.
|
|
32
|
+
* @param {object} joinAliases A map of aliases for joined tables.
|
|
33
|
+
* @param {object} stack The ClientStack instance for data access.
|
|
34
|
+
* @param {function} executePlan The function to execute sub-plans.
|
|
35
|
+
* @param {object} outerRow The row from the parent query context (for correlation).
|
|
36
|
+
* @param {object} outerAliases The aliases from the parent query context.
|
|
37
|
+
* @returns {Promise<*>} The result of the expression evaluation.
|
|
38
|
+
*/
|
|
39
|
+
export async function evalExpression(row, expr, fromAlias, joinAliases, stack, executePlan, outerRow, outerAliases) {
|
|
40
|
+
if (!expr)
|
|
41
|
+
return null;
|
|
42
|
+
switch (expr.type) {
|
|
43
|
+
case 'scalar_subquery': {
|
|
44
|
+
// Dynamically import planner to avoid circular dependency
|
|
45
|
+
const { createPlan } = await import('./planner');
|
|
46
|
+
const subqueryPlan = createPlan([expr.ast]);
|
|
47
|
+
// Execute the subquery, passing the current row as the outer context for correlation
|
|
48
|
+
const result = await executePlan(stack, subqueryPlan, [], row, null); // Pass outer row, but no aliases
|
|
49
|
+
if (result.length > 0 && result[0] != null) {
|
|
50
|
+
const firstRow = result[0];
|
|
51
|
+
const firstColName = Object.keys(firstRow)[0];
|
|
52
|
+
return firstRow[firstColName];
|
|
53
|
+
}
|
|
54
|
+
return null; // SQL standard: scalar subquery with no rows evaluates to NULL
|
|
55
|
+
}
|
|
56
|
+
case 'column_ref': {
|
|
57
|
+
const tableAlias = expr.table || fromAlias;
|
|
58
|
+
const tableData = row[tableAlias];
|
|
59
|
+
// 1. Check current row's data for the specified alias
|
|
60
|
+
if (tableData && typeof tableData === 'object' && tableData !== null && tableData.hasOwnProperty(expr.column)) {
|
|
61
|
+
return tableData[expr.column];
|
|
62
|
+
}
|
|
63
|
+
// 2. Fallback for simplified structures (e.g., aggregated rows)
|
|
64
|
+
if (row.hasOwnProperty(expr.column)) {
|
|
65
|
+
return row[expr.column];
|
|
66
|
+
}
|
|
67
|
+
// 3. Check outer context for correlated subqueries
|
|
68
|
+
if (outerRow) {
|
|
69
|
+
for (const alias in outerRow) {
|
|
70
|
+
const outerTableData = outerRow[alias];
|
|
71
|
+
if (outerTableData && typeof outerTableData === 'object' && outerTableData.hasOwnProperty(expr.column)) {
|
|
72
|
+
// If an explicit table is specified in the expression (e.g., m.actors),
|
|
73
|
+
// it must match the alias in the outer row.
|
|
74
|
+
if (expr.table && expr.table !== alias) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
return outerTableData[expr.column];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
case 'binary_expr': {
|
|
84
|
+
const left = await evalExpression(row, expr.left, fromAlias, joinAliases, stack, executePlan, outerRow, outerAliases);
|
|
85
|
+
let right;
|
|
86
|
+
if (expr.right.type === 'param') {
|
|
87
|
+
right = expr.right.value;
|
|
88
|
+
if (!isNaN(parseFloat(right)))
|
|
89
|
+
right = parseFloat(right);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
right = await evalExpression(row, expr.right, fromAlias, joinAliases, stack, executePlan, outerRow, outerAliases);
|
|
93
|
+
}
|
|
94
|
+
switch (expr.operator) {
|
|
95
|
+
case '=': return left == right;
|
|
96
|
+
case '>': return left > right;
|
|
97
|
+
case '<': return left < right;
|
|
98
|
+
case '>=': return left >= right;
|
|
99
|
+
case '<=': return left <= right;
|
|
100
|
+
case 'IN': // This is handled specially during join execution
|
|
101
|
+
return Array.isArray(right) && right.includes(left);
|
|
102
|
+
default:
|
|
103
|
+
throw new Error(`Unsupported operator ${expr.operator}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
case 'aggr_func':
|
|
107
|
+
// This should be handled by accumulators, but can be evaluated post-aggregation
|
|
108
|
+
if (row.hasOwnProperty(expr.name))
|
|
109
|
+
return row[expr.name];
|
|
110
|
+
return null;
|
|
111
|
+
case 'param':
|
|
112
|
+
let value = expr.value;
|
|
113
|
+
if (!isNaN(parseFloat(value)))
|
|
114
|
+
value = parseFloat(value);
|
|
115
|
+
return value;
|
|
116
|
+
case 'star':
|
|
117
|
+
return row; // Represents the whole row for COUNT(*)
|
|
118
|
+
default:
|
|
119
|
+
throw new Error(`Unsupported expression type: ${expr.type}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Evaluates an expression against a row that has already been aggregated.
|
|
124
|
+
* This is specifically used for the HAVING clause, where expressions can
|
|
125
|
+
* contain aggregate functions or GROUP BY columns.
|
|
126
|
+
* @param {object} row The aggregated data row.
|
|
127
|
+
* @param {object} expr The AST expression node from the HAVING clause.
|
|
128
|
+
* @param {Map<string, string>} aggregateAliasMap A map to resolve aggregate function expressions to their aliases in the row.
|
|
129
|
+
* @returns {*} The result of the expression evaluation.
|
|
130
|
+
* @throws {Error} If the expression is invalid for a HAVING clause.
|
|
131
|
+
*/
|
|
132
|
+
export function evalAggregatedRowExpression(row, expr, aggregateAliasMap) {
|
|
133
|
+
if (!expr)
|
|
134
|
+
return null;
|
|
135
|
+
switch (expr.type) {
|
|
136
|
+
case 'aggr_func':
|
|
137
|
+
const key = JSON.stringify(expr);
|
|
138
|
+
const alias = aggregateAliasMap.get(key);
|
|
139
|
+
if (alias && row.hasOwnProperty(alias)) {
|
|
140
|
+
return row[alias];
|
|
141
|
+
}
|
|
142
|
+
throw new Error(`Aggregate function ${expr.name} used in HAVING clause was not found in the SELECT list.`);
|
|
143
|
+
case 'column_ref':
|
|
144
|
+
// In an aggregated row, column refs point to GROUP BY keys.
|
|
145
|
+
const colName = expr.as || expr.column;
|
|
146
|
+
if (row.hasOwnProperty(colName)) {
|
|
147
|
+
return row[colName];
|
|
148
|
+
}
|
|
149
|
+
throw new Error(`Column '${colName}' not found in aggregated row. It must be part of the GROUP BY clause.`);
|
|
150
|
+
case 'binary_expr':
|
|
151
|
+
const left = evalAggregatedRowExpression(row, expr.left, aggregateAliasMap);
|
|
152
|
+
let right;
|
|
153
|
+
if (expr.right.type === 'param') {
|
|
154
|
+
right = expr.right.value;
|
|
155
|
+
if (!isNaN(parseFloat(right)))
|
|
156
|
+
right = parseFloat(right);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
right = evalAggregatedRowExpression(row, expr.right, aggregateAliasMap);
|
|
160
|
+
}
|
|
161
|
+
switch (expr.operator) {
|
|
162
|
+
case '=': return left == right;
|
|
163
|
+
case '>': return left > right;
|
|
164
|
+
case '<': return left < right;
|
|
165
|
+
case '>=': return left >= right;
|
|
166
|
+
case '<=': return left <= right;
|
|
167
|
+
default:
|
|
168
|
+
throw new Error(`Unsupported operator in HAVING clause: ${expr.operator}`);
|
|
169
|
+
}
|
|
170
|
+
case 'param':
|
|
171
|
+
let value = expr.value;
|
|
172
|
+
if (!isNaN(parseFloat(value)))
|
|
173
|
+
value = parseFloat(value);
|
|
174
|
+
return value;
|
|
175
|
+
default:
|
|
176
|
+
throw new Error(`Unsupported expression type in HAVING clause: ${expr.type}`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=evaluator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluator.js","sourceRoot":"","sources":["../../../src/core/query-engine/evaluator.ts"],"names":[],"mappings":"AAAA,cAAc;AAEd;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY;IAClF,OAAO,KAAK,EAAE,GAAG,EAAE,EAAE;QACjB,iDAAiD;QACjD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACrF,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YACrD,IAAI,GAAG,KAAK,SAAS;gBAAE,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,2BAA2B;YAClE,OAAO,GAAG,CAAC;QACf,CAAC,EAAE,EAAE,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