@malloydata/malloy 0.0.88-dev231002231014 → 0.0.88-dev231003001139
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/dialect/dialect_map.js +1 -0
- package/dist/dialect/functions/util.d.ts +1 -0
- package/dist/lang/ast/elements/define-query.d.ts +3 -3
- package/dist/lang/ast/elements/define-query.js +9 -4
- package/dist/lang/ast/elements/define-source.d.ts +3 -3
- package/dist/lang/ast/elements/define-source.js +12 -4
- package/dist/lang/ast/elements/pipeline-desc.d.ts +1 -0
- package/dist/lang/ast/elements/pipeline-desc.js +3 -0
- package/dist/lang/ast/elements/source-query-nodes.d.ts +72 -0
- package/dist/lang/ast/elements/source-query-nodes.js +368 -0
- package/dist/lang/ast/elements/source-query.d.ts +11 -0
- package/dist/lang/ast/{query-elements/run-query.js → elements/source-query.js} +32 -21
- package/dist/lang/ast/index.d.ts +2 -2
- package/dist/lang/ast/index.js +2 -2
- package/dist/lang/ast/query-elements/anonymous-query.d.ts +3 -3
- package/dist/lang/ast/query-elements/anonymous-query.js +15 -8
- package/dist/lang/ast/query-elements/existing-query.js +1 -1
- package/dist/lang/ast/query-items/field-references.d.ts +4 -0
- package/dist/lang/ast/query-items/field-references.js +11 -1
- package/dist/lang/ast/query-items/typecheck_utils.js +5 -5
- package/dist/lang/ast/query-properties/joins.d.ts +7 -5
- package/dist/lang/ast/query-properties/joins.js +22 -8
- package/dist/lang/ast/sources/sql-source.js +5 -0
- package/dist/lang/ast/sql-elements/sql-string.d.ts +2 -2
- package/dist/lang/ast/sql-elements/sql-string.js +19 -9
- package/dist/lang/ast/types/malloy-element.d.ts +3 -1
- package/dist/lang/ast/types/malloy-element.js +16 -5
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +179 -184
- package/dist/lang/lib/Malloy/MalloyParser.js +3141 -2928
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +147 -199
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +88 -120
- package/dist/lang/malloy-to-ast.d.ts +16 -15
- package/dist/lang/malloy-to-ast.js +147 -141
- package/dist/lang/parse-tree-walkers/document-symbol-walker.js +1 -1
- package/dist/lang/parse-utils.js +2 -2
- package/dist/lang/test/annotation.spec.js +35 -46
- package/dist/lang/test/document-symbol-walker.spec.js +2 -2
- package/dist/lang/test/expressions.spec.js +16 -16
- package/dist/lang/test/imports.spec.js +10 -8
- package/dist/lang/test/literals.spec.js +4 -4
- package/dist/lang/test/locations.spec.js +82 -80
- package/dist/lang/test/parse-expects.js +5 -1
- package/dist/lang/test/parse.spec.js +173 -117
- package/dist/lang/test/query.spec.js +199 -203
- package/dist/lang/test/source.spec.js +54 -45
- package/dist/lang/test/sql-block.spec.js +19 -12
- package/dist/lang/test/test-translator.js +8 -5
- package/dist/malloy.js +2 -2
- package/dist/model/malloy_query.js +3 -0
- package/dist/model/malloy_types.d.ts +1 -0
- package/package.json +1 -2
- package/dist/lang/ast/query-elements/run-query.d.ts +0 -13
- package/dist/lang/ast/sources/named-source-or-query.d.ts +0 -10
- package/dist/lang/ast/sources/named-source-or-query.js +0 -71
package/dist/lang/ast/index.js
CHANGED
|
@@ -41,6 +41,8 @@ __exportStar(require("./elements/define-source"), exports);
|
|
|
41
41
|
__exportStar(require("./elements/define-query"), exports);
|
|
42
42
|
__exportStar(require("./elements/source"), exports);
|
|
43
43
|
__exportStar(require("./elements/refined-source"), exports);
|
|
44
|
+
__exportStar(require("./elements/source-query"), exports);
|
|
45
|
+
__exportStar(require("./elements/source-query-nodes"), exports);
|
|
44
46
|
__exportStar(require("./source-properties/field-list-edit"), exports);
|
|
45
47
|
__exportStar(require("./source-properties/primary-key"), exports);
|
|
46
48
|
__exportStar(require("./source-properties/renames"), exports);
|
|
@@ -91,7 +93,6 @@ __exportStar(require("./elements/import-statement"), exports);
|
|
|
91
93
|
__exportStar(require("./query-properties/extend"), exports);
|
|
92
94
|
__exportStar(require("./parameters/has-parameter"), exports);
|
|
93
95
|
__exportStar(require("./query-elements/anonymous-query"), exports);
|
|
94
|
-
__exportStar(require("./query-elements/run-query"), exports);
|
|
95
96
|
__exportStar(require("./query-elements/existing-query"), exports);
|
|
96
97
|
__exportStar(require("./query-elements/full-query"), exports);
|
|
97
98
|
__exportStar(require("./query-items/field-declaration"), exports);
|
|
@@ -115,7 +116,6 @@ __exportStar(require("./query-properties/qop-desc"), exports);
|
|
|
115
116
|
__exportStar(require("./query-properties/sampling"), exports);
|
|
116
117
|
__exportStar(require("./query-properties/top"), exports);
|
|
117
118
|
__exportStar(require("./sources/named-source"), exports);
|
|
118
|
-
__exportStar(require("./sources/named-source-or-query"), exports);
|
|
119
119
|
__exportStar(require("./sources/query-source"), exports);
|
|
120
120
|
__exportStar(require("./sources/from-sql-source"), exports);
|
|
121
121
|
__exportStar(require("./sources/sql-source"), exports);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Annotation } from '../../../model';
|
|
2
2
|
import { DocStatement, Document, MalloyElement } from '../types/malloy-element';
|
|
3
|
-
import { QueryElement } from '../types/query-element';
|
|
4
3
|
import { Noteable, extendNoteMethod } from '../types/noteable';
|
|
4
|
+
import { SourceQueryNode } from '../elements/source-query';
|
|
5
5
|
export declare class AnonymousQuery extends MalloyElement implements DocStatement, Noteable {
|
|
6
|
-
readonly
|
|
6
|
+
readonly queryExpr: SourceQueryNode;
|
|
7
7
|
elementType: string;
|
|
8
|
-
constructor(
|
|
8
|
+
constructor(queryExpr: SourceQueryNode);
|
|
9
9
|
readonly isNoteableObj = true;
|
|
10
10
|
extendNote: typeof extendNoteMethod;
|
|
11
11
|
note?: Annotation;
|
|
@@ -26,20 +26,27 @@ exports.AnonymousQuery = void 0;
|
|
|
26
26
|
const malloy_element_1 = require("../types/malloy-element");
|
|
27
27
|
const noteable_1 = require("../types/noteable");
|
|
28
28
|
class AnonymousQuery extends malloy_element_1.MalloyElement {
|
|
29
|
-
constructor(
|
|
29
|
+
constructor(queryExpr) {
|
|
30
30
|
super();
|
|
31
|
-
this.
|
|
31
|
+
this.queryExpr = queryExpr;
|
|
32
32
|
this.elementType = 'anonymousQuery';
|
|
33
33
|
this.isNoteableObj = true;
|
|
34
34
|
this.extendNote = noteable_1.extendNoteMethod;
|
|
35
|
-
this.has({
|
|
35
|
+
this.has({ queryExpr });
|
|
36
36
|
}
|
|
37
37
|
execute(doc) {
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
const queryObj = this.queryExpr.getQuery();
|
|
39
|
+
if (!queryObj) {
|
|
40
|
+
this.queryExpr.sqLog('Cannot run this object as a query');
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const modelQuery = { ...queryObj.query() };
|
|
44
|
+
const annotation = this.note || {};
|
|
45
|
+
if (modelQuery.annotation) {
|
|
46
|
+
annotation.inherits = modelQuery.annotation;
|
|
47
|
+
}
|
|
48
|
+
if (annotation.notes || annotation.blockNotes || annotation.inherits) {
|
|
49
|
+
modelQuery.annotation = annotation;
|
|
43
50
|
}
|
|
44
51
|
doc.queryList.push(modelQuery);
|
|
45
52
|
}
|
|
@@ -30,7 +30,7 @@ const query_head_struct_1 = require("./query-head-struct");
|
|
|
30
30
|
class ExistingQuery extends pipeline_desc_1.PipelineDesc {
|
|
31
31
|
constructor() {
|
|
32
32
|
super(...arguments);
|
|
33
|
-
this.elementType = '
|
|
33
|
+
this.elementType = 'exisitingQuery';
|
|
34
34
|
}
|
|
35
35
|
set head(head) {
|
|
36
36
|
this._head = head;
|
|
@@ -60,6 +60,10 @@ export declare class DimensionFieldReference extends FieldReference {
|
|
|
60
60
|
elementType: string;
|
|
61
61
|
typecheck(type: TypeDesc): void;
|
|
62
62
|
}
|
|
63
|
+
export declare class ViewFieldReference extends FieldReference {
|
|
64
|
+
elementType: string;
|
|
65
|
+
typecheck(_type: TypeDesc): void;
|
|
66
|
+
}
|
|
63
67
|
export declare class WildcardFieldReference extends MalloyElement implements Noteable {
|
|
64
68
|
readonly joinPath: FieldReference | undefined;
|
|
65
69
|
elementType: string;
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.FieldReferences = exports.WildcardFieldReference = exports.DimensionFieldReference = exports.MeasureFieldReference = exports.DeclareFieldReference = exports.ProjectFieldReference = exports.GroupByFieldReference = exports.AggregateFieldReference = exports.IndexFieldReference = exports.CalculateFieldReference = exports.ExpressionFieldReference = exports.AcceptExceptFieldReference = exports.FieldReference = void 0;
|
|
25
|
+
exports.FieldReferences = exports.WildcardFieldReference = exports.ViewFieldReference = exports.DimensionFieldReference = exports.MeasureFieldReference = exports.DeclareFieldReference = exports.ProjectFieldReference = exports.GroupByFieldReference = exports.AggregateFieldReference = exports.IndexFieldReference = exports.CalculateFieldReference = exports.ExpressionFieldReference = exports.AcceptExceptFieldReference = exports.FieldReference = void 0;
|
|
26
26
|
const reference_field_1 = require("../field-space/reference-field");
|
|
27
27
|
const definition_list_1 = require("../types/definition-list");
|
|
28
28
|
const malloy_element_1 = require("../types/malloy-element");
|
|
@@ -176,6 +176,16 @@ class DimensionFieldReference extends FieldReference {
|
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
exports.DimensionFieldReference = DimensionFieldReference;
|
|
179
|
+
class ViewFieldReference extends FieldReference {
|
|
180
|
+
constructor() {
|
|
181
|
+
super(...arguments);
|
|
182
|
+
this.elementType = 'viewFieldRefernce';
|
|
183
|
+
}
|
|
184
|
+
typecheck(_type) {
|
|
185
|
+
this.log('Cannot use a view field in an expression');
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
exports.ViewFieldReference = ViewFieldReference;
|
|
179
189
|
class WildcardFieldReference extends malloy_element_1.MalloyElement {
|
|
180
190
|
constructor(joinPath) {
|
|
181
191
|
super();
|
|
@@ -30,7 +30,7 @@ function typecheckProject(type, logTo) {
|
|
|
30
30
|
let kind;
|
|
31
31
|
if (type.dataType === 'turtle') {
|
|
32
32
|
useInstead = 'a nest';
|
|
33
|
-
kind = 'a
|
|
33
|
+
kind = 'a view';
|
|
34
34
|
}
|
|
35
35
|
else if ((0, model_1.expressionIsAnalytic)(type.expressionType)) {
|
|
36
36
|
useInstead = 'a calculate';
|
|
@@ -51,7 +51,7 @@ function typecheckIndex(type, logTo) {
|
|
|
51
51
|
if (type.dataType === 'turtle' || !(0, model_1.expressionIsScalar)(type.expressionType)) {
|
|
52
52
|
let kind;
|
|
53
53
|
if (type.dataType === 'turtle') {
|
|
54
|
-
kind = 'a
|
|
54
|
+
kind = 'a view';
|
|
55
55
|
}
|
|
56
56
|
else if ((0, model_1.expressionIsAnalytic)(type.expressionType)) {
|
|
57
57
|
kind = 'an analytic';
|
|
@@ -110,7 +110,7 @@ function typecheckCalculate(type, logTo) {
|
|
|
110
110
|
let kind;
|
|
111
111
|
if (type.dataType === 'turtle') {
|
|
112
112
|
useInstead = 'a nest';
|
|
113
|
-
kind = 'a
|
|
113
|
+
kind = 'a view';
|
|
114
114
|
}
|
|
115
115
|
else if ((0, model_1.expressionIsAggregate)(type.expressionType)) {
|
|
116
116
|
useInstead = 'an aggregate';
|
|
@@ -134,7 +134,7 @@ function typecheckAggregate(type, logTo) {
|
|
|
134
134
|
let kind;
|
|
135
135
|
if (type.dataType === 'turtle') {
|
|
136
136
|
useInstead = 'a nest';
|
|
137
|
-
kind = 'a
|
|
137
|
+
kind = 'a view';
|
|
138
138
|
}
|
|
139
139
|
else if ((0, model_1.expressionIsAnalytic)(type.expressionType)) {
|
|
140
140
|
useInstead = 'a calculate';
|
|
@@ -157,7 +157,7 @@ function typecheckGroupBy(type, logTo) {
|
|
|
157
157
|
let kind;
|
|
158
158
|
if (type.dataType === 'turtle') {
|
|
159
159
|
useInstead = 'a nest';
|
|
160
|
-
kind = 'a
|
|
160
|
+
kind = 'a view';
|
|
161
161
|
}
|
|
162
162
|
else if ((0, model_1.expressionIsAnalytic)(type.expressionType)) {
|
|
163
163
|
useInstead = 'a calculate';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Annotation, Expr, StructDef } from '../../../model/malloy_types';
|
|
2
|
-
import { Source } from '../elements/source';
|
|
3
2
|
import { DynamicSpace } from '../field-space/dynamic-space';
|
|
4
3
|
import { DefinitionList } from '../types/definition-list';
|
|
5
4
|
import { QueryBuilder } from '../types/query-builder';
|
|
@@ -9,32 +8,35 @@ import { MalloyElement, ModelEntryReference } from '../types/malloy-element';
|
|
|
9
8
|
import { extendNoteMethod, Noteable } from '../types/noteable';
|
|
10
9
|
import { LegalRefinementStage, QueryPropertyInterface } from '../types/query-property-interface';
|
|
11
10
|
import { MakeEntry } from '../types/space-entry';
|
|
11
|
+
import { SourceQueryNode } from '../elements/source-query';
|
|
12
12
|
export declare abstract class Join extends MalloyElement implements Noteable, MakeEntry {
|
|
13
13
|
abstract name: ModelEntryReference;
|
|
14
14
|
abstract structDef(): StructDef;
|
|
15
15
|
abstract fixupJoinOn(outer: FieldSpace, inStruct: StructDef): void;
|
|
16
16
|
readonly isNoteableObj = true;
|
|
17
17
|
extendNote: typeof extendNoteMethod;
|
|
18
|
+
abstract sourceExpr: SourceQueryNode;
|
|
18
19
|
note?: Annotation;
|
|
19
20
|
makeEntry(fs: DynamicSpace): void;
|
|
21
|
+
protected getStructDefFromExpr(): StructDef;
|
|
20
22
|
}
|
|
21
23
|
export declare class KeyJoin extends Join {
|
|
22
24
|
readonly name: ModelEntryReference;
|
|
23
|
-
readonly
|
|
25
|
+
readonly sourceExpr: SourceQueryNode;
|
|
24
26
|
readonly keyExpr: ExpressionDef;
|
|
25
27
|
elementType: string;
|
|
26
|
-
constructor(name: ModelEntryReference,
|
|
28
|
+
constructor(name: ModelEntryReference, sourceExpr: SourceQueryNode, keyExpr: ExpressionDef);
|
|
27
29
|
structDef(): StructDef;
|
|
28
30
|
fixupJoinOn(outer: FieldSpace, inStruct: StructDef): void;
|
|
29
31
|
}
|
|
30
32
|
type ExpressionJoinType = 'many' | 'one' | 'cross';
|
|
31
33
|
export declare class ExpressionJoin extends Join {
|
|
32
34
|
readonly name: ModelEntryReference;
|
|
33
|
-
readonly
|
|
35
|
+
readonly sourceExpr: SourceQueryNode;
|
|
34
36
|
elementType: string;
|
|
35
37
|
joinType: ExpressionJoinType;
|
|
36
38
|
private expr?;
|
|
37
|
-
constructor(name: ModelEntryReference,
|
|
39
|
+
constructor(name: ModelEntryReference, sourceExpr: SourceQueryNode);
|
|
38
40
|
set joinOn(joinExpr: ExpressionDef | undefined);
|
|
39
41
|
get joinOn(): ExpressionDef | undefined;
|
|
40
42
|
fixupJoinOn(outer: FieldSpace, inStruct: StructDef): Expr | undefined;
|
|
@@ -30,6 +30,7 @@ const definition_list_1 = require("../types/definition-list");
|
|
|
30
30
|
const malloy_element_1 = require("../types/malloy-element");
|
|
31
31
|
const noteable_1 = require("../types/noteable");
|
|
32
32
|
const query_property_interface_1 = require("../types/query-property-interface");
|
|
33
|
+
const error_factory_1 = require("../error-factory");
|
|
33
34
|
class Join extends malloy_element_1.MalloyElement {
|
|
34
35
|
constructor() {
|
|
35
36
|
super(...arguments);
|
|
@@ -39,19 +40,27 @@ class Join extends malloy_element_1.MalloyElement {
|
|
|
39
40
|
makeEntry(fs) {
|
|
40
41
|
fs.newEntry(this.name.refString, this, new join_space_field_1.JoinSpaceField(fs, this));
|
|
41
42
|
}
|
|
43
|
+
getStructDefFromExpr() {
|
|
44
|
+
const source = this.sourceExpr.getSource();
|
|
45
|
+
if (!source) {
|
|
46
|
+
this.sourceExpr.sqLog('Cannot great a source to join from');
|
|
47
|
+
return error_factory_1.ErrorFactory.structDef;
|
|
48
|
+
}
|
|
49
|
+
return source.structDef();
|
|
50
|
+
}
|
|
42
51
|
}
|
|
43
52
|
exports.Join = Join;
|
|
44
53
|
class KeyJoin extends Join {
|
|
45
|
-
constructor(name,
|
|
46
|
-
super({ name
|
|
54
|
+
constructor(name, sourceExpr, keyExpr) {
|
|
55
|
+
super({ name, sourceExpr, keyExpr });
|
|
47
56
|
this.name = name;
|
|
48
|
-
this.
|
|
57
|
+
this.sourceExpr = sourceExpr;
|
|
49
58
|
this.keyExpr = keyExpr;
|
|
50
59
|
this.elementType = 'joinOnKey';
|
|
51
60
|
}
|
|
52
61
|
structDef() {
|
|
53
62
|
var _a;
|
|
54
|
-
const sourceDef = this.
|
|
63
|
+
const sourceDef = this.getStructDefFromExpr();
|
|
55
64
|
const joinStruct = {
|
|
56
65
|
...sourceDef,
|
|
57
66
|
structRelationship: {
|
|
@@ -107,10 +116,10 @@ class KeyJoin extends Join {
|
|
|
107
116
|
}
|
|
108
117
|
exports.KeyJoin = KeyJoin;
|
|
109
118
|
class ExpressionJoin extends Join {
|
|
110
|
-
constructor(name,
|
|
111
|
-
super({ name
|
|
119
|
+
constructor(name, sourceExpr) {
|
|
120
|
+
super({ name, sourceExpr });
|
|
112
121
|
this.name = name;
|
|
113
|
-
this.
|
|
122
|
+
this.sourceExpr = sourceExpr;
|
|
114
123
|
this.elementType = 'joinOnExpr';
|
|
115
124
|
this.joinType = 'one';
|
|
116
125
|
}
|
|
@@ -137,7 +146,12 @@ class ExpressionJoin extends Join {
|
|
|
137
146
|
}
|
|
138
147
|
structDef() {
|
|
139
148
|
var _a;
|
|
140
|
-
const
|
|
149
|
+
const source = this.sourceExpr.getSource();
|
|
150
|
+
if (!source) {
|
|
151
|
+
this.sourceExpr.sqLog('Cannot create a source to join from');
|
|
152
|
+
return error_factory_1.ErrorFactory.structDef;
|
|
153
|
+
}
|
|
154
|
+
const sourceDef = source.structDef();
|
|
141
155
|
const joinStruct = {
|
|
142
156
|
...sourceDef,
|
|
143
157
|
structRelationship: { type: this.joinType },
|
|
@@ -108,6 +108,11 @@ class SQLSource extends source_1.Source {
|
|
|
108
108
|
fields: lookup.value.fields.map(f => ({ ...f, location })),
|
|
109
109
|
location: this.location,
|
|
110
110
|
};
|
|
111
|
+
const fromDoc = this.document();
|
|
112
|
+
const modelAnnotation = fromDoc === null || fromDoc === void 0 ? void 0 : fromDoc.currentModelAnnotation();
|
|
113
|
+
if (modelAnnotation) {
|
|
114
|
+
locStruct.modelAnnotation = modelAnnotation;
|
|
115
|
+
}
|
|
111
116
|
return locStruct;
|
|
112
117
|
}
|
|
113
118
|
else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SQLPhrase } from '../../../model/malloy_types';
|
|
2
|
-
import { QueryElement } from '../types/query-element';
|
|
3
2
|
import { MalloyElement } from '../types/malloy-element';
|
|
4
|
-
|
|
3
|
+
import { SourceQueryNode } from '../elements/source-query';
|
|
4
|
+
type SQLStringSegment = string | SourceQueryNode;
|
|
5
5
|
export declare class SQLString extends MalloyElement {
|
|
6
6
|
elementType: string;
|
|
7
7
|
elements: SQLStringSegment[];
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.SQLString = void 0;
|
|
26
|
-
const query_element_1 = require("../types/query-element");
|
|
27
26
|
const malloy_element_1 = require("../types/malloy-element");
|
|
27
|
+
const source_query_1 = require("../elements/source-query");
|
|
28
28
|
class SQLString extends malloy_element_1.MalloyElement {
|
|
29
29
|
constructor() {
|
|
30
30
|
super(...arguments);
|
|
@@ -34,7 +34,7 @@ class SQLString extends malloy_element_1.MalloyElement {
|
|
|
34
34
|
}
|
|
35
35
|
complete() {
|
|
36
36
|
this.has({
|
|
37
|
-
queries: this.elements.filter(
|
|
37
|
+
queries: this.elements.filter(isQuery),
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
push(el) {
|
|
@@ -43,7 +43,7 @@ class SQLString extends malloy_element_1.MalloyElement {
|
|
|
43
43
|
this.elements.push(el);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
else if (
|
|
46
|
+
else if (el instanceof source_query_1.SourceQueryNode) {
|
|
47
47
|
this.elements.push(el);
|
|
48
48
|
this.containsQueries = true;
|
|
49
49
|
el.parent = this;
|
|
@@ -53,16 +53,26 @@ class SQLString extends malloy_element_1.MalloyElement {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
sqlPhrases() {
|
|
56
|
-
|
|
56
|
+
const ret = [];
|
|
57
|
+
for (const el of this.elements) {
|
|
57
58
|
if (typeof el === 'string') {
|
|
58
|
-
|
|
59
|
+
ret.push({ sql: el });
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
else {
|
|
62
|
+
const queryObject = el.getQuery();
|
|
63
|
+
if (queryObject) {
|
|
64
|
+
ret.push(queryObject.query());
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
el.sqLog('Cannot expand into a query');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return ret;
|
|
62
72
|
}
|
|
63
73
|
}
|
|
64
74
|
exports.SQLString = SQLString;
|
|
65
|
-
function
|
|
66
|
-
return
|
|
75
|
+
function isQuery(x) {
|
|
76
|
+
return x instanceof source_query_1.SourceQueryNode;
|
|
67
77
|
}
|
|
68
78
|
//# sourceMappingURL=sql-string.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Annotation, DocumentLocation, DocumentReference, ModelDef, Note, Query, SQLBlockStructDef, StructDef } from '../../../model/malloy_types';
|
|
1
|
+
import { Annotation, DocumentLocation, DocumentReference, ModelDef, ModelAnnotation, NamedModelObject, Note, Query, SQLBlockStructDef, StructDef } from '../../../model/malloy_types';
|
|
2
2
|
import { LogSeverity, MessageLogger } from '../../parse-log';
|
|
3
3
|
import { MalloyTranslation } from '../../parse-malloy';
|
|
4
4
|
import { ModelDataRequest } from '../../translate-response';
|
|
@@ -61,6 +61,7 @@ export declare class ModelEntryReference extends MalloyElement {
|
|
|
61
61
|
constructor(name: string);
|
|
62
62
|
get refString(): string;
|
|
63
63
|
toString(): string;
|
|
64
|
+
getNamed(): NamedModelObject | undefined;
|
|
64
65
|
}
|
|
65
66
|
export interface DocStatement extends MalloyElement {
|
|
66
67
|
execute(doc: Document): void;
|
|
@@ -113,6 +114,7 @@ export declare class Document extends MalloyElement implements NameSpace {
|
|
|
113
114
|
compile(): DocumentCompileResult;
|
|
114
115
|
private modelAnnotationTodoList;
|
|
115
116
|
rememberToAddModelAnnotations(sd: StructDef): void;
|
|
117
|
+
currentModelAnnotation(): ModelAnnotation | undefined;
|
|
116
118
|
modelDef(): ModelDef;
|
|
117
119
|
defineSQL(sql: SQLBlockStructDef, name?: string): boolean;
|
|
118
120
|
getEntry(str: string): ModelEntry;
|
|
@@ -276,6 +276,10 @@ class ModelEntryReference extends MalloyElement {
|
|
|
276
276
|
toString() {
|
|
277
277
|
return this.refString;
|
|
278
278
|
}
|
|
279
|
+
getNamed() {
|
|
280
|
+
var _a;
|
|
281
|
+
return (_a = this.modelEntry(this)) === null || _a === void 0 ? void 0 : _a.entry;
|
|
282
|
+
}
|
|
279
283
|
}
|
|
280
284
|
exports.ModelEntryReference = ModelEntryReference;
|
|
281
285
|
function isDocStatement(e) {
|
|
@@ -455,11 +459,17 @@ class Document extends MalloyElement {
|
|
|
455
459
|
rememberToAddModelAnnotations(sd) {
|
|
456
460
|
this.modelAnnotationTodoList.push(sd);
|
|
457
461
|
}
|
|
462
|
+
currentModelAnnotation() {
|
|
463
|
+
if (this.notes.length > 0) {
|
|
464
|
+
const ret = { id: '', notes: this.notes };
|
|
465
|
+
ret.id = annotationID(ret);
|
|
466
|
+
return ret;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
458
469
|
modelDef() {
|
|
459
470
|
const def = { name: '', exports: [], contents: {} };
|
|
460
471
|
if (this.notes.length > 0) {
|
|
461
|
-
def.annotation =
|
|
462
|
-
def.annotation.id = annotationID(def.annotation);
|
|
472
|
+
def.annotation = this.currentModelAnnotation();
|
|
463
473
|
}
|
|
464
474
|
for (const entry in this.documentModel) {
|
|
465
475
|
const entryDef = this.documentModel[entry].entry;
|
|
@@ -467,10 +477,11 @@ class Document extends MalloyElement {
|
|
|
467
477
|
if (this.documentModel[entry].exported) {
|
|
468
478
|
def.exports.push(entry);
|
|
469
479
|
}
|
|
470
|
-
|
|
471
|
-
if (
|
|
472
|
-
|
|
480
|
+
const newEntry = (0, cloneDeep_1.default)(entryDef);
|
|
481
|
+
if (newEntry.modelAnnotation === undefined && def.annotation) {
|
|
482
|
+
newEntry.modelAnnotation = def.annotation;
|
|
473
483
|
}
|
|
484
|
+
def.contents[entry] = newEntry;
|
|
474
485
|
}
|
|
475
486
|
}
|
|
476
487
|
return def;
|