@malloydata/malloy 0.0.61-dev230720062204 → 0.0.61-dev230724132807
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/lang/ast/elements/pipeline-desc.d.ts +12 -7
- package/dist/lang/ast/elements/pipeline-desc.js +65 -20
- package/dist/lang/ast/elements/refined-source.js +5 -5
- package/dist/lang/ast/expressions/expr-aggregate-function.js +2 -4
- package/dist/lang/ast/field-space/column-space-field.d.ts +1 -1
- package/dist/lang/ast/field-space/column-space-field.js +1 -1
- package/dist/lang/ast/field-space/dynamic-space.d.ts +2 -3
- package/dist/lang/ast/field-space/dynamic-space.js +6 -2
- package/dist/lang/ast/field-space/index-field-space.d.ts +2 -3
- package/dist/lang/ast/field-space/index-field-space.js +15 -6
- package/dist/lang/ast/field-space/query-input-space.d.ts +28 -0
- package/dist/lang/ast/field-space/query-input-space.js +47 -0
- package/dist/lang/ast/field-space/query-space-field.d.ts +1 -1
- package/dist/lang/ast/field-space/query-space-field.js +1 -1
- package/dist/lang/ast/field-space/query-spaces.d.ts +13 -33
- package/dist/lang/ast/field-space/query-spaces.js +30 -99
- package/dist/lang/ast/field-space/reference-field.d.ts +7 -3
- package/dist/lang/ast/field-space/reference-field.js +22 -11
- package/dist/lang/ast/field-space/refined-space.d.ts +2 -2
- package/dist/lang/ast/field-space/refined-space.js +6 -44
- package/dist/lang/ast/field-space/rename-space-field.d.ts +1 -1
- package/dist/lang/ast/field-space/rename-space-field.js +1 -1
- package/dist/lang/ast/field-space/struct-space-field-base.d.ts +1 -1
- package/dist/lang/ast/field-space/struct-space-field-base.js +1 -1
- package/dist/lang/ast/field-space/wild-space-field.d.ts +1 -1
- package/dist/lang/ast/field-space/wild-space-field.js +1 -1
- package/dist/lang/ast/index.d.ts +3 -2
- package/dist/lang/ast/index.js +3 -2
- package/dist/lang/ast/{executors/index-executor.d.ts → query-builders/index-builder.d.ts} +4 -3
- package/dist/lang/ast/{executors/index-executor.js → query-builders/index-builder.js} +7 -6
- package/dist/lang/ast/{executors/project-executor.d.ts → query-builders/project-builder.d.ts} +3 -2
- package/dist/lang/ast/{executors/project-executor.js → query-builders/project-builder.js} +10 -14
- package/dist/lang/ast/{executors/reduce-executor.d.ts → query-builders/reduce-builder.d.ts} +5 -3
- package/dist/lang/ast/{executors/reduce-executor.js → query-builders/reduce-builder.js} +15 -40
- package/dist/lang/ast/query-elements/existing-query.d.ts +1 -0
- package/dist/lang/ast/query-elements/existing-query.js +6 -2
- package/dist/lang/ast/query-elements/full-query.d.ts +2 -1
- package/dist/lang/ast/query-elements/full-query.js +12 -9
- package/dist/lang/ast/query-items/field-declaration.d.ts +18 -3
- package/dist/lang/ast/query-items/field-declaration.js +45 -1
- package/dist/lang/ast/query-items/field-references.d.ts +5 -2
- package/dist/lang/ast/query-items/field-references.js +12 -0
- package/dist/lang/ast/query-properties/aggregate.d.ts +4 -1
- package/dist/lang/ast/query-properties/aggregate.js +3 -0
- package/dist/lang/ast/query-properties/calculate.d.ts +4 -1
- package/dist/lang/ast/query-properties/calculate.js +3 -0
- package/dist/lang/ast/query-properties/declare-fields.d.ts +6 -1
- package/dist/lang/ast/query-properties/declare-fields.js +8 -0
- package/dist/lang/ast/query-properties/extend.d.ts +6 -1
- package/dist/lang/ast/query-properties/extend.js +10 -0
- package/dist/lang/ast/query-properties/filters.d.ts +5 -2
- package/dist/lang/ast/query-properties/filters.js +12 -5
- package/dist/lang/ast/query-properties/group-by.d.ts +4 -1
- package/dist/lang/ast/query-properties/group-by.js +3 -0
- package/dist/lang/ast/query-properties/indexing.d.ts +4 -1
- package/dist/lang/ast/query-properties/indexing.js +3 -0
- package/dist/lang/ast/query-properties/joins.d.ts +10 -2
- package/dist/lang/ast/query-properties/joins.js +13 -0
- package/dist/lang/ast/query-properties/limit.d.ts +4 -1
- package/dist/lang/ast/query-properties/limit.js +3 -0
- package/dist/lang/ast/query-properties/nest.d.ts +34 -6
- package/dist/lang/ast/query-properties/nest.js +87 -16
- package/dist/lang/ast/query-properties/nests.d.ts +5 -2
- package/dist/lang/ast/query-properties/nests.js +3 -0
- package/dist/lang/ast/query-properties/ordering.d.ts +4 -1
- package/dist/lang/ast/query-properties/ordering.js +3 -0
- package/dist/lang/ast/query-properties/project-statement.d.ts +6 -1
- package/dist/lang/ast/query-properties/project-statement.js +8 -0
- package/dist/lang/ast/query-properties/qop-desc.d.ts +6 -7
- package/dist/lang/ast/query-properties/qop-desc.js +35 -59
- package/dist/lang/ast/query-properties/sampling.d.ts +4 -1
- package/dist/lang/ast/query-properties/sampling.js +3 -0
- package/dist/lang/ast/query-properties/top.d.ts +4 -1
- package/dist/lang/ast/query-properties/top.js +3 -0
- package/dist/lang/ast/source-properties/renames.d.ts +4 -1
- package/dist/lang/ast/source-properties/renames.js +20 -0
- package/dist/lang/ast/source-properties/timezone-statement.d.ts +6 -1
- package/dist/lang/ast/source-properties/timezone-statement.js +5 -0
- package/dist/lang/ast/types/annotation-elements.d.ts +16 -0
- package/dist/lang/ast/types/annotation-elements.js +61 -0
- package/dist/lang/ast/types/field-space.d.ts +1 -0
- package/dist/lang/ast/types/malloy-element.d.ts +0 -11
- package/dist/lang/ast/types/malloy-element.js +1 -32
- package/dist/lang/ast/types/{executor.d.ts → query-builder.d.ts} +4 -2
- package/dist/lang/ast/types/{executor.js → query-builder.js} +1 -1
- package/dist/lang/ast/types/query-item.d.ts +1 -2
- package/dist/lang/ast/types/query-property-interface.d.ts +23 -0
- package/dist/lang/{parse-error-handler.js → ast/types/query-property-interface.js} +21 -21
- package/dist/lang/ast/types/query-property.d.ts +3 -18
- package/dist/lang/ast/types/query-property.js +1 -34
- package/dist/lang/ast/types/source-property.d.ts +2 -1
- package/dist/lang/ast/types/source-property.js +2 -2
- package/dist/lang/ast/types/space-entry.d.ts +14 -1
- package/dist/lang/ast/types/space-entry.js +18 -1
- package/dist/lang/ast/types/space-param.d.ts +2 -2
- package/dist/lang/ast/types/space-param.js +2 -2
- package/dist/lang/ast/types/turtle-headed-pipe.d.ts +1 -7
- package/dist/lang/ast/types/turtle-headed-pipe.js +2 -11
- package/dist/lang/malloy-parse-info.d.ts +11 -0
- package/dist/lang/{ast/types/nested-query.js → malloy-parse-info.js} +1 -1
- package/dist/lang/malloy-to-ast.d.ts +3 -3
- package/dist/lang/malloy-to-ast.js +11 -11
- package/dist/lang/parse-malloy.d.ts +10 -11
- package/dist/lang/parse-malloy.js +24 -5
- package/dist/lang/test/parse.spec.js +79 -60
- package/dist/lang/test/refine.spec.d.ts +1 -0
- package/dist/lang/test/refine.spec.js +112 -0
- package/package.json +1 -1
- package/dist/lang/ast/field-space/field-definition-value.d.ts +0 -16
- package/dist/lang/ast/field-space/field-definition-value.js +0 -61
- package/dist/lang/ast/query-properties/nest-reference.d.ts +0 -9
- package/dist/lang/ast/query-properties/nest-reference.js +0 -58
- package/dist/lang/ast/types/nested-query.d.ts +0 -3
- package/dist/lang/parse-error-handler.d.ts +0 -9
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Annotation, DocumentLocation, PipeSegment, Pipeline, StructDef } from '../../../model/malloy_types';
|
|
2
|
-
import { FieldSpace } from '../types/field-space';
|
|
2
|
+
import { FieldName, FieldSpace } from '../types/field-space';
|
|
3
3
|
import { MalloyElement } from '../types/malloy-element';
|
|
4
4
|
import { QOPDesc } from '../query-properties/qop-desc';
|
|
5
|
-
import { QueryInputSpace } from '../field-space/query-
|
|
5
|
+
import { QueryInputSpace } from '../field-space/query-input-space';
|
|
6
6
|
interface AppendResult {
|
|
7
7
|
opList: PipeSegment[];
|
|
8
8
|
structDef: StructDef;
|
|
@@ -13,19 +13,24 @@ interface AppendResult {
|
|
|
13
13
|
* is refers to the first segment of the composed pipeline.
|
|
14
14
|
*/
|
|
15
15
|
export declare abstract class PipelineDesc extends MalloyElement {
|
|
16
|
-
|
|
17
|
-
protected headRefinement?: QOPDesc;
|
|
16
|
+
protected withRefinement?: QOPDesc;
|
|
18
17
|
protected qops: QOPDesc[];
|
|
19
18
|
nestedInQuerySpace?: QueryInputSpace;
|
|
20
|
-
|
|
19
|
+
refineWith(refinement: QOPDesc): void;
|
|
21
20
|
addSegments(...segDesc: QOPDesc[]): void;
|
|
22
|
-
protected appendOps(modelPipe: PipeSegment[]
|
|
21
|
+
protected appendOps(pipelineOutput: FieldSpace, modelPipe: PipeSegment[]): AppendResult;
|
|
22
|
+
private refineSegment;
|
|
23
23
|
protected refinePipeline(fs: FieldSpace, modelPipe: Pipeline): Pipeline;
|
|
24
24
|
protected expandTurtle(turtleName: string, fromStruct: StructDef): {
|
|
25
25
|
pipeline: PipeSegment[];
|
|
26
26
|
location: DocumentLocation | undefined;
|
|
27
27
|
annotation: Annotation | undefined;
|
|
28
28
|
};
|
|
29
|
-
protected
|
|
29
|
+
protected getFinalStruct(walkStruct: StructDef, pipeline: PipeSegment[]): StructDef;
|
|
30
|
+
}
|
|
31
|
+
export declare abstract class TurtleHeadedPipe extends PipelineDesc {
|
|
32
|
+
_turtleName?: FieldName;
|
|
33
|
+
set turtleName(turtleName: FieldName | undefined);
|
|
34
|
+
get turtleName(): FieldName | undefined;
|
|
30
35
|
}
|
|
31
36
|
export {};
|
|
@@ -22,9 +22,12 @@
|
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.PipelineDesc = void 0;
|
|
25
|
+
exports.TurtleHeadedPipe = exports.PipelineDesc = void 0;
|
|
26
26
|
const malloy_element_1 = require("../types/malloy-element");
|
|
27
|
+
const qop_desc_1 = require("../query-properties/qop-desc");
|
|
27
28
|
const struct_utils_1 = require("../struct-utils");
|
|
29
|
+
const query_property_interface_1 = require("../types/query-property-interface");
|
|
30
|
+
const static_space_1 = require("../field-space/static-space");
|
|
28
31
|
/**
|
|
29
32
|
* Generic abstract for all pipelines, the first segment might be a reference
|
|
30
33
|
* to an existing pipeline (query or turtle), and if there is a refinement it
|
|
@@ -33,49 +36,81 @@ const struct_utils_1 = require("../struct-utils");
|
|
|
33
36
|
class PipelineDesc extends malloy_element_1.MalloyElement {
|
|
34
37
|
constructor() {
|
|
35
38
|
super(...arguments);
|
|
36
|
-
this.elementType = 'pipelineDesc';
|
|
37
39
|
this.qops = [];
|
|
38
40
|
}
|
|
39
|
-
|
|
40
|
-
this.
|
|
41
|
-
this.has({
|
|
41
|
+
refineWith(refinement) {
|
|
42
|
+
this.withRefinement = refinement;
|
|
43
|
+
this.has({ withRefinement: refinement });
|
|
42
44
|
}
|
|
43
45
|
addSegments(...segDesc) {
|
|
44
46
|
this.qops.push(...segDesc);
|
|
45
47
|
this.has({ segments: this.qops });
|
|
46
48
|
}
|
|
47
|
-
appendOps(
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
appendOps(pipelineOutput, modelPipe) {
|
|
50
|
+
const returnPipe = [...modelPipe];
|
|
51
|
+
const nestedIn = modelPipe.length === 0 ? this.nestedInQuerySpace : undefined;
|
|
52
|
+
let nextFS = pipelineOutput;
|
|
50
53
|
for (const qop of this.qops) {
|
|
51
|
-
const
|
|
52
|
-
const next = qop.getOp(nextFS, qopIsNested ? this : null);
|
|
53
|
-
if (returnPipe === undefined) {
|
|
54
|
-
returnPipe = [...modelPipe];
|
|
55
|
-
}
|
|
54
|
+
const next = qop.getOp(nextFS, nestedIn);
|
|
56
55
|
returnPipe.push(next.segment);
|
|
57
56
|
nextFS = next.outputSpace();
|
|
58
57
|
}
|
|
59
58
|
return {
|
|
60
|
-
opList: returnPipe
|
|
59
|
+
opList: returnPipe,
|
|
61
60
|
structDef: nextFS.structDef(),
|
|
62
61
|
};
|
|
63
62
|
}
|
|
63
|
+
refineSegment(fs, refinement, seg) {
|
|
64
|
+
refinement.refineFrom(seg);
|
|
65
|
+
return refinement.getOp(fs, this.nestedInQuerySpace).segment;
|
|
66
|
+
}
|
|
64
67
|
refinePipeline(fs, modelPipe) {
|
|
65
|
-
if (!this.
|
|
68
|
+
if (!this.withRefinement) {
|
|
66
69
|
return modelPipe;
|
|
67
70
|
}
|
|
68
|
-
|
|
71
|
+
let pipeline = [];
|
|
69
72
|
if (modelPipe.pipeHead) {
|
|
70
73
|
const { pipeline: turtlePipe } = this.expandTurtle(modelPipe.pipeHead.name, fs.structDef());
|
|
71
74
|
pipeline.push(...turtlePipe);
|
|
72
75
|
}
|
|
73
76
|
pipeline.push(...modelPipe.pipeline);
|
|
74
77
|
const firstSeg = pipeline[0];
|
|
75
|
-
if (
|
|
76
|
-
|
|
78
|
+
if (pipeline.length === 1) {
|
|
79
|
+
// I could let everything fall through to the head/tail case, it should be the
|
|
80
|
+
// same, but this does less computation and is the most common case.
|
|
81
|
+
pipeline = [this.refineSegment(fs, this.withRefinement, firstSeg)];
|
|
82
|
+
this.withRefinement = undefined;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
const headRefinements = new qop_desc_1.QOPDesc([]);
|
|
86
|
+
const tailRefinements = new qop_desc_1.QOPDesc([]);
|
|
87
|
+
for (const qop of this.withRefinement.list) {
|
|
88
|
+
switch (qop.queryRefinementStage) {
|
|
89
|
+
case query_property_interface_1.LegalRefinementStage.Head:
|
|
90
|
+
headRefinements.push(qop);
|
|
91
|
+
break;
|
|
92
|
+
case query_property_interface_1.LegalRefinementStage.Single:
|
|
93
|
+
qop.log('Illegal in refinement of a query with more than one stage');
|
|
94
|
+
break;
|
|
95
|
+
case query_property_interface_1.LegalRefinementStage.Tail:
|
|
96
|
+
tailRefinements.push(qop);
|
|
97
|
+
break;
|
|
98
|
+
default:
|
|
99
|
+
qop.log('Illegal query refinement');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (headRefinements.notEmpty()) {
|
|
103
|
+
this.has({ headRefinements });
|
|
104
|
+
pipeline[0] = this.refineSegment(fs, headRefinements, firstSeg);
|
|
105
|
+
}
|
|
106
|
+
if (tailRefinements.notEmpty()) {
|
|
107
|
+
const last = pipeline.length - 1;
|
|
108
|
+
this.has({ tailRefinements });
|
|
109
|
+
const finalIn = this.getFinalStruct(fs.structDef(), pipeline.slice(-1));
|
|
110
|
+
pipeline[last] = this.refineSegment(new static_space_1.StaticSpace(finalIn), tailRefinements, pipeline[last]);
|
|
111
|
+
}
|
|
77
112
|
}
|
|
78
|
-
|
|
113
|
+
this.withRefinement = undefined;
|
|
79
114
|
return { pipeline };
|
|
80
115
|
}
|
|
81
116
|
expandTurtle(turtleName, fromStruct) {
|
|
@@ -95,7 +130,7 @@ class PipelineDesc extends malloy_element_1.MalloyElement {
|
|
|
95
130
|
}
|
|
96
131
|
return { pipeline: [], location: undefined, annotation };
|
|
97
132
|
}
|
|
98
|
-
|
|
133
|
+
getFinalStruct(walkStruct, pipeline) {
|
|
99
134
|
for (const modelQop of pipeline) {
|
|
100
135
|
walkStruct = (0, struct_utils_1.opOutputStruct)(this, walkStruct, modelQop);
|
|
101
136
|
}
|
|
@@ -103,4 +138,14 @@ class PipelineDesc extends malloy_element_1.MalloyElement {
|
|
|
103
138
|
}
|
|
104
139
|
}
|
|
105
140
|
exports.PipelineDesc = PipelineDesc;
|
|
141
|
+
class TurtleHeadedPipe extends PipelineDesc {
|
|
142
|
+
set turtleName(turtleName) {
|
|
143
|
+
this._turtleName = turtleName;
|
|
144
|
+
this.has({ turtleName: turtleName });
|
|
145
|
+
}
|
|
146
|
+
get turtleName() {
|
|
147
|
+
return this._turtleName;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.TurtleHeadedPipe = TurtleHeadedPipe;
|
|
106
151
|
//# sourceMappingURL=pipeline-desc.js.map
|
|
@@ -34,11 +34,11 @@ const filters_1 = require("../query-properties/filters");
|
|
|
34
34
|
const joins_1 = require("../query-properties/joins");
|
|
35
35
|
const field_list_edit_1 = require("../source-properties/field-list-edit");
|
|
36
36
|
const primary_key_1 = require("../source-properties/primary-key");
|
|
37
|
-
const renames_1 = require("../source-properties/renames");
|
|
38
37
|
const turtles_1 = require("../source-properties/turtles");
|
|
39
38
|
const source_1 = require("./source");
|
|
40
39
|
const timezone_statement_1 = require("../source-properties/timezone-statement");
|
|
41
|
-
const
|
|
40
|
+
const annotation_elements_1 = require("../types/annotation-elements");
|
|
41
|
+
const renames_1 = require("../source-properties/renames");
|
|
42
42
|
/**
|
|
43
43
|
* A Source made from a source reference and a set of refinements
|
|
44
44
|
*/
|
|
@@ -59,8 +59,8 @@ class RefinedSource extends source_1.Source {
|
|
|
59
59
|
const filters = [];
|
|
60
60
|
let newTimezone;
|
|
61
61
|
for (const el of this.refinement.list) {
|
|
62
|
-
if (el instanceof
|
|
63
|
-
//
|
|
62
|
+
if (el instanceof annotation_elements_1.ObjectAnnotation) {
|
|
63
|
+
// Treat lone annotations as comments
|
|
64
64
|
continue;
|
|
65
65
|
}
|
|
66
66
|
const errTo = el;
|
|
@@ -102,7 +102,7 @@ class RefinedSource extends source_1.Source {
|
|
|
102
102
|
if (newTimezone) {
|
|
103
103
|
fs.setTimezone(newTimezone);
|
|
104
104
|
}
|
|
105
|
-
fs.
|
|
105
|
+
fs.pushFields(...fields);
|
|
106
106
|
if (pList) {
|
|
107
107
|
fs.addParameters(pList);
|
|
108
108
|
}
|
|
@@ -25,7 +25,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
25
25
|
exports.ExprAggregateFunction = void 0;
|
|
26
26
|
const malloy_types_1 = require("../../../model/malloy_types");
|
|
27
27
|
const ast_utils_1 = require("../ast-utils");
|
|
28
|
-
const query_spaces_1 = require("../field-space/query-spaces");
|
|
29
28
|
const reference_field_1 = require("../field-space/reference-field");
|
|
30
29
|
const struct_space_field_base_1 = require("../field-space/struct-space-field-base");
|
|
31
30
|
const fragtype_utils_1 = require("../fragtype-utils");
|
|
@@ -71,9 +70,8 @@ class ExprAggregateFunction extends expression_def_1.ExpressionDef {
|
|
|
71
70
|
};
|
|
72
71
|
// If you reference an output field as the foot, then we need to get the
|
|
73
72
|
// source from that field, rather than using the default source.
|
|
74
|
-
if (sourceFoot instanceof
|
|
75
|
-
|
|
76
|
-
structPath = sourceFoot.inputSpaceEntry.fieldRef.sourceString;
|
|
73
|
+
if (sourceFoot.outputField && sourceFoot instanceof reference_field_1.ReferenceField) {
|
|
74
|
+
structPath = sourceFoot.fieldRef.sourceString;
|
|
77
75
|
}
|
|
78
76
|
else {
|
|
79
77
|
structPath = this.source.sourceString;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as model from '../../../model/malloy_types';
|
|
2
2
|
import { SpaceEntry } from '../types/space-entry';
|
|
3
|
-
import { FieldSpace } from '../types/field-space';
|
|
4
3
|
import { HasParameter } from '../parameters/has-parameter';
|
|
5
4
|
import { MalloyElement } from '../types/malloy-element';
|
|
6
5
|
import { SourceSpec, SpaceSeed } from '../space-seed';
|
|
@@ -8,7 +7,6 @@ import { StaticSpace } from './static-space';
|
|
|
8
7
|
export declare abstract class DynamicSpace extends StaticSpace {
|
|
9
8
|
protected final: model.StructDef | undefined;
|
|
10
9
|
protected source: SpaceSeed;
|
|
11
|
-
outputFS?: FieldSpace;
|
|
12
10
|
completions: (() => void)[];
|
|
13
11
|
private complete;
|
|
14
12
|
protected newTimezone?: string;
|
|
@@ -17,7 +15,8 @@ export declare abstract class DynamicSpace extends StaticSpace {
|
|
|
17
15
|
isComplete(): void;
|
|
18
16
|
protected setEntry(name: string, value: SpaceEntry): void;
|
|
19
17
|
addParameters(params: HasParameter[]): DynamicSpace;
|
|
20
|
-
newEntry(name: string,
|
|
18
|
+
newEntry(name: string, logTo: MalloyElement, entry: SpaceEntry): void;
|
|
19
|
+
renameEntry(oldName: string, newName: string, entry: SpaceEntry): void;
|
|
21
20
|
addFieldDef(fd: model.FieldDef): void;
|
|
22
21
|
setTimezone(tz: string): void;
|
|
23
22
|
structDef(): model.StructDef;
|
|
@@ -72,13 +72,17 @@ class DynamicSpace extends static_space_1.StaticSpace {
|
|
|
72
72
|
}
|
|
73
73
|
return this;
|
|
74
74
|
}
|
|
75
|
-
newEntry(name,
|
|
75
|
+
newEntry(name, logTo, entry) {
|
|
76
76
|
if (this.entry(name)) {
|
|
77
|
-
|
|
77
|
+
logTo.log(`Cannot redefine '${name}'`);
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
80
|
this.setEntry(name, entry);
|
|
81
81
|
}
|
|
82
|
+
renameEntry(oldName, newName, entry) {
|
|
83
|
+
this.dropEntry(oldName);
|
|
84
|
+
this.setEntry(newName, entry);
|
|
85
|
+
}
|
|
82
86
|
addFieldDef(fd) {
|
|
83
87
|
this.setEntry((0, field_utils_1.nameOf)(fd), this.defToSpaceField(fd));
|
|
84
88
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { IndexSegment, PipeSegment } from '../../../model/malloy_types';
|
|
2
|
-
import {
|
|
2
|
+
import { MalloyElement } from '../types/malloy-element';
|
|
3
3
|
import { QuerySpace } from './query-spaces';
|
|
4
4
|
export declare class IndexFieldSpace extends QuerySpace {
|
|
5
5
|
readonly segmentType = "index";
|
|
6
6
|
fieldList: Set<string>;
|
|
7
|
-
|
|
8
|
-
addWild(wild: WildcardFieldReference): void;
|
|
7
|
+
pushFields(...defs: MalloyElement[]): void;
|
|
9
8
|
getPipeSegment(refineIndex?: PipeSegment): IndexSegment;
|
|
10
9
|
}
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.IndexFieldSpace = void 0;
|
|
26
|
+
const field_references_1 = require("../query-items/field-references");
|
|
26
27
|
const query_spaces_1 = require("./query-spaces");
|
|
27
28
|
class IndexFieldSpace extends query_spaces_1.QuerySpace {
|
|
28
29
|
constructor() {
|
|
@@ -30,14 +31,22 @@ class IndexFieldSpace extends query_spaces_1.QuerySpace {
|
|
|
30
31
|
this.segmentType = 'index';
|
|
31
32
|
this.fieldList = new Set();
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
pushFields(...defs) {
|
|
35
|
+
for (const indexField of defs) {
|
|
36
|
+
if (indexField instanceof field_references_1.FieldReference) {
|
|
37
|
+
if (indexField.getField(this.inputSpace()).found) {
|
|
38
|
+
this.fieldList.add(indexField.refString);
|
|
39
|
+
}
|
|
40
|
+
// mtoy TODO else error ???
|
|
41
|
+
}
|
|
42
|
+
else if (indexField instanceof field_references_1.WildcardFieldReference) {
|
|
43
|
+
this.fieldList.add(indexField.refString);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
indexField.log('Internal error, not expected in index query');
|
|
47
|
+
}
|
|
36
48
|
}
|
|
37
49
|
}
|
|
38
|
-
addWild(wild) {
|
|
39
|
-
this.fieldList.add(wild.refString);
|
|
40
|
-
}
|
|
41
50
|
getPipeSegment(refineIndex) {
|
|
42
51
|
if (refineIndex && refineIndex.fields) {
|
|
43
52
|
for (const exists of refineIndex.fields) {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unlike a source, which is a refinement of a namespace, a query
|
|
3
|
+
* is creating a new unrelated namespace. The query starts with a
|
|
4
|
+
* source, which it might modify. This set of fields used to resolve
|
|
5
|
+
* expressions in the query is called the "input space". There is a
|
|
6
|
+
* specialized QuerySpace for each type of query operation.
|
|
7
|
+
*/
|
|
8
|
+
import { FieldDeclaration } from '../query-items/field-declaration';
|
|
9
|
+
import { Join } from '../query-properties/joins';
|
|
10
|
+
import { SourceSpec } from '../space-seed';
|
|
11
|
+
import { FieldSpace, QueryFieldSpace } from '../types/field-space';
|
|
12
|
+
import { RefinedSpace } from './refined-space';
|
|
13
|
+
export declare class QueryInputSpace extends RefinedSpace implements QueryFieldSpace {
|
|
14
|
+
private queryOutput;
|
|
15
|
+
nestParent?: QueryInputSpace;
|
|
16
|
+
extendList: string[];
|
|
17
|
+
/**
|
|
18
|
+
* Because of circularity concerns this constructor is not typed
|
|
19
|
+
* properly ...
|
|
20
|
+
* @param input The source which might be extended
|
|
21
|
+
* @param queryOutput MUST BE A QuerySpace
|
|
22
|
+
*/
|
|
23
|
+
constructor(input: SourceSpec, queryOutput: FieldSpace);
|
|
24
|
+
extendSource(extendField: Join | FieldDeclaration): void;
|
|
25
|
+
isQueryFieldSpace(): boolean;
|
|
26
|
+
outputSpace(): FieldSpace;
|
|
27
|
+
inputSpace(): this;
|
|
28
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Unlike a source, which is a refinement of a namespace, a query
|
|
4
|
+
* is creating a new unrelated namespace. The query starts with a
|
|
5
|
+
* source, which it might modify. This set of fields used to resolve
|
|
6
|
+
* expressions in the query is called the "input space". There is a
|
|
7
|
+
* specialized QuerySpace for each type of query operation.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.QueryInputSpace = void 0;
|
|
11
|
+
const joins_1 = require("../query-properties/joins");
|
|
12
|
+
const space_seed_1 = require("../space-seed");
|
|
13
|
+
const refined_space_1 = require("./refined-space");
|
|
14
|
+
class QueryInputSpace extends refined_space_1.RefinedSpace {
|
|
15
|
+
/**
|
|
16
|
+
* Because of circularity concerns this constructor is not typed
|
|
17
|
+
* properly ...
|
|
18
|
+
* @param input The source which might be extended
|
|
19
|
+
* @param queryOutput MUST BE A QuerySpace
|
|
20
|
+
*/
|
|
21
|
+
constructor(input, queryOutput) {
|
|
22
|
+
const inputSpace = new space_seed_1.SpaceSeed(input);
|
|
23
|
+
super(inputSpace.structDef);
|
|
24
|
+
this.queryOutput = queryOutput;
|
|
25
|
+
this.extendList = [];
|
|
26
|
+
}
|
|
27
|
+
extendSource(extendField) {
|
|
28
|
+
this.pushFields(extendField);
|
|
29
|
+
if (extendField instanceof joins_1.Join) {
|
|
30
|
+
this.extendList.push(extendField.name.refString);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
this.extendList.push(extendField.defineName);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
isQueryFieldSpace() {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
outputSpace() {
|
|
40
|
+
return this.queryOutput;
|
|
41
|
+
}
|
|
42
|
+
inputSpace() {
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.QueryInputSpace = QueryInputSpace;
|
|
47
|
+
//# sourceMappingURL=query-input-space.js.map
|
|
@@ -1,42 +1,28 @@
|
|
|
1
1
|
import * as model from '../../../model/malloy_types';
|
|
2
|
-
import {
|
|
3
|
-
import { FieldName, FieldSpace } from '../types/field-space';
|
|
2
|
+
import { FieldName, FieldSpace, QueryFieldSpace } from '../types/field-space';
|
|
4
3
|
import { MalloyElement } from '../types/malloy-element';
|
|
5
|
-
import {
|
|
6
|
-
import { SourceSpec } from '../space-seed';
|
|
7
|
-
import { FieldReference, WildcardFieldReference } from '../query-items/field-references';
|
|
8
|
-
import { FieldCollectionMember } from '../types/field-collection-member';
|
|
9
|
-
import { QueryItem } from '../types/query-item';
|
|
4
|
+
import { WildcardFieldReference } from '../query-items/field-references';
|
|
10
5
|
import { RefinedSpace } from './refined-space';
|
|
11
6
|
import { LookupResult } from '../types/lookup-result';
|
|
7
|
+
import { QueryInputSpace } from './query-input-space';
|
|
12
8
|
import { SpaceEntry } from '../types/space-entry';
|
|
13
9
|
/**
|
|
14
|
-
*
|
|
15
|
-
* is
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* specialized QuerySpace for each type of query operation.
|
|
10
|
+
* The output space of a query operation, it is not named "QueryOutputSpace"
|
|
11
|
+
* because this is the namespace of the Query. This is the one which is constructed
|
|
12
|
+
* with the query. The QueryInputSpace is created and paired when a
|
|
13
|
+
* QuerySpace is created.
|
|
19
14
|
*/
|
|
20
|
-
export declare class
|
|
21
|
-
readonly result: QuerySpace;
|
|
22
|
-
nestParent?: QueryInputSpace;
|
|
23
|
-
extendList: string[];
|
|
24
|
-
constructor(input: SourceSpec, result: QuerySpace);
|
|
25
|
-
extendSource(extendField: Join | FieldDeclaration): void;
|
|
26
|
-
isQueryFieldSpace(): boolean;
|
|
27
|
-
outputSpace(): QuerySpace;
|
|
28
|
-
}
|
|
29
|
-
export declare abstract class QuerySpace extends RefinedSpace {
|
|
15
|
+
export declare abstract class QuerySpace extends RefinedSpace implements QueryFieldSpace {
|
|
30
16
|
readonly queryInputSpace: FieldSpace;
|
|
31
|
-
|
|
17
|
+
private exprSpace;
|
|
32
18
|
astEl?: MalloyElement | undefined;
|
|
33
19
|
abstract readonly segmentType: 'reduce' | 'project' | 'index';
|
|
34
20
|
constructor(queryInputSpace: FieldSpace, refineThis: model.PipeSegment | undefined);
|
|
35
21
|
private addRefineFromFields;
|
|
36
22
|
log(s: string): void;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
addWild(wild: WildcardFieldReference): void;
|
|
23
|
+
pushFields(...defs: MalloyElement[]): void;
|
|
24
|
+
setEntry(name: string, value: SpaceEntry): void;
|
|
25
|
+
protected addWild(wild: WildcardFieldReference): void;
|
|
40
26
|
/**
|
|
41
27
|
* Check for the definition of an ungrouping reference in the result space,
|
|
42
28
|
* or in the case of an exclude reference, if this query is nested
|
|
@@ -44,7 +30,6 @@ export declare abstract class QuerySpace extends RefinedSpace {
|
|
|
44
30
|
* is nested inside of.
|
|
45
31
|
*/
|
|
46
32
|
checkUngroup(fn: FieldName, isExclude: boolean): void;
|
|
47
|
-
addQueryItems(...qiList: QueryItem[]): void;
|
|
48
33
|
canContain(_typeDesc: model.TypeDesc): boolean;
|
|
49
34
|
protected queryFieldDefs(): model.QueryFieldDef[];
|
|
50
35
|
getQuerySegment(rf: model.QuerySegment | undefined): model.QuerySegment;
|
|
@@ -52,13 +37,8 @@ export declare abstract class QuerySpace extends RefinedSpace {
|
|
|
52
37
|
lookup(path: FieldName[]): LookupResult;
|
|
53
38
|
isQueryFieldSpace(): boolean;
|
|
54
39
|
outputSpace(): this;
|
|
40
|
+
inputSpace(): QueryInputSpace;
|
|
55
41
|
}
|
|
56
42
|
export declare class ReduceFieldSpace extends QuerySpace {
|
|
57
43
|
readonly segmentType = "reduce";
|
|
58
44
|
}
|
|
59
|
-
export declare class OutputSpaceEntry extends SpaceEntry {
|
|
60
|
-
readonly inputSpaceEntry: SpaceEntry;
|
|
61
|
-
refType: 'field' | 'parameter';
|
|
62
|
-
constructor(inputSpaceEntry: SpaceEntry);
|
|
63
|
-
typeDesc(): model.TypeDesc;
|
|
64
|
-
}
|