flowquery 1.0.70 → 1.0.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +456 -103
- package/dist/compute/provenance.d.ts +201 -0
- package/dist/compute/provenance.d.ts.map +1 -0
- package/dist/compute/provenance.js +216 -0
- package/dist/compute/provenance.js.map +1 -0
- package/dist/compute/runner.d.ts +196 -3
- package/dist/compute/runner.d.ts.map +1 -1
- package/dist/compute/runner.js +283 -2
- package/dist/compute/runner.js.map +1 -1
- package/dist/flowquery.min.js +1 -1
- package/dist/graph/bindings.d.ts.map +1 -1
- package/dist/graph/bindings.js +15 -1
- package/dist/graph/bindings.js.map +1 -1
- package/dist/graph/data_cache.d.ts +4 -0
- package/dist/graph/data_cache.d.ts.map +1 -1
- package/dist/graph/data_cache.js +15 -3
- package/dist/graph/data_cache.js.map +1 -1
- package/dist/graph/data_resolver.d.ts.map +1 -1
- package/dist/graph/data_resolver.js +23 -4
- package/dist/graph/data_resolver.js.map +1 -1
- package/dist/graph/physical_node.d.ts +4 -8
- package/dist/graph/physical_node.d.ts.map +1 -1
- package/dist/graph/physical_node.js +14 -85
- package/dist/graph/physical_node.js.map +1 -1
- package/dist/graph/physical_relationship.d.ts +4 -8
- package/dist/graph/physical_relationship.d.ts.map +1 -1
- package/dist/graph/physical_relationship.js +14 -85
- package/dist/graph/physical_relationship.js.map +1 -1
- package/dist/graph/relationship_match_collector.d.ts.map +1 -1
- package/dist/graph/relationship_match_collector.js +9 -0
- package/dist/graph/relationship_match_collector.js.map +1 -1
- package/dist/graph/virtual_sources.d.ts +8 -0
- package/dist/graph/virtual_sources.d.ts.map +1 -0
- package/dist/graph/virtual_sources.js +31 -0
- package/dist/graph/virtual_sources.js.map +1 -0
- package/dist/graph/virtual_statement.d.ts +41 -0
- package/dist/graph/virtual_statement.d.ts.map +1 -0
- package/dist/graph/virtual_statement.js +143 -0
- package/dist/graph/virtual_statement.js.map +1 -0
- package/dist/index.browser.d.ts +3 -3
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.d.ts +3 -3
- package/dist/index.node.d.ts.map +1 -1
- package/dist/index.node.js.map +1 -1
- package/dist/parsing/operations/aggregated_return.d.ts +10 -0
- package/dist/parsing/operations/aggregated_return.d.ts.map +1 -1
- package/dist/parsing/operations/aggregated_return.js +56 -3
- package/dist/parsing/operations/aggregated_return.js.map +1 -1
- package/dist/parsing/operations/aggregated_with.d.ts +20 -0
- package/dist/parsing/operations/aggregated_with.d.ts.map +1 -1
- package/dist/parsing/operations/aggregated_with.js +33 -1
- package/dist/parsing/operations/aggregated_with.js.map +1 -1
- package/dist/parsing/operations/group_by.d.ts +32 -0
- package/dist/parsing/operations/group_by.d.ts.map +1 -1
- package/dist/parsing/operations/group_by.js +103 -0
- package/dist/parsing/operations/group_by.js.map +1 -1
- package/dist/parsing/operations/let.d.ts.map +1 -1
- package/dist/parsing/operations/let.js +53 -0
- package/dist/parsing/operations/let.js.map +1 -1
- package/dist/parsing/operations/load.d.ts +20 -0
- package/dist/parsing/operations/load.d.ts.map +1 -1
- package/dist/parsing/operations/load.js +71 -0
- package/dist/parsing/operations/load.js.map +1 -1
- package/dist/parsing/operations/order_by.d.ts +6 -0
- package/dist/parsing/operations/order_by.d.ts.map +1 -1
- package/dist/parsing/operations/order_by.js +10 -1
- package/dist/parsing/operations/order_by.js.map +1 -1
- package/dist/parsing/operations/return.d.ts +34 -0
- package/dist/parsing/operations/return.d.ts.map +1 -1
- package/dist/parsing/operations/return.js +95 -2
- package/dist/parsing/operations/return.js.map +1 -1
- package/dist/parsing/operations/union.d.ts +19 -2
- package/dist/parsing/operations/union.d.ts.map +1 -1
- package/dist/parsing/operations/union.js +47 -11
- package/dist/parsing/operations/union.js.map +1 -1
- package/dist/parsing/operations/union_all.d.ts +5 -1
- package/dist/parsing/operations/union_all.d.ts.map +1 -1
- package/dist/parsing/operations/union_all.js +8 -2
- package/dist/parsing/operations/union_all.js.map +1 -1
- package/dist/parsing/statement_info_crawler.d.ts +106 -0
- package/dist/parsing/statement_info_crawler.d.ts.map +1 -1
- package/dist/parsing/statement_info_crawler.js +231 -12
- package/dist/parsing/statement_info_crawler.js.map +1 -1
- package/package.json +1 -1
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const provenance_1 = require("../../compute/provenance");
|
|
15
16
|
const projection_1 = __importDefault(require("./projection"));
|
|
16
17
|
/**
|
|
17
18
|
* Represents a RETURN operation that produces the final query results.
|
|
@@ -31,6 +32,9 @@ class Return extends projection_1.default {
|
|
|
31
32
|
this._results = [];
|
|
32
33
|
this._limit = null;
|
|
33
34
|
this._orderBy = null;
|
|
35
|
+
this._provenanceSources = null;
|
|
36
|
+
this._provenanceSink = null;
|
|
37
|
+
this._provenanceRows = [];
|
|
34
38
|
}
|
|
35
39
|
set where(where) {
|
|
36
40
|
this._where = where;
|
|
@@ -47,6 +51,28 @@ class Return extends projection_1.default {
|
|
|
47
51
|
set orderBy(orderBy) {
|
|
48
52
|
this._orderBy = orderBy;
|
|
49
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Direct the runner-owned sink that receives the post-sorted,
|
|
56
|
+
* post-limited provenance rows. Once a sink is registered, every
|
|
57
|
+
* emit captures a snapshot from the registered provenance sources.
|
|
58
|
+
*/
|
|
59
|
+
enableProvenance(sink) {
|
|
60
|
+
this._provenanceSink = sink;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Append a provenance source. Sources are snapshotted per emitted
|
|
64
|
+
* row and their segments are concatenated in registration order.
|
|
65
|
+
* Multiple MATCHes downstream of the last aggregation register their
|
|
66
|
+
* `ProvenanceSites` here; upstream aggregations register themselves
|
|
67
|
+
* as virtual sources that replay the current group's accumulated
|
|
68
|
+
* provenance.
|
|
69
|
+
*/
|
|
70
|
+
addProvenanceSource(source) {
|
|
71
|
+
if (this._provenanceSources === null) {
|
|
72
|
+
this._provenanceSources = [];
|
|
73
|
+
}
|
|
74
|
+
this._provenanceSources.push(source);
|
|
75
|
+
}
|
|
50
76
|
run() {
|
|
51
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
78
|
if (!this.where) {
|
|
@@ -77,25 +103,92 @@ class Return extends projection_1.default {
|
|
|
77
103
|
this._orderBy.captureSortKeys();
|
|
78
104
|
}
|
|
79
105
|
this._results.push(Object.fromEntries(record));
|
|
106
|
+
if (this._provenanceSink !== null) {
|
|
107
|
+
const segment = this._snapshotProvenance();
|
|
108
|
+
// Non-aggregate row: `rows` contains the single input-row segment
|
|
109
|
+
// so the shape stays uniform with aggregate rows.
|
|
110
|
+
const row = {
|
|
111
|
+
nodes: segment.nodes,
|
|
112
|
+
relationships: segment.relationships,
|
|
113
|
+
rows: [segment],
|
|
114
|
+
};
|
|
115
|
+
if (segment.data_sources !== undefined) {
|
|
116
|
+
row.data_sources = segment.data_sources;
|
|
117
|
+
}
|
|
118
|
+
this._provenanceRows.push(row);
|
|
119
|
+
}
|
|
80
120
|
if (this._orderBy === null && this._limit !== null) {
|
|
81
121
|
this._limit.increment();
|
|
82
122
|
}
|
|
83
123
|
});
|
|
84
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Concatenate all registered provenance sources into a single
|
|
127
|
+
* {@link RowSegment}. Called once per emitted row by `run()`, which
|
|
128
|
+
* wraps the result as a `RowProvenance` with `rows: [segment]`.
|
|
129
|
+
*/
|
|
130
|
+
_snapshotProvenance() {
|
|
131
|
+
const merged = { nodes: [], relationships: [] };
|
|
132
|
+
if (this._provenanceSources !== null) {
|
|
133
|
+
for (const src of this._provenanceSources) {
|
|
134
|
+
(0, provenance_1.mergeProvenanceSegment)(merged, src.snapshot());
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return merged;
|
|
138
|
+
}
|
|
85
139
|
initialize() {
|
|
86
140
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
141
|
this._results = [];
|
|
142
|
+
this._provenanceRows = [];
|
|
88
143
|
});
|
|
89
144
|
}
|
|
90
145
|
get results() {
|
|
146
|
+
const { results } = this._buildOutput();
|
|
147
|
+
return results;
|
|
148
|
+
}
|
|
149
|
+
finish() {
|
|
150
|
+
const _super = Object.create(null, {
|
|
151
|
+
finish: { get: () => super.finish }
|
|
152
|
+
});
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
// Materialise final, sort-/limit-aligned provenance into the runner's
|
|
155
|
+
// sink (when enabled) so `Runner.provenance` reads cheaply.
|
|
156
|
+
if (this._provenanceSink !== null) {
|
|
157
|
+
const { provenance } = this._buildOutput();
|
|
158
|
+
this._provenanceSink.length = 0;
|
|
159
|
+
for (const p of provenance)
|
|
160
|
+
this._provenanceSink.push(p);
|
|
161
|
+
}
|
|
162
|
+
yield _super.finish.call(this);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Apply ORDER BY permutation and LIMIT slicing to both the result rows
|
|
167
|
+
* and the parallel provenance array in lockstep. Provenance is
|
|
168
|
+
* computed only when a sink is registered.
|
|
169
|
+
*/
|
|
170
|
+
_buildOutput() {
|
|
91
171
|
let results = this._results;
|
|
172
|
+
let provenance = this._provenanceRows;
|
|
173
|
+
const wantProvenance = this._provenanceSink !== null;
|
|
92
174
|
if (this._orderBy !== null) {
|
|
93
|
-
|
|
175
|
+
const indices = this._orderBy.sortIndices(results);
|
|
176
|
+
results = indices.map((i) => results[i]);
|
|
177
|
+
if (wantProvenance) {
|
|
178
|
+
provenance = indices.map((i) => provenance[i]);
|
|
179
|
+
}
|
|
94
180
|
}
|
|
95
181
|
if (this._orderBy !== null && this._limit !== null) {
|
|
96
182
|
results = results.slice(0, this._limit.limitValue);
|
|
183
|
+
if (wantProvenance) {
|
|
184
|
+
provenance = provenance.slice(0, this._limit.limitValue);
|
|
185
|
+
}
|
|
97
186
|
}
|
|
98
|
-
return results;
|
|
187
|
+
return { results, provenance };
|
|
188
|
+
}
|
|
189
|
+
/** @internal Direct accessor used by UNION to merge child provenance. */
|
|
190
|
+
get provenanceRows() {
|
|
191
|
+
return this._buildOutput().provenance;
|
|
99
192
|
}
|
|
100
193
|
}
|
|
101
194
|
exports.default = Return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"return.js","sourceRoot":"","sources":["../../../src/parsing/operations/return.ts"],"names":[],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"return.js","sourceRoot":"","sources":["../../../src/parsing/operations/return.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,yDAKkC;AAGlC,8DAAsC;AAGtC;;;;;;;;;;GAUG;AACH,MAAM,MAAO,SAAQ,oBAAU;IAA/B;;QACc,WAAM,GAAiB,IAAI,CAAC;QAC5B,aAAQ,GAA0B,EAAE,CAAC;QACvC,WAAM,GAAiB,IAAI,CAAC;QAC1B,aAAQ,GAAmB,IAAI,CAAC;QAChC,uBAAkB,GAA8B,IAAI,CAAC;QACrD,oBAAe,GAA2B,IAAI,CAAC;QAC/C,oBAAe,GAAoB,EAAE,CAAC;IAiJpD,CAAC;IAhJG,IAAW,KAAK,CAAC,KAAY;QACzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IACD,IAAW,KAAK;QACZ,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;IACD,IAAW,KAAK,CAAC,KAAY;QACzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IACD,IAAW,OAAO,CAAC,OAAgB;QAC/B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5B,CAAC;IACD;;;;OAIG;IACI,gB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,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;YACnD,CAAC;QACL,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YACjD,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YACnD,IAAI,cAAc,EAAE,CAAC;gBACjB,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAC7D,CAAC;QACL,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IACnC,CAAC;IACD,yEAAyE;IACzE,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC,UAAU,CAAC;IAC1C,CAAC;CACJ;AAED,kBAAe,MAAM,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RowProvenance } from "../../compute/provenance";
|
|
1
2
|
import Operation from "./operation";
|
|
2
3
|
/**
|
|
3
4
|
* Represents a UNION operation that combines results from two sub-queries.
|
|
@@ -17,17 +18,33 @@ declare class Union extends Operation {
|
|
|
17
18
|
protected _left: Operation | null;
|
|
18
19
|
protected _right: Operation | null;
|
|
19
20
|
protected _results: Record<string, any>[];
|
|
21
|
+
protected _leftProvenance: RowProvenance[] | null;
|
|
22
|
+
protected _rightProvenance: RowProvenance[] | null;
|
|
23
|
+
protected _provenanceSink: RowProvenance[] | null;
|
|
20
24
|
set left(operation: Operation);
|
|
21
25
|
get left(): Operation;
|
|
22
26
|
set right(operation: Operation);
|
|
23
27
|
get right(): Operation;
|
|
28
|
+
/**
|
|
29
|
+
* Wire provenance through this UNION. The Runner attaches each branch
|
|
30
|
+
* to its own sink array; `sink` is the merged output array aligned with
|
|
31
|
+
* `_results`.
|
|
32
|
+
*/
|
|
33
|
+
enableProvenance(leftSink: RowProvenance[], rightSink: RowProvenance[], sink: RowProvenance[]): void;
|
|
24
34
|
private lastInChain;
|
|
25
35
|
initialize(): Promise<void>;
|
|
26
36
|
run(): Promise<void>;
|
|
27
37
|
/**
|
|
28
|
-
* Combines results from left and right pipelines
|
|
29
|
-
*
|
|
38
|
+
* Combines results from left and right pipelines and returns both the
|
|
39
|
+
* merged rows and the merged provenance array (when enabled). UNION
|
|
40
|
+
* drops duplicates (first occurrence wins); subclass UnionAll overrides
|
|
41
|
+
* to keep all rows.
|
|
30
42
|
*/
|
|
43
|
+
protected combineWithProvenance(left: Record<string, any>[], right: Record<string, any>[]): {
|
|
44
|
+
rows: Record<string, any>[];
|
|
45
|
+
provenance: RowProvenance[];
|
|
46
|
+
};
|
|
47
|
+
/** Kept for backwards compatibility with subclasses that override only combine(). */
|
|
31
48
|
protected combine(left: Record<string, any>[], right: Record<string, any>[]): Record<string, any>[];
|
|
32
49
|
finish(): Promise<void>;
|
|
33
50
|
get results(): Record<string, any>[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union.d.ts","sourceRoot":"","sources":["../../../src/parsing/operations/union.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC;;;;;;;;;;;;;GAaG;AACH,cAAM,KAAM,SAAQ,SAAS;IACzB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAQ;IACzC,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAAQ;IAC1C,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAM;
|
|
1
|
+
{"version":3,"file":"union.d.ts","sourceRoot":"","sources":["../../../src/parsing/operations/union.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,SAAS,MAAM,aAAa,CAAC;AAE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C3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAC7B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE;IAIX,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIpC,IAAW,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAE1C;CACJ;AAED,eAAe,KAAK,CAAC"}
|
|
@@ -33,6 +33,9 @@ class Union extends operation_1.default {
|
|
|
33
33
|
this._left = null;
|
|
34
34
|
this._right = null;
|
|
35
35
|
this._results = [];
|
|
36
|
+
this._leftProvenance = null;
|
|
37
|
+
this._rightProvenance = null;
|
|
38
|
+
this._provenanceSink = null;
|
|
36
39
|
}
|
|
37
40
|
set left(operation) {
|
|
38
41
|
this._left = operation;
|
|
@@ -52,6 +55,16 @@ class Union extends operation_1.default {
|
|
|
52
55
|
}
|
|
53
56
|
return this._right;
|
|
54
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Wire provenance through this UNION. The Runner attaches each branch
|
|
60
|
+
* to its own sink array; `sink` is the merged output array aligned with
|
|
61
|
+
* `_results`.
|
|
62
|
+
*/
|
|
63
|
+
enableProvenance(leftSink, rightSink, sink) {
|
|
64
|
+
this._leftProvenance = leftSink;
|
|
65
|
+
this._rightProvenance = rightSink;
|
|
66
|
+
this._provenanceSink = sink;
|
|
67
|
+
}
|
|
55
68
|
lastInChain(operation) {
|
|
56
69
|
let current = operation;
|
|
57
70
|
while (current.next) {
|
|
@@ -88,24 +101,47 @@ class Union extends operation_1.default {
|
|
|
88
101
|
throw new Error("All sub queries in a UNION must have the same return column names");
|
|
89
102
|
}
|
|
90
103
|
}
|
|
91
|
-
// Combine results
|
|
92
|
-
|
|
104
|
+
// Combine results (and provenance when enabled)
|
|
105
|
+
const { rows, provenance } = this.combineWithProvenance(leftResults, rightResults);
|
|
106
|
+
this._results = rows;
|
|
107
|
+
if (this._provenanceSink !== null) {
|
|
108
|
+
this._provenanceSink.length = 0;
|
|
109
|
+
for (const p of provenance)
|
|
110
|
+
this._provenanceSink.push(p);
|
|
111
|
+
}
|
|
93
112
|
});
|
|
94
113
|
}
|
|
95
114
|
/**
|
|
96
|
-
* Combines results from left and right pipelines
|
|
97
|
-
*
|
|
115
|
+
* Combines results from left and right pipelines and returns both the
|
|
116
|
+
* merged rows and the merged provenance array (when enabled). UNION
|
|
117
|
+
* drops duplicates (first occurrence wins); subclass UnionAll overrides
|
|
118
|
+
* to keep all rows.
|
|
98
119
|
*/
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
|
|
120
|
+
combineWithProvenance(left, right) {
|
|
121
|
+
const leftProv = this._leftProvenance;
|
|
122
|
+
const rightProv = this._rightProvenance;
|
|
123
|
+
const wantProv = this._provenanceSink !== null;
|
|
124
|
+
const rows = [...left];
|
|
125
|
+
const provenance = wantProv && leftProv !== null ? [...leftProv] : [];
|
|
126
|
+
const serializedSeen = new Set();
|
|
127
|
+
for (const row of left)
|
|
128
|
+
serializedSeen.add(JSON.stringify(row));
|
|
129
|
+
for (let i = 0; i < right.length; i++) {
|
|
130
|
+
const row = right[i];
|
|
102
131
|
const serialized = JSON.stringify(row);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
132
|
+
if (!serializedSeen.has(serialized)) {
|
|
133
|
+
rows.push(row);
|
|
134
|
+
if (wantProv && rightProv !== null) {
|
|
135
|
+
provenance.push(rightProv[i]);
|
|
136
|
+
}
|
|
137
|
+
serializedSeen.add(serialized);
|
|
106
138
|
}
|
|
107
139
|
}
|
|
108
|
-
return
|
|
140
|
+
return { rows, provenance };
|
|
141
|
+
}
|
|
142
|
+
/** Kept for backwards compatibility with subclasses that override only combine(). */
|
|
143
|
+
combine(left, right) {
|
|
144
|
+
return this.combineWithProvenance(left, right).rows;
|
|
109
145
|
}
|
|
110
146
|
finish() {
|
|
111
147
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union.js","sourceRoot":"","sources":["../../../src/parsing/operations/union.ts"],"names":[],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"union.js","sourceRoot":"","sources":["../../../src/parsing/operations/union.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,4DAAoC;AAEpC;;;;;;;;;;;;;GAaG;AACH,MAAM,KAAM,SAAQ,mBAAS;IAA7B;;QACc,UAAK,GAAqB,IAAI,CAAC;QAC/B,WAAM,GAAqB,IAAI,CAAC;QAChC,aAAQ,GAA0B,EAAE,CAAC;QACrC,oBAAe,GAA2B,IAAI,CAAC;QAC/C,qBAAgB,GAA2B,IAAI,CAAC;QAChD,oBAAe,GAA2B,IAAI,CAAC;IAkI7D,CAAC;IAhIG,IAAW,IAAI,CAAC,SAAoB;QAChC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IAC3B,CAAC;IACD,IAAW,IAAI;QACX,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IACD,IAAW,KAAK,CAAC,SAAoB;QACjC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC5B,CAAC;IACD,IAAW,KAAK;QACZ,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAClD,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACI,gBAAgB,CACnB,QAAyB,EACzB,SAA0B,EAC1B,IAAqB;QAErB,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAC;QAChC,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;QAClC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;IAChC,CAAC;IAEO,WAAW,CAAC,SAAoB;QACpC,IAAI,OAAO,GAAG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AAE,CAAC,EAAE,EAAE,CAAC;YACpC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACrB,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACvC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;gBAClC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACf,IAAI,QAAQ,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;oBACjC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;gBAClC,CAAC;gBACD,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACnC,CAAC;QACL,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAChC,CAAC;IAED,qFAAqF;IAC3E,OAAO,CACb,IAA2B,EAC3B,KAA4B;QAE5B,OAAO,IAAI,CAAC,qBAAqB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC;IACxD,CAAC;IAEY,MAAM;;;YACf,MAAM,CAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,MAAM,EAAE,CAAA,CAAC;QAC9B,CAAC;KAAA;IAED,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;CACJ;AAED,kBAAe,KAAK,CAAC"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { RowProvenance } from "../../compute/provenance";
|
|
1
2
|
import Union from "./union";
|
|
2
3
|
/**
|
|
3
4
|
* Represents a UNION ALL operation that concatenates results from two sub-queries
|
|
4
5
|
* without removing duplicates.
|
|
5
6
|
*/
|
|
6
7
|
declare class UnionAll extends Union {
|
|
7
|
-
protected
|
|
8
|
+
protected combineWithProvenance(left: Record<string, any>[], right: Record<string, any>[]): {
|
|
9
|
+
rows: Record<string, any>[];
|
|
10
|
+
provenance: RowProvenance[];
|
|
11
|
+
};
|
|
8
12
|
}
|
|
9
13
|
export default UnionAll;
|
|
10
14
|
//# sourceMappingURL=union_all.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union_all.d.ts","sourceRoot":"","sources":["../../../src/parsing/operations/union_all.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B;;;GAGG;AACH,cAAM,QAAS,SAAQ,KAAK;IACxB,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"union_all.d.ts","sourceRoot":"","sources":["../../../src/parsing/operations/union_all.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B;;;GAGG;AACH,cAAM,QAAS,SAAQ,KAAK;IACxB,SAAS,CAAC,qBAAqB,CAC3B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,EAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAC7B;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;QAAC,UAAU,EAAE,aAAa,EAAE,CAAA;KAAE;CASlE;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -9,8 +9,14 @@ const union_1 = __importDefault(require("./union"));
|
|
|
9
9
|
* without removing duplicates.
|
|
10
10
|
*/
|
|
11
11
|
class UnionAll extends union_1.default {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
combineWithProvenance(left, right) {
|
|
13
|
+
const wantProv = this._provenanceSink !== null;
|
|
14
|
+
const leftProv = this._leftProvenance;
|
|
15
|
+
const rightProv = this._rightProvenance;
|
|
16
|
+
const provenance = wantProv
|
|
17
|
+
? [...(leftProv !== null && leftProv !== void 0 ? leftProv : []), ...(rightProv !== null && rightProv !== void 0 ? rightProv : [])]
|
|
18
|
+
: [];
|
|
19
|
+
return { rows: [...left, ...right], provenance };
|
|
14
20
|
}
|
|
15
21
|
}
|
|
16
22
|
exports.default = UnionAll;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union_all.js","sourceRoot":"","sources":["../../../src/parsing/operations/union_all.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"union_all.js","sourceRoot":"","sources":["../../../src/parsing/operations/union_all.ts"],"names":[],"mappings":";;;;;AACA,oDAA4B;AAE5B;;;GAGG;AACH,MAAM,QAAS,SAAQ,eAAK;IACd,qBAAqB,CAC3B,IAA2B,EAC3B,KAA4B;QAE5B,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,KAAK,IAAI,CAAC;QAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC;QACtC,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC;QACxC,MAAM,UAAU,GAAoB,QAAQ;YACxC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC,EAAE,GAAG,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAC,CAAC;YAC7C,CAAC,CAAC,EAAE,CAAC;QACT,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrD,CAAC;CACJ;AAED,kBAAe,QAAQ,CAAC"}
|
|
@@ -42,6 +42,52 @@ export interface DeclaredEntityInfo {
|
|
|
42
42
|
properties: string[];
|
|
43
43
|
sources: string[];
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* A single `alias.property` access that contributes to an output column.
|
|
47
|
+
*/
|
|
48
|
+
export interface ColumnReference {
|
|
49
|
+
/** The binding name as written in the query (e.g. `'c'` in `c.name`). */
|
|
50
|
+
alias: string;
|
|
51
|
+
/** Whether the binding is a node or a relationship. */
|
|
52
|
+
kind: "node" | "relationship";
|
|
53
|
+
/**
|
|
54
|
+
* Node labels (when `kind === 'node'`) or relationship types (when
|
|
55
|
+
* `kind === 'relationship'`). Multi-label intersection matches
|
|
56
|
+
* surface every label.
|
|
57
|
+
*/
|
|
58
|
+
labels: string[];
|
|
59
|
+
/** The property name read off the binding (e.g. `'name'` in `c.name`). */
|
|
60
|
+
property: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Per-output-column lineage. Bridges the AST-level access list with the
|
|
64
|
+
* runtime row provenance: for each column the runner emits, this tells
|
|
65
|
+
* you which `alias.property` reads went into it and how they were
|
|
66
|
+
* combined.
|
|
67
|
+
*/
|
|
68
|
+
export interface ColumnLineage {
|
|
69
|
+
/**
|
|
70
|
+
* Every distinct `alias.property` access reachable from the column's
|
|
71
|
+
* expression tree. Deduplicated by `(alias, property)`.
|
|
72
|
+
*
|
|
73
|
+
* Empty when the column is a pure literal or an aggregate that takes
|
|
74
|
+
* no `alias.property` arguments (e.g. `count(c) AS n` references the
|
|
75
|
+
* binding `c` but no specific property).
|
|
76
|
+
*/
|
|
77
|
+
references: ColumnReference[];
|
|
78
|
+
/**
|
|
79
|
+
* - `'literal'` — the column is a literal expression with no bindings.
|
|
80
|
+
* - `'property'` — a single direct `alias.property` access (or a
|
|
81
|
+
* pass-through projection of one).
|
|
82
|
+
* - `'expression'` — a computed expression over one or more
|
|
83
|
+
* `alias.property` accesses.
|
|
84
|
+
* - `'aggregate'` — contains an aggregate function (`count`, `sum`,
|
|
85
|
+
* `collect`, …).
|
|
86
|
+
*/
|
|
87
|
+
kind: "literal" | "property" | "expression" | "aggregate";
|
|
88
|
+
/** When `kind === 'aggregate'`: the function name (e.g. `'count'`). */
|
|
89
|
+
aggregate?: string;
|
|
90
|
+
}
|
|
45
91
|
/**
|
|
46
92
|
* Structural information extracted from a parsed FlowQuery statement.
|
|
47
93
|
*
|
|
@@ -105,6 +151,18 @@ export interface StatementInfo {
|
|
|
105
151
|
nodes: Record<string, DeclaredEntityInfo>;
|
|
106
152
|
relationships: Record<string, DeclaredEntityInfo>;
|
|
107
153
|
};
|
|
154
|
+
/**
|
|
155
|
+
* Per-output-column lineage for the final `RETURN` clause. Maps each
|
|
156
|
+
* result column name to the `alias.property` accesses that compose
|
|
157
|
+
* it. Empty (`{}`) when the statement has no `RETURN` (e.g. pure
|
|
158
|
+
* CREATE / DELETE statements).
|
|
159
|
+
*
|
|
160
|
+
* Combine with {@link Runner.provenance} to trace a result-row cell
|
|
161
|
+
* back to its source node / relationship id, the matched property
|
|
162
|
+
* value, and the originating virtual sub-query (all available when
|
|
163
|
+
* the runner is constructed with `{ provenance: true }`).
|
|
164
|
+
*/
|
|
165
|
+
returns: Record<string, ColumnLineage>;
|
|
108
166
|
}
|
|
109
167
|
/**
|
|
110
168
|
* Walks one or more parsed FlowQuery statement ASTs and extracts a
|
|
@@ -137,6 +195,12 @@ declare class StatementInfoCrawler {
|
|
|
137
195
|
private _relDeclaredSources;
|
|
138
196
|
private _ownCreatedNodeLabels;
|
|
139
197
|
private _ownCreatedRelTypes;
|
|
198
|
+
/**
|
|
199
|
+
* Per-output-column lineage of the most recently visited `RETURN`
|
|
200
|
+
* clause. Overwritten each time a `Return` op is visited so the
|
|
201
|
+
* last RETURN wins (matching the user-visible result shape).
|
|
202
|
+
*/
|
|
203
|
+
private _returns;
|
|
140
204
|
/**
|
|
141
205
|
* For each inline CREATE VIRTUAL clause, the (label or type) it
|
|
142
206
|
* declares and its inner statement AST. The label key receives the
|
|
@@ -144,6 +208,14 @@ declare class StatementInfoCrawler {
|
|
|
144
208
|
*/
|
|
145
209
|
private _ownNodeCreates;
|
|
146
210
|
private _ownRelCreates;
|
|
211
|
+
/**
|
|
212
|
+
* Map of `LET name = { ... }` binding name to the data sources its
|
|
213
|
+
* sub-query right-hand side touches. Used to follow a downstream
|
|
214
|
+
* `LOAD JSON FROM name` reference back to the original URL / file /
|
|
215
|
+
* async-function name when both the LET and the consuming statement
|
|
216
|
+
* are crawled together.
|
|
217
|
+
*/
|
|
218
|
+
private _letSources;
|
|
147
219
|
/**
|
|
148
220
|
* Walks one or more statement ASTs and returns the merged structural info.
|
|
149
221
|
*
|
|
@@ -153,6 +225,14 @@ declare class StatementInfoCrawler {
|
|
|
153
225
|
crawl(statements: ASTNode | Iterable<ASTNode>): StatementInfo;
|
|
154
226
|
private toIterable;
|
|
155
227
|
private reset;
|
|
228
|
+
/**
|
|
229
|
+
* Pre-pass over a statement to record, for each `LET name = { ... }`
|
|
230
|
+
* with a sub-query right-hand side, the data sources its sub-query
|
|
231
|
+
* touches. Stored in `_letSources` so a downstream
|
|
232
|
+
* `LOAD JSON FROM name` consumer can union those sources into the
|
|
233
|
+
* consuming statement's per-label / per-type source set.
|
|
234
|
+
*/
|
|
235
|
+
private collectLetSources;
|
|
156
236
|
private crawlStatement;
|
|
157
237
|
private visitOperation;
|
|
158
238
|
private resolveRegisteredDefinitions;
|
|
@@ -165,6 +245,30 @@ declare class StatementInfoCrawler {
|
|
|
165
245
|
* RETURN-style operations.
|
|
166
246
|
*/
|
|
167
247
|
private collectPropertyAccesses;
|
|
248
|
+
/**
|
|
249
|
+
* Builds the per-column lineage map of a single `RETURN` clause.
|
|
250
|
+
* Mirrors {@link Projection.expressions}'s default-aliasing rule so
|
|
251
|
+
* unnamed columns are keyed `expr0`, `expr1`, ….
|
|
252
|
+
*/
|
|
253
|
+
private collectReturnColumns;
|
|
254
|
+
/**
|
|
255
|
+
* Walks an output-column expression and returns the contributing
|
|
256
|
+
* `alias.property` accesses plus a `kind` summarising how they were
|
|
257
|
+
* combined (`literal` / `property` / `expression` / `aggregate`).
|
|
258
|
+
*/
|
|
259
|
+
private lineageOfExpression;
|
|
260
|
+
/**
|
|
261
|
+
* Returns the user-written identifier of a `Lookup`'s variable side
|
|
262
|
+
* (e.g. `'c'` in `c.name`), or `null` if the variable isn't a plain
|
|
263
|
+
* `Reference` to a named binding.
|
|
264
|
+
*/
|
|
265
|
+
private aliasOfLookup;
|
|
266
|
+
/**
|
|
267
|
+
* True iff the expression is a direct `alias.property` projection
|
|
268
|
+
* (possibly wrapped in a single-child pass-through `Expression`),
|
|
269
|
+
* with no operators, functions, or additional references.
|
|
270
|
+
*/
|
|
271
|
+
private isSimplePropertyProjection;
|
|
168
272
|
private handleLookupAccess;
|
|
169
273
|
/**
|
|
170
274
|
* Resolves a `Lookup` of the shape `alias.prop` to the labels/types
|
|
@@ -237,6 +341,8 @@ declare class StatementInfoCrawler {
|
|
|
237
341
|
* Returns a deep copy of a StatementInfo so callers can mutate it freely.
|
|
238
342
|
*/
|
|
239
343
|
static clone(info: StatementInfo): StatementInfo;
|
|
344
|
+
private cloneReturns;
|
|
345
|
+
private static cloneReturnsStatic;
|
|
240
346
|
}
|
|
241
347
|
export default StatementInfoCrawler;
|
|
242
348
|
//# sourceMappingURL=statement_info_crawler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statement_info_crawler.d.ts","sourceRoot":"","sources":["../../src/parsing/statement_info_crawler.ts"],"names":[],"mappings":"AAIA,OAAO,OAAO,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"statement_info_crawler.d.ts","sourceRoot":"","sources":["../../src/parsing/statement_info_crawler.ts"],"names":[],"mappings":"AAIA,OAAO,OAAO,MAAM,YAAY,CAAC;AA0BjC;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACrB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;CAC1C;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC7B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,2EAA2E;IAC3E,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;CAC1C;AAED;;;;GAIG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