rawsql-ts 0.11.25-beta → 0.11.27-beta
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/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +23 -23
- package/dist/esm/index.min.js.map +4 -4
- package/dist/esm/src/index.d.ts +2 -0
- package/dist/esm/src/index.js +2 -0
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/transformers/CTEDependencyAnalyzer.d.ts +1 -0
- package/dist/esm/src/transformers/CTEDependencyAnalyzer.js +10 -2
- package/dist/esm/src/transformers/CTEDependencyAnalyzer.js.map +1 -1
- package/dist/esm/src/transformers/CTEQueryDecomposer.d.ts +6 -0
- package/dist/esm/src/transformers/CTEQueryDecomposer.js +79 -1
- package/dist/esm/src/transformers/CTEQueryDecomposer.js.map +1 -1
- package/dist/esm/src/transformers/CTETableReferenceCollector.d.ts +87 -0
- package/dist/esm/src/transformers/CTETableReferenceCollector.js +354 -0
- package/dist/esm/src/transformers/CTETableReferenceCollector.js.map +1 -0
- package/dist/esm/src/transformers/JoinAggregationDecomposer.d.ts +188 -0
- package/dist/esm/src/transformers/JoinAggregationDecomposer.js +490 -0
- package/dist/esm/src/transformers/JoinAggregationDecomposer.js.map +1 -0
- package/dist/esm/src/transformers/QueryBuilder.d.ts +22 -0
- package/dist/esm/src/transformers/QueryBuilder.js +49 -3
- package/dist/esm/src/transformers/QueryBuilder.js.map +1 -1
- package/dist/esm/src/transformers/TableSourceCollector.js +2 -2
- package/dist/esm/src/transformers/TableSourceCollector.js.map +1 -1
- package/dist/esm/tsconfig.browser.tsbuildinfo +1 -1
- package/dist/index.min.js +25 -25
- package/dist/index.min.js.map +4 -4
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/transformers/CTEDependencyAnalyzer.d.ts +1 -0
- package/dist/src/transformers/CTEDependencyAnalyzer.js +10 -2
- package/dist/src/transformers/CTEDependencyAnalyzer.js.map +1 -1
- package/dist/src/transformers/CTEQueryDecomposer.d.ts +6 -0
- package/dist/src/transformers/CTEQueryDecomposer.js +79 -1
- package/dist/src/transformers/CTEQueryDecomposer.js.map +1 -1
- package/dist/src/transformers/CTETableReferenceCollector.d.ts +87 -0
- package/dist/src/transformers/CTETableReferenceCollector.js +358 -0
- package/dist/src/transformers/CTETableReferenceCollector.js.map +1 -0
- package/dist/src/transformers/JoinAggregationDecomposer.d.ts +188 -0
- package/dist/src/transformers/JoinAggregationDecomposer.js +497 -0
- package/dist/src/transformers/JoinAggregationDecomposer.js.map +1 -0
- package/dist/src/transformers/QueryBuilder.d.ts +22 -0
- package/dist/src/transformers/QueryBuilder.js +49 -3
- package/dist/src/transformers/QueryBuilder.js.map +1 -1
- package/dist/src/transformers/TableSourceCollector.js +2 -2
- package/dist/src/transformers/TableSourceCollector.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CTETableReferenceCollector = void 0;
|
|
4
|
+
const Clause_1 = require("../models/Clause");
|
|
5
|
+
const SelectQuery_1 = require("../models/SelectQuery");
|
|
6
|
+
const ValueComponent_1 = require("../models/ValueComponent");
|
|
7
|
+
/**
|
|
8
|
+
* A specialized table source collector designed for CTE dependency analysis.
|
|
9
|
+
*
|
|
10
|
+
* Unlike the general-purpose TableSourceCollector, this collector:
|
|
11
|
+
* - Always includes CTE references in results (treats CTEs as valid table sources)
|
|
12
|
+
* - Always performs deep traversal of subqueries, WHERE clauses, etc.
|
|
13
|
+
* - Is optimized for dependency analysis rather than database schema analysis
|
|
14
|
+
*
|
|
15
|
+
* This collector is specifically designed for use by CTEDependencyAnalyzer to track
|
|
16
|
+
* which tables/CTEs are referenced by queries at any nesting level.
|
|
17
|
+
*/
|
|
18
|
+
class CTETableReferenceCollector {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.tableSources = [];
|
|
21
|
+
this.visitedNodes = new Set();
|
|
22
|
+
this.tableNameMap = new Map();
|
|
23
|
+
this.isRootVisit = true;
|
|
24
|
+
this.handlers = new Map();
|
|
25
|
+
// Setup handlers for query components
|
|
26
|
+
this.handlers.set(SelectQuery_1.SimpleSelectQuery.kind, (expr) => this.visitSimpleSelectQuery(expr));
|
|
27
|
+
this.handlers.set(SelectQuery_1.BinarySelectQuery.kind, (expr) => this.visitBinarySelectQuery(expr));
|
|
28
|
+
this.handlers.set(SelectQuery_1.ValuesQuery.kind, (expr) => this.visitValuesQuery(expr));
|
|
29
|
+
// Note: We intentionally do NOT handle WITH clause and CommonTable
|
|
30
|
+
// These are processed separately by CTEDependencyAnalyzer for CTE-to-CTE dependencies
|
|
31
|
+
// Handlers for FROM and JOIN components
|
|
32
|
+
this.handlers.set(Clause_1.FromClause.kind, (expr) => this.visitFromClause(expr));
|
|
33
|
+
this.handlers.set(Clause_1.JoinClause.kind, (expr) => this.visitJoinClause(expr));
|
|
34
|
+
this.handlers.set(Clause_1.JoinOnClause.kind, (expr) => this.visitJoinOnClause(expr));
|
|
35
|
+
this.handlers.set(Clause_1.JoinUsingClause.kind, (expr) => this.visitJoinUsingClause(expr));
|
|
36
|
+
// Source components
|
|
37
|
+
this.handlers.set(Clause_1.SourceExpression.kind, (expr) => this.visitSourceExpression(expr));
|
|
38
|
+
this.handlers.set(Clause_1.TableSource.kind, (expr) => this.visitTableSource(expr));
|
|
39
|
+
this.handlers.set(Clause_1.FunctionSource.kind, (expr) => this.visitFunctionSource(expr));
|
|
40
|
+
this.handlers.set(Clause_1.ParenSource.kind, (expr) => this.visitParenSource(expr));
|
|
41
|
+
this.handlers.set(Clause_1.SubQuerySource.kind, (expr) => this.visitSubQuerySource(expr));
|
|
42
|
+
this.handlers.set(ValueComponent_1.InlineQuery.kind, (expr) => this.visitInlineQuery(expr));
|
|
43
|
+
// Additional clause handlers for full scanning
|
|
44
|
+
this.handlers.set(Clause_1.WhereClause.kind, (expr) => this.visitWhereClause(expr));
|
|
45
|
+
this.handlers.set(Clause_1.GroupByClause.kind, (expr) => this.visitGroupByClause(expr));
|
|
46
|
+
this.handlers.set(Clause_1.HavingClause.kind, (expr) => this.visitHavingClause(expr));
|
|
47
|
+
this.handlers.set(Clause_1.OrderByClause.kind, (expr) => this.visitOrderByClause(expr));
|
|
48
|
+
this.handlers.set(Clause_1.WindowFrameClause.kind, (expr) => this.visitWindowFrameClause(expr));
|
|
49
|
+
this.handlers.set(Clause_1.LimitClause.kind, (expr) => this.visitLimitClause(expr));
|
|
50
|
+
this.handlers.set(Clause_1.OffsetClause.kind, (expr) => this.visitOffsetClause(expr));
|
|
51
|
+
this.handlers.set(Clause_1.FetchClause.kind, (expr) => this.visitFetchClause(expr));
|
|
52
|
+
this.handlers.set(Clause_1.ForClause.kind, (expr) => this.visitForClause(expr));
|
|
53
|
+
this.handlers.set(Clause_1.OrderByItem.kind, (expr) => this.visitOrderByItem(expr));
|
|
54
|
+
this.handlers.set(Clause_1.SelectClause.kind, (expr) => this.visitSelectClause(expr));
|
|
55
|
+
this.handlers.set(Clause_1.SelectItem.kind, (expr) => this.visitSelectItem(expr));
|
|
56
|
+
// Value components that might contain table references
|
|
57
|
+
this.handlers.set(ValueComponent_1.ParenExpression.kind, (expr) => this.visitParenExpression(expr));
|
|
58
|
+
this.handlers.set(ValueComponent_1.BinaryExpression.kind, (expr) => this.visitBinaryExpression(expr));
|
|
59
|
+
this.handlers.set(ValueComponent_1.UnaryExpression.kind, (expr) => this.visitUnaryExpression(expr));
|
|
60
|
+
this.handlers.set(ValueComponent_1.CaseExpression.kind, (expr) => this.visitCaseExpression(expr));
|
|
61
|
+
this.handlers.set(ValueComponent_1.CaseKeyValuePair.kind, (expr) => this.visitCaseKeyValuePair(expr));
|
|
62
|
+
this.handlers.set(ValueComponent_1.SwitchCaseArgument.kind, (expr) => this.visitSwitchCaseArgument(expr));
|
|
63
|
+
this.handlers.set(ValueComponent_1.BetweenExpression.kind, (expr) => this.visitBetweenExpression(expr));
|
|
64
|
+
this.handlers.set(ValueComponent_1.FunctionCall.kind, (expr) => this.visitFunctionCall(expr));
|
|
65
|
+
this.handlers.set(ValueComponent_1.ArrayExpression.kind, (expr) => this.visitArrayExpression(expr));
|
|
66
|
+
this.handlers.set(ValueComponent_1.ArrayQueryExpression.kind, (expr) => this.visitArrayQueryExpression(expr));
|
|
67
|
+
this.handlers.set(ValueComponent_1.TupleExpression.kind, (expr) => this.visitTupleExpression(expr));
|
|
68
|
+
this.handlers.set(ValueComponent_1.CastExpression.kind, (expr) => this.visitCastExpression(expr));
|
|
69
|
+
this.handlers.set(ValueComponent_1.ValueList.kind, (expr) => this.visitValueList(expr));
|
|
70
|
+
this.handlers.set(ValueComponent_1.StringSpecifierExpression.kind, (expr) => this.visitStringSpecifierExpression(expr));
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Collects all table references from the given SQL component
|
|
74
|
+
* @param query The SQL component to analyze
|
|
75
|
+
* @returns Array of TableSource objects representing all table references
|
|
76
|
+
*/
|
|
77
|
+
collect(query) {
|
|
78
|
+
this.visit(query);
|
|
79
|
+
return this.getTableSources();
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Gets all collected table sources
|
|
83
|
+
*/
|
|
84
|
+
getTableSources() {
|
|
85
|
+
return this.tableSources;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Reset the collection of table sources
|
|
89
|
+
*/
|
|
90
|
+
reset() {
|
|
91
|
+
this.tableSources = [];
|
|
92
|
+
this.tableNameMap.clear();
|
|
93
|
+
this.visitedNodes.clear();
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Gets a unique identifier for a table source
|
|
97
|
+
*/
|
|
98
|
+
getTableIdentifier(source) {
|
|
99
|
+
// Use QualifiedName for identifier (dot-joined string)
|
|
100
|
+
if (source.qualifiedName.namespaces && source.qualifiedName.namespaces.length > 0) {
|
|
101
|
+
return source.qualifiedName.namespaces.map(ns => ns.name).join('.') + '.' + (source.qualifiedName.name instanceof ValueComponent_1.RawString ? source.qualifiedName.name.value : source.qualifiedName.name.name);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
return source.qualifiedName.name instanceof ValueComponent_1.RawString ? source.qualifiedName.name.value : source.qualifiedName.name.name;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Main entry point for the visitor pattern.
|
|
109
|
+
*/
|
|
110
|
+
visit(arg) {
|
|
111
|
+
// If not a root visit, just visit the node and return
|
|
112
|
+
if (!this.isRootVisit) {
|
|
113
|
+
this.visitNode(arg);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
// If this is a root visit, we need to reset the state
|
|
117
|
+
this.reset();
|
|
118
|
+
this.isRootVisit = false;
|
|
119
|
+
try {
|
|
120
|
+
this.visitNode(arg);
|
|
121
|
+
}
|
|
122
|
+
finally {
|
|
123
|
+
// Regardless of success or failure, reset the root visit flag
|
|
124
|
+
this.isRootVisit = true;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Internal visit method used for all nodes.
|
|
129
|
+
*/
|
|
130
|
+
visitNode(arg) {
|
|
131
|
+
// Skip if we've already visited this node to prevent infinite recursion
|
|
132
|
+
if (this.visitedNodes.has(arg)) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
// Mark as visited
|
|
136
|
+
this.visitedNodes.add(arg);
|
|
137
|
+
const handler = this.handlers.get(arg.getKind());
|
|
138
|
+
if (handler) {
|
|
139
|
+
handler(arg);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
// If no handler found, that's ok - we only care about specific components
|
|
143
|
+
}
|
|
144
|
+
visitSimpleSelectQuery(query) {
|
|
145
|
+
// Skip WITH clause processing - we only want to collect table references from the main query parts
|
|
146
|
+
// The WITH clause is handled separately by CTEDependencyAnalyzer for CTE-to-CTE dependencies
|
|
147
|
+
if (query.fromClause) {
|
|
148
|
+
query.fromClause.accept(this);
|
|
149
|
+
}
|
|
150
|
+
if (query.whereClause) {
|
|
151
|
+
query.whereClause.accept(this);
|
|
152
|
+
}
|
|
153
|
+
if (query.groupByClause) {
|
|
154
|
+
query.groupByClause.accept(this);
|
|
155
|
+
}
|
|
156
|
+
if (query.havingClause) {
|
|
157
|
+
query.havingClause.accept(this);
|
|
158
|
+
}
|
|
159
|
+
if (query.orderByClause) {
|
|
160
|
+
query.orderByClause.accept(this);
|
|
161
|
+
}
|
|
162
|
+
if (query.windowClause) {
|
|
163
|
+
for (const win of query.windowClause.windows) {
|
|
164
|
+
win.accept(this);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (query.limitClause) {
|
|
168
|
+
query.limitClause.accept(this);
|
|
169
|
+
}
|
|
170
|
+
if (query.offsetClause) {
|
|
171
|
+
query.offsetClause.accept(this);
|
|
172
|
+
}
|
|
173
|
+
if (query.fetchClause) {
|
|
174
|
+
query.fetchClause.accept(this);
|
|
175
|
+
}
|
|
176
|
+
if (query.forClause) {
|
|
177
|
+
query.forClause.accept(this);
|
|
178
|
+
}
|
|
179
|
+
query.selectClause.accept(this);
|
|
180
|
+
}
|
|
181
|
+
visitBinarySelectQuery(query) {
|
|
182
|
+
// For UNION-like queries, visit both sides
|
|
183
|
+
query.left.accept(this);
|
|
184
|
+
query.right.accept(this);
|
|
185
|
+
}
|
|
186
|
+
visitValuesQuery(query) {
|
|
187
|
+
// VALUES queries might contain subqueries in tuple expressions
|
|
188
|
+
for (const tuple of query.tuples) {
|
|
189
|
+
tuple.accept(this);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
visitFromClause(fromClause) {
|
|
193
|
+
// Check the main source in FROM clause
|
|
194
|
+
fromClause.source.accept(this);
|
|
195
|
+
// Check all JOIN clauses
|
|
196
|
+
if (fromClause.joins) {
|
|
197
|
+
for (const join of fromClause.joins) {
|
|
198
|
+
join.accept(this);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
visitSourceExpression(source) {
|
|
203
|
+
// Process the actual data source, ignoring aliases
|
|
204
|
+
source.datasource.accept(this);
|
|
205
|
+
}
|
|
206
|
+
visitTableSource(source) {
|
|
207
|
+
// Get the table identifier for uniqueness check
|
|
208
|
+
const identifier = this.getTableIdentifier(source);
|
|
209
|
+
// Include all table sources (both real tables and CTEs)
|
|
210
|
+
if (!this.tableNameMap.has(identifier)) {
|
|
211
|
+
this.tableNameMap.set(identifier, true);
|
|
212
|
+
this.tableSources.push(source);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
visitFunctionSource(source) {
|
|
216
|
+
// Function sources are not regular table sources, but may contain subqueries in their arguments
|
|
217
|
+
if (source.argument) {
|
|
218
|
+
this.visitValueComponent(source.argument);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
visitValueComponent(value) {
|
|
222
|
+
value.accept(this);
|
|
223
|
+
}
|
|
224
|
+
visitParenSource(source) {
|
|
225
|
+
source.source.accept(this);
|
|
226
|
+
}
|
|
227
|
+
visitSubQuerySource(subQuery) {
|
|
228
|
+
// Always check subqueries in CTE analysis mode
|
|
229
|
+
subQuery.query.accept(this);
|
|
230
|
+
}
|
|
231
|
+
visitInlineQuery(inlineQuery) {
|
|
232
|
+
// Always visit inline queries
|
|
233
|
+
inlineQuery.selectQuery.accept(this);
|
|
234
|
+
}
|
|
235
|
+
visitJoinClause(joinClause) {
|
|
236
|
+
// Visit the source being joined
|
|
237
|
+
joinClause.source.accept(this);
|
|
238
|
+
// Visit the join condition
|
|
239
|
+
if (joinClause.condition) {
|
|
240
|
+
joinClause.condition.accept(this);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
visitJoinOnClause(joinOn) {
|
|
244
|
+
joinOn.condition.accept(this);
|
|
245
|
+
}
|
|
246
|
+
visitJoinUsingClause(joinUsing) {
|
|
247
|
+
joinUsing.condition.accept(this);
|
|
248
|
+
}
|
|
249
|
+
// Additional visitor methods for comprehensive analysis
|
|
250
|
+
visitWhereClause(whereClause) {
|
|
251
|
+
whereClause.condition.accept(this);
|
|
252
|
+
}
|
|
253
|
+
visitGroupByClause(clause) {
|
|
254
|
+
for (const item of clause.grouping) {
|
|
255
|
+
item.accept(this);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
visitHavingClause(clause) {
|
|
259
|
+
clause.condition.accept(this);
|
|
260
|
+
}
|
|
261
|
+
visitOrderByClause(clause) {
|
|
262
|
+
for (const item of clause.order) {
|
|
263
|
+
item.accept(this);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
visitWindowFrameClause(clause) {
|
|
267
|
+
clause.expression.accept(this);
|
|
268
|
+
}
|
|
269
|
+
visitLimitClause(clause) {
|
|
270
|
+
clause.value.accept(this);
|
|
271
|
+
}
|
|
272
|
+
visitOffsetClause(clause) {
|
|
273
|
+
clause.value.accept(this);
|
|
274
|
+
}
|
|
275
|
+
visitFetchClause(clause) {
|
|
276
|
+
clause.expression.accept(this);
|
|
277
|
+
}
|
|
278
|
+
visitForClause(_clause) {
|
|
279
|
+
// FOR clause doesn't contain table sources
|
|
280
|
+
}
|
|
281
|
+
visitOrderByItem(item) {
|
|
282
|
+
item.value.accept(this);
|
|
283
|
+
}
|
|
284
|
+
visitSelectClause(clause) {
|
|
285
|
+
for (const item of clause.items) {
|
|
286
|
+
item.accept(this);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
visitSelectItem(item) {
|
|
290
|
+
item.value.accept(this);
|
|
291
|
+
}
|
|
292
|
+
visitParenExpression(expr) {
|
|
293
|
+
expr.expression.accept(this);
|
|
294
|
+
}
|
|
295
|
+
visitBinaryExpression(expr) {
|
|
296
|
+
expr.left.accept(this);
|
|
297
|
+
expr.right.accept(this);
|
|
298
|
+
}
|
|
299
|
+
visitUnaryExpression(expr) {
|
|
300
|
+
expr.expression.accept(this);
|
|
301
|
+
}
|
|
302
|
+
visitCaseExpression(expr) {
|
|
303
|
+
if (expr.condition) {
|
|
304
|
+
expr.condition.accept(this);
|
|
305
|
+
}
|
|
306
|
+
expr.switchCase.accept(this);
|
|
307
|
+
}
|
|
308
|
+
visitSwitchCaseArgument(switchCase) {
|
|
309
|
+
for (const caseItem of switchCase.cases) {
|
|
310
|
+
caseItem.accept(this);
|
|
311
|
+
}
|
|
312
|
+
if (switchCase.elseValue) {
|
|
313
|
+
switchCase.elseValue.accept(this);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
visitCaseKeyValuePair(pair) {
|
|
317
|
+
pair.key.accept(this);
|
|
318
|
+
pair.value.accept(this);
|
|
319
|
+
}
|
|
320
|
+
visitBetweenExpression(expr) {
|
|
321
|
+
expr.expression.accept(this);
|
|
322
|
+
expr.lower.accept(this);
|
|
323
|
+
expr.upper.accept(this);
|
|
324
|
+
}
|
|
325
|
+
visitFunctionCall(func) {
|
|
326
|
+
if (func.argument) {
|
|
327
|
+
func.argument.accept(this);
|
|
328
|
+
}
|
|
329
|
+
if (func.over) {
|
|
330
|
+
func.over.accept(this);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
visitArrayExpression(expr) {
|
|
334
|
+
expr.expression.accept(this);
|
|
335
|
+
}
|
|
336
|
+
visitArrayQueryExpression(expr) {
|
|
337
|
+
expr.query.accept(this);
|
|
338
|
+
}
|
|
339
|
+
visitTupleExpression(expr) {
|
|
340
|
+
for (const value of expr.values) {
|
|
341
|
+
value.accept(this);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
visitCastExpression(expr) {
|
|
345
|
+
expr.input.accept(this);
|
|
346
|
+
expr.castType.accept(this);
|
|
347
|
+
}
|
|
348
|
+
visitValueList(valueList) {
|
|
349
|
+
for (const value of valueList.values) {
|
|
350
|
+
value.accept(this);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
visitStringSpecifierExpression(_expr) {
|
|
354
|
+
// StringSpecifierExpression doesn't contain table references
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
exports.CTETableReferenceCollector = CTETableReferenceCollector;
|
|
358
|
+
//# sourceMappingURL=CTETableReferenceCollector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CTETableReferenceCollector.js","sourceRoot":"","sources":["../../../src/transformers/CTETableReferenceCollector.ts"],"names":[],"mappings":";;;AAAA,6CAAsY;AACtY,uDAAuG;AAEvG,6DASkC;AAElC;;;;;;;;;;GAUG;AACH,MAAa,0BAA0B;IAOnC;QALQ,iBAAY,GAAkB,EAAE,CAAC;QACjC,iBAAY,GAAsB,IAAI,GAAG,EAAE,CAAC;QAC5C,iBAAY,GAAyB,IAAI,GAAG,EAAmB,CAAC;QAChE,gBAAW,GAAY,IAAI,CAAC;QAGhC,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAA8B,CAAC;QAEtD,sCAAsC;QACtC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,+BAAiB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,IAAyB,CAAC,CAAC,CAAC;QAC5G,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,+BAAiB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,IAAyB,CAAC,CAAC,CAAC;QAC5G,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,yBAAW,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAmB,CAAC,CAAC,CAAC;QAE1F,mEAAmE;QACnE,sFAAsF;QAEtF,wCAAwC;QACxC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,mBAAU,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,IAAkB,CAAC,CAAC,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AAI,CAAC,CAAC;QAC/B,CAAC;QAED,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACZ,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;IACL,CAAC;IAEO,oBAAoB,CAAC,IAAqB;QAC9C,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAEO,yBAAyB,CAAC,IAA0B;QACxD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAEO,oBAAoB,CAAC,IAAqB;QAC9C,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC9B,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACL,CAAC;IAEO,mBAAmB,CAAC,IAAoB;QAC5C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACxB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAEO,cAAc,CAAC,SAAoB;QACvC,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;YACnC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACL,CAAC;IAEO,8BAA8B,CAAC,KAAgC;QACnE,6DAA6D;IACjE,CAAC;CACJ;AA7ZD,gEA6ZC"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { SimpleSelectQuery } from "../models/SimpleSelectQuery";
|
|
2
|
+
/**
|
|
3
|
+
* Options for JoinAggregationDecomposer
|
|
4
|
+
*/
|
|
5
|
+
export interface JoinDecomposerOptions {
|
|
6
|
+
/** Name for the detail CTE (default: "detail_data") */
|
|
7
|
+
detailCTEName?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Result of decomposition analysis (safe, no exceptions)
|
|
11
|
+
*/
|
|
12
|
+
export interface DecompositionAnalysisResult {
|
|
13
|
+
/** Whether the query can be decomposed */
|
|
14
|
+
success: boolean;
|
|
15
|
+
/** The decomposed query if successful */
|
|
16
|
+
decomposedQuery?: SimpleSelectQuery;
|
|
17
|
+
/** Error message if failed */
|
|
18
|
+
error?: string;
|
|
19
|
+
/** Known limitations that may affect the result */
|
|
20
|
+
limitations?: string[];
|
|
21
|
+
/** Metadata about the decomposition process */
|
|
22
|
+
metadata: {
|
|
23
|
+
/** Number of JOINs found */
|
|
24
|
+
joinCount: number;
|
|
25
|
+
/** Number of aggregation functions found */
|
|
26
|
+
aggregationCount: number;
|
|
27
|
+
/** Columns included in detail CTE */
|
|
28
|
+
detailColumns: string[];
|
|
29
|
+
/** Whether HAVING clause exists */
|
|
30
|
+
hasHaving: boolean;
|
|
31
|
+
/** Whether ORDER BY clause exists */
|
|
32
|
+
hasOrderBy: boolean;
|
|
33
|
+
/** Whether window functions are present */
|
|
34
|
+
hasWindowFunctions: boolean;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Error thrown when query decomposition fails
|
|
39
|
+
*/
|
|
40
|
+
export declare class DecompositionError extends Error {
|
|
41
|
+
readonly originalQuery: SimpleSelectQuery;
|
|
42
|
+
readonly cause?: Error | undefined;
|
|
43
|
+
constructor(message: string, originalQuery: SimpleSelectQuery, cause?: Error | undefined);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Decomposes queries that combine table joins with aggregations into separate detail and aggregation queries using CTEs
|
|
47
|
+
*
|
|
48
|
+
* This transformer separates JOIN operations from aggregation operations to make queries easier to debug:
|
|
49
|
+
* - Detail query: Contains JOINs and column selection
|
|
50
|
+
* - Aggregation query: Contains GROUP BY and aggregation functions, referencing the CTE
|
|
51
|
+
*
|
|
52
|
+
* Provides two patterns following existing codebase conventions:
|
|
53
|
+
* - analyze(): Safe analysis (Result pattern like SelectQueryParser.analyze)
|
|
54
|
+
* - decompose(): Direct decomposition with exceptions (Exception pattern like SelectQueryParser.parse)
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const decomposer = new JoinAggregationDecomposer();
|
|
59
|
+
*
|
|
60
|
+
* // Safe analysis (Result pattern)
|
|
61
|
+
* const analysis = decomposer.analyze(query);
|
|
62
|
+
* if (analysis.success) {
|
|
63
|
+
* console.log('Can decompose with', analysis.metadata.joinCount, 'joins');
|
|
64
|
+
* if (analysis.limitations) {
|
|
65
|
+
* console.log('Known limitations:', analysis.limitations);
|
|
66
|
+
* }
|
|
67
|
+
* } else {
|
|
68
|
+
* console.log('Cannot decompose:', analysis.error);
|
|
69
|
+
* }
|
|
70
|
+
*
|
|
71
|
+
* // Direct decomposition (Exception pattern)
|
|
72
|
+
* try {
|
|
73
|
+
* const decomposed = decomposer.decompose(query);
|
|
74
|
+
* // Success: decomposed query ready to use
|
|
75
|
+
* } catch (error) {
|
|
76
|
+
* if (error instanceof DecompositionError) {
|
|
77
|
+
* console.log('Decomposition failed:', error.message);
|
|
78
|
+
* }
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export declare class JoinAggregationDecomposer {
|
|
83
|
+
private readonly options;
|
|
84
|
+
private readonly formatter;
|
|
85
|
+
constructor(options?: JoinDecomposerOptions);
|
|
86
|
+
/**
|
|
87
|
+
* Analyzes a query for decomposition without throwing errors (safe analysis)
|
|
88
|
+
* Follows the same pattern as SelectQueryParser.analyze()
|
|
89
|
+
*
|
|
90
|
+
* @param query The query to analyze
|
|
91
|
+
* @returns Analysis result with success status, error information, and metadata
|
|
92
|
+
*/
|
|
93
|
+
analyze(query: SimpleSelectQuery): DecompositionAnalysisResult;
|
|
94
|
+
/**
|
|
95
|
+
* Decomposes a JOIN + aggregation query into separate detail and aggregation queries
|
|
96
|
+
* Follows the same pattern as SelectQueryParser.parse() - throws on error
|
|
97
|
+
*
|
|
98
|
+
* @param query The query to decompose
|
|
99
|
+
* @returns The decomposed query with CTE structure
|
|
100
|
+
* @throws DecompositionError if the query cannot be decomposed or formatted
|
|
101
|
+
*/
|
|
102
|
+
decompose(query: SimpleSelectQuery): SimpleSelectQuery;
|
|
103
|
+
/**
|
|
104
|
+
* Gets validation error message without throwing (for analyze method)
|
|
105
|
+
*/
|
|
106
|
+
private getValidationError;
|
|
107
|
+
/**
|
|
108
|
+
* Performs the actual decomposition
|
|
109
|
+
*/
|
|
110
|
+
private performDecomposition;
|
|
111
|
+
/**
|
|
112
|
+
* Extracts metadata about the query
|
|
113
|
+
*/
|
|
114
|
+
private extractMetadata;
|
|
115
|
+
/**
|
|
116
|
+
* Detects known limitations based on metadata
|
|
117
|
+
*/
|
|
118
|
+
private detectLimitations;
|
|
119
|
+
/**
|
|
120
|
+
* Counts the number of JOINs in the query
|
|
121
|
+
*/
|
|
122
|
+
private countJoins;
|
|
123
|
+
/**
|
|
124
|
+
* Counts aggregation functions in the query
|
|
125
|
+
*/
|
|
126
|
+
private countAggregationFunctions;
|
|
127
|
+
/**
|
|
128
|
+
* Checks if query contains window functions
|
|
129
|
+
*/
|
|
130
|
+
private hasWindowFunctions;
|
|
131
|
+
/**
|
|
132
|
+
* Checks if an expression contains aggregation functions
|
|
133
|
+
*/
|
|
134
|
+
private containsAggregationFunction;
|
|
135
|
+
/**
|
|
136
|
+
* Checks if an expression contains window functions
|
|
137
|
+
*/
|
|
138
|
+
private containsWindowFunction;
|
|
139
|
+
/**
|
|
140
|
+
* Gets function name from FunctionCall
|
|
141
|
+
*/
|
|
142
|
+
private getFunctionName;
|
|
143
|
+
/**
|
|
144
|
+
* Extracts detail column names for metadata
|
|
145
|
+
*/
|
|
146
|
+
private extractDetailColumnNames;
|
|
147
|
+
/**
|
|
148
|
+
* Extracts columns needed for the detail CTE
|
|
149
|
+
*/
|
|
150
|
+
private extractDetailColumns;
|
|
151
|
+
/**
|
|
152
|
+
* Extracts column references from an expression
|
|
153
|
+
*/
|
|
154
|
+
private extractColumnsFromExpression;
|
|
155
|
+
/**
|
|
156
|
+
* Gets a unique key for a column reference
|
|
157
|
+
*/
|
|
158
|
+
private getColumnKey;
|
|
159
|
+
/**
|
|
160
|
+
* Builds the detail query (CTE content)
|
|
161
|
+
*/
|
|
162
|
+
private buildDetailQuery;
|
|
163
|
+
/**
|
|
164
|
+
* Builds the aggregation query that references the CTE
|
|
165
|
+
*/
|
|
166
|
+
private buildAggregationQuery;
|
|
167
|
+
/**
|
|
168
|
+
* Transforms an expression to reference CTE columns instead of original table columns
|
|
169
|
+
*/
|
|
170
|
+
private transformExpressionForCTE;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Utility function to analyze a JOIN + aggregation query from SQL string (safe, no exceptions)
|
|
174
|
+
*
|
|
175
|
+
* @param sql The SQL string to parse and analyze
|
|
176
|
+
* @param options Decomposer options
|
|
177
|
+
* @returns Analysis result with success status, error information, and metadata
|
|
178
|
+
*/
|
|
179
|
+
export declare function analyzeJoinAggregation(sql: string, options?: JoinDecomposerOptions): DecompositionAnalysisResult;
|
|
180
|
+
/**
|
|
181
|
+
* Utility function to decompose a JOIN + aggregation query from SQL string
|
|
182
|
+
*
|
|
183
|
+
* @param sql The SQL string to parse and decompose
|
|
184
|
+
* @param options Decomposer options
|
|
185
|
+
* @returns The decomposed query
|
|
186
|
+
* @throws DecompositionError if parsing or decomposition fails
|
|
187
|
+
*/
|
|
188
|
+
export declare function decomposeJoinAggregation(sql: string, options?: JoinDecomposerOptions): SimpleSelectQuery;
|