@malloydata/malloy 0.0.195-dev241003204905 → 0.0.195-dev241007154000
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/connection/base_connection.d.ts +21 -7
- package/dist/connection/base_connection.js +62 -0
- package/dist/connection/types.d.ts +5 -5
- package/dist/dialect/dialect.d.ts +5 -3
- package/dist/dialect/dialect.js +15 -0
- package/dist/dialect/duckdb/duckdb.d.ts +3 -3
- package/dist/dialect/duckdb/duckdb.js +8 -3
- package/dist/dialect/postgres/postgres.d.ts +3 -3
- package/dist/dialect/postgres/postgres.js +5 -2
- package/dist/dialect/snowflake/snowflake.d.ts +3 -3
- package/dist/dialect/snowflake/snowflake.js +4 -1
- package/dist/dialect/standardsql/standardsql.d.ts +3 -3
- package/dist/dialect/standardsql/standardsql.js +5 -2
- package/dist/dialect/trino/trino.d.ts +3 -3
- package/dist/dialect/trino/trino.js +35 -3
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -2
- package/dist/lang/ast/error-factory.d.ts +4 -3
- package/dist/lang/ast/error-factory.js +27 -17
- package/dist/lang/ast/expressions/constant-expression.d.ts +1 -0
- package/dist/lang/ast/expressions/constant-expression.js +3 -0
- package/dist/lang/ast/expressions/expr-aggregate-function.d.ts +3 -7
- package/dist/lang/ast/expressions/expr-aggregate-function.js +50 -54
- package/dist/lang/ast/expressions/expr-cast.js +2 -4
- package/dist/lang/ast/expressions/expr-func.js +1 -1
- package/dist/lang/ast/expressions/expr-granular-time.js +1 -1
- package/dist/lang/ast/expressions/expr-record-literal.d.ts +16 -0
- package/dist/lang/ast/expressions/expr-record-literal.js +57 -0
- package/dist/lang/ast/expressions/expr-time-extract.js +3 -3
- package/dist/lang/ast/expressions/expr-time.d.ts +3 -3
- package/dist/lang/ast/expressions/expr-time.js +1 -1
- package/dist/lang/ast/expressions/time-literal.d.ts +6 -6
- package/dist/lang/ast/expressions/time-literal.js +1 -1
- package/dist/lang/ast/field-space/column-space-field.d.ts +6 -5
- package/dist/lang/ast/field-space/column-space-field.js +7 -4
- package/dist/lang/ast/field-space/dynamic-space.d.ts +8 -6
- package/dist/lang/ast/field-space/dynamic-space.js +35 -11
- package/dist/lang/ast/field-space/index-field-space.js +6 -3
- package/dist/lang/ast/field-space/ir-view-field.d.ts +1 -0
- package/dist/lang/ast/field-space/ir-view-field.js +3 -1
- package/dist/lang/ast/field-space/join-space-field.d.ts +2 -2
- package/dist/lang/ast/field-space/join-space-field.js +2 -2
- package/dist/lang/ast/field-space/parameter-space.d.ts +1 -0
- package/dist/lang/ast/field-space/parameter-space.js +4 -1
- package/dist/lang/ast/field-space/query-input-space.d.ts +4 -4
- package/dist/lang/ast/field-space/query-input-space.js +3 -5
- package/dist/lang/ast/field-space/query-spaces.d.ts +4 -4
- package/dist/lang/ast/field-space/query-spaces.js +1 -1
- package/dist/lang/ast/field-space/reference-field.js +10 -8
- package/dist/lang/ast/field-space/refined-space.d.ts +2 -2
- package/dist/lang/ast/field-space/static-space.d.ts +14 -5
- package/dist/lang/ast/field-space/static-space.js +45 -20
- package/dist/lang/ast/field-space/struct-space-field-base.d.ts +6 -5
- package/dist/lang/ast/field-space/struct-space-field-base.js +12 -4
- package/dist/lang/ast/index.d.ts +2 -1
- package/dist/lang/ast/index.js +2 -1
- package/dist/lang/ast/query-builders/index-builder.d.ts +2 -2
- package/dist/lang/ast/query-builders/project-builder.d.ts +2 -2
- package/dist/lang/ast/query-builders/reduce-builder.d.ts +2 -2
- package/dist/lang/ast/query-elements/query-arrow.js +2 -2
- package/dist/lang/ast/query-elements/query-head-struct.d.ts +2 -2
- package/dist/lang/ast/query-elements/query-head-struct.js +2 -2
- package/dist/lang/ast/query-elements/query-raw.js +2 -2
- package/dist/lang/ast/query-elements/query-reference.js +1 -1
- package/dist/lang/ast/query-items/field-declaration.d.ts +8 -6
- package/dist/lang/ast/query-items/field-declaration.js +66 -24
- package/dist/lang/ast/query-properties/qop-desc.d.ts +2 -2
- package/dist/lang/ast/query-properties/qop-desc.js +1 -1
- package/dist/lang/ast/source-elements/named-source.d.ts +4 -4
- package/dist/lang/ast/source-elements/named-source.js +16 -8
- package/dist/lang/ast/source-elements/query-source.d.ts +3 -3
- package/dist/lang/ast/source-elements/query-source.js +5 -2
- package/dist/lang/ast/source-elements/refined-source.d.ts +3 -3
- package/dist/lang/ast/source-elements/refined-source.js +4 -4
- package/dist/lang/ast/source-elements/source.d.ts +2 -2
- package/dist/lang/ast/source-elements/source.js +2 -2
- package/dist/lang/ast/source-elements/sql-source.d.ts +4 -4
- package/dist/lang/ast/source-elements/sql-source.js +6 -6
- package/dist/lang/ast/source-elements/table-source.d.ts +2 -2
- package/dist/lang/ast/source-elements/table-source.js +1 -1
- package/dist/lang/ast/source-properties/{joins.d.ts → join.d.ts} +11 -14
- package/dist/lang/ast/source-properties/{joins.js → join.js} +35 -52
- package/dist/lang/ast/source-query-elements/sq-reference.js +6 -5
- package/dist/lang/ast/sql-elements/sql-string.d.ts +2 -2
- package/dist/lang/ast/statements/define-source.js +1 -1
- package/dist/lang/ast/struct-utils.d.ts +3 -3
- package/dist/lang/ast/struct-utils.js +12 -3
- package/dist/lang/ast/time-utils.d.ts +3 -3
- package/dist/lang/ast/types/document-compile-result.d.ts +2 -2
- package/dist/lang/ast/types/expression-def.js +4 -4
- package/dist/lang/ast/types/field-space.d.ts +8 -3
- package/dist/lang/ast/types/lookup-result.d.ts +8 -5
- package/dist/lang/ast/types/malloy-element.d.ts +3 -3
- package/dist/lang/ast/types/malloy-element.js +10 -21
- package/dist/lang/ast/types/op-desc.d.ts +2 -2
- package/dist/lang/ast/types/pipeline-comp.d.ts +2 -2
- package/dist/lang/ast/types/query-comp.d.ts +3 -3
- package/dist/lang/ast/types/query-extend-property.d.ts +1 -2
- package/dist/lang/ast/types/query-extend-property.js +4 -2
- package/dist/lang/ast/types/source-property.d.ts +2 -2
- package/dist/lang/ast/types/source-property.js +2 -2
- package/dist/lang/ast/types/space-field.d.ts +10 -3
- package/dist/lang/ast/types/space-field.js +11 -2
- package/dist/lang/ast/types/time-result.d.ts +2 -2
- package/dist/lang/ast/view-elements/qop-desc-view.d.ts +3 -3
- package/dist/lang/ast/view-elements/qop-desc-view.js +1 -1
- package/dist/lang/ast/view-elements/reference-view.d.ts +4 -4
- package/dist/lang/ast/view-elements/reference-view.js +2 -6
- package/dist/lang/ast/view-elements/view-refine.d.ts +2 -2
- package/dist/lang/index.d.ts +1 -1
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +54 -21
- package/dist/lang/lib/Malloy/MalloyParser.js +1647 -1457
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +57 -9
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +35 -5
- package/dist/lang/malloy-to-ast.d.ts +4 -4
- package/dist/lang/malloy-to-ast.js +32 -4
- package/dist/lang/parse-log.d.ts +5 -9
- package/dist/lang/parse-malloy.d.ts +10 -10
- package/dist/lang/parse-malloy.js +2 -1
- package/dist/lang/test/annotation.spec.js +7 -1
- package/dist/lang/test/field-symbols.spec.js +21 -25
- package/dist/lang/test/imports.spec.js +12 -10
- package/dist/lang/test/lenses.spec.js +2 -2
- package/dist/lang/test/model_serialization.spec.d.ts +4 -4
- package/dist/lang/test/model_serialization.spec.js +19 -31
- package/dist/lang/test/parse.spec.js +3 -4
- package/dist/lang/test/query.spec.js +3 -2
- package/dist/lang/test/source.spec.js +7 -0
- package/dist/lang/test/sql-block.spec.js +8 -19
- package/dist/lang/test/test-translator.d.ts +4 -4
- package/dist/lang/test/test-translator.js +53 -61
- package/dist/lang/translate-response.d.ts +3 -3
- package/dist/malloy.d.ts +31 -149
- package/dist/malloy.js +109 -267
- package/dist/model/malloy_query.d.ts +25 -23
- package/dist/model/malloy_query.js +262 -323
- package/dist/model/malloy_types.d.ts +145 -155
- package/dist/model/malloy_types.js +81 -84
- package/dist/model/sql_block.d.ts +4 -4
- package/dist/model/sql_block.js +9 -12
- package/dist/tags.js +2 -2
- package/package.json +1 -1
- package/dist/lang/ast/space-seed.d.ts +0 -16
- package/dist/lang/ast/space-seed.js +0 -59
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.
|
|
25
|
+
exports.JoinStatement = exports.ExpressionJoin = exports.KeyJoin = exports.Join = void 0;
|
|
26
26
|
const malloy_types_1 = require("../../../model/malloy_types");
|
|
27
27
|
const join_space_field_1 = require("../field-space/join-space-field");
|
|
28
28
|
const definition_list_1 = require("../types/definition-list");
|
|
29
29
|
const malloy_element_1 = require("../types/malloy-element");
|
|
30
30
|
const noteable_1 = require("../types/noteable");
|
|
31
|
-
const query_property_interface_1 = require("../types/query-property-interface");
|
|
32
31
|
const error_factory_1 = require("../error-factory");
|
|
32
|
+
const query_property_interface_1 = require("../types/query-property-interface");
|
|
33
33
|
class Join extends malloy_element_1.MalloyElement {
|
|
34
34
|
constructor() {
|
|
35
35
|
super(...arguments);
|
|
@@ -37,7 +37,7 @@ class Join extends malloy_element_1.MalloyElement {
|
|
|
37
37
|
this.extendNote = noteable_1.extendNoteMethod;
|
|
38
38
|
}
|
|
39
39
|
makeEntry(fs) {
|
|
40
|
-
fs.newEntry(this.name.refString, this, new join_space_field_1.JoinSpaceField(fs.parameterSpace(), this));
|
|
40
|
+
fs.newEntry(this.name.refString, this, new join_space_field_1.JoinSpaceField(fs.parameterSpace(), this, fs.dialect));
|
|
41
41
|
}
|
|
42
42
|
getStructDefFromExpr(parameterSpace) {
|
|
43
43
|
const source = this.sourceExpr.getSource();
|
|
@@ -45,7 +45,7 @@ class Join extends malloy_element_1.MalloyElement {
|
|
|
45
45
|
this.sourceExpr.sqLog('invalid-join-source', 'Cannot create a source to join from');
|
|
46
46
|
return error_factory_1.ErrorFactory.structDef;
|
|
47
47
|
}
|
|
48
|
-
return source.
|
|
48
|
+
return source.getSourceDef(parameterSpace);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
exports.Join = Join;
|
|
@@ -60,22 +60,18 @@ class KeyJoin extends Join {
|
|
|
60
60
|
structDef(parameterSpace) {
|
|
61
61
|
var _a;
|
|
62
62
|
const sourceDef = this.getStructDefFromExpr(parameterSpace);
|
|
63
|
+
if (!(0, malloy_types_1.isJoinable)(sourceDef)) {
|
|
64
|
+
throw this.internalError(`Cannot join struct type '${sourceDef.type}'`);
|
|
65
|
+
}
|
|
63
66
|
const joinStruct = {
|
|
64
67
|
...sourceDef,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
},
|
|
68
|
+
name: this.name.refString,
|
|
69
|
+
join: 'one',
|
|
70
|
+
matrixOperation: 'left',
|
|
71
|
+
onExpression: { node: 'error', message: "('join fixup'='not done yet')" },
|
|
70
72
|
location: this.location,
|
|
71
73
|
};
|
|
72
|
-
|
|
73
|
-
// the name from query does not need to be preserved
|
|
74
|
-
joinStruct.name = this.name.refString;
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
joinStruct.as = this.name.refString;
|
|
78
|
-
}
|
|
74
|
+
delete joinStruct.as;
|
|
79
75
|
if (this.note) {
|
|
80
76
|
joinStruct.annotation = this.note;
|
|
81
77
|
}
|
|
@@ -84,22 +80,19 @@ class KeyJoin extends Join {
|
|
|
84
80
|
}
|
|
85
81
|
fixupJoinOn(outer, inStruct) {
|
|
86
82
|
const exprX = this.keyExpr.getExpression(outer);
|
|
87
|
-
if (inStruct.primaryKey) {
|
|
83
|
+
if ((0, malloy_types_1.isSourceDef)(inStruct) && inStruct.primaryKey) {
|
|
88
84
|
const pkey = inStruct.fields.find(f => (f.as || f.name) === inStruct.primaryKey);
|
|
89
85
|
if (pkey) {
|
|
90
86
|
if (pkey.type === exprX.dataType) {
|
|
91
|
-
inStruct.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
node: 'field',
|
|
99
|
-
path: [this.name.refString, inStruct.primaryKey],
|
|
100
|
-
},
|
|
101
|
-
right: exprX.value,
|
|
87
|
+
inStruct.join = 'one';
|
|
88
|
+
inStruct.onExpression = {
|
|
89
|
+
node: '=',
|
|
90
|
+
kids: {
|
|
91
|
+
left: {
|
|
92
|
+
node: 'field',
|
|
93
|
+
path: [this.name.refString, inStruct.primaryKey],
|
|
102
94
|
},
|
|
95
|
+
right: exprX.value,
|
|
103
96
|
},
|
|
104
97
|
};
|
|
105
98
|
return;
|
|
@@ -143,40 +136,31 @@ class ExpressionJoin extends Join {
|
|
|
143
136
|
this.logError('non-boolean-join-on', 'join conditions must be boolean expressions');
|
|
144
137
|
return;
|
|
145
138
|
}
|
|
146
|
-
|
|
147
|
-
if ((0, malloy_types_1.isJoinOn)(joinRel)) {
|
|
148
|
-
joinRel.onExpression = exprX.value;
|
|
149
|
-
}
|
|
139
|
+
inStruct.onExpression = exprX.value;
|
|
150
140
|
}
|
|
151
141
|
structDef(parameterSpace) {
|
|
152
142
|
var _a;
|
|
153
143
|
const source = this.sourceExpr.getSource();
|
|
154
144
|
if (!source) {
|
|
155
145
|
this.sourceExpr.sqLog('invalid-join-source', 'Cannot create a source to join from');
|
|
156
|
-
return error_factory_1.ErrorFactory.
|
|
146
|
+
return error_factory_1.ErrorFactory.joinDef;
|
|
157
147
|
}
|
|
158
|
-
const sourceDef = source.
|
|
148
|
+
const sourceDef = source.getSourceDef(parameterSpace);
|
|
159
149
|
let matrixOperation = 'left';
|
|
160
150
|
if (this.inExperiment('join_types', true)) {
|
|
161
151
|
matrixOperation = this.matrixOperation;
|
|
162
152
|
}
|
|
153
|
+
if (!(0, malloy_types_1.isJoinable)(sourceDef)) {
|
|
154
|
+
throw this.internalError(`Can't join struct type ${sourceDef.type}`);
|
|
155
|
+
}
|
|
163
156
|
const joinStruct = {
|
|
164
157
|
...sourceDef,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
matrixOperation,
|
|
169
|
-
},
|
|
158
|
+
name: this.name.refString,
|
|
159
|
+
join: this.joinType,
|
|
160
|
+
matrixOperation,
|
|
170
161
|
location: this.location,
|
|
171
162
|
};
|
|
172
|
-
|
|
173
|
-
// the name from query does not need to be preserved
|
|
174
|
-
joinStruct.name = this.name.refString;
|
|
175
|
-
delete joinStruct.as;
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
joinStruct.as = this.name.refString;
|
|
179
|
-
}
|
|
163
|
+
delete joinStruct.as;
|
|
180
164
|
if (this.note) {
|
|
181
165
|
joinStruct.annotation = this.note;
|
|
182
166
|
}
|
|
@@ -185,11 +169,10 @@ class ExpressionJoin extends Join {
|
|
|
185
169
|
}
|
|
186
170
|
}
|
|
187
171
|
exports.ExpressionJoin = ExpressionJoin;
|
|
188
|
-
|
|
189
|
-
class Joins extends definition_list_1.DefinitionList {
|
|
172
|
+
class JoinStatement extends definition_list_1.DefinitionList {
|
|
190
173
|
constructor(joins) {
|
|
191
174
|
super(joins);
|
|
192
|
-
this.elementType = '
|
|
175
|
+
this.elementType = 'joinStatement';
|
|
193
176
|
this.forceQueryClass = undefined;
|
|
194
177
|
this.queryRefinementStage = query_property_interface_1.LegalRefinementStage.Single;
|
|
195
178
|
}
|
|
@@ -199,5 +182,5 @@ class Joins extends definition_list_1.DefinitionList {
|
|
|
199
182
|
}
|
|
200
183
|
}
|
|
201
184
|
}
|
|
202
|
-
exports.
|
|
203
|
-
//# sourceMappingURL=
|
|
185
|
+
exports.JoinStatement = JoinStatement;
|
|
186
|
+
//# sourceMappingURL=join.js.map
|
|
@@ -27,6 +27,7 @@ const source_query_element_1 = require("./source-query-element");
|
|
|
27
27
|
const query_source_1 = require("../source-elements/query-source");
|
|
28
28
|
const named_source_1 = require("../source-elements/named-source");
|
|
29
29
|
const query_reference_1 = require("../query-elements/query-reference");
|
|
30
|
+
const model_1 = require("../../../model");
|
|
30
31
|
/**
|
|
31
32
|
* A reference to either a source or a query.
|
|
32
33
|
*
|
|
@@ -51,7 +52,7 @@ class SQReference extends source_query_element_1.SourceQueryElement {
|
|
|
51
52
|
return query;
|
|
52
53
|
}
|
|
53
54
|
else {
|
|
54
|
-
this.sqLog(
|
|
55
|
+
this.sqLog('cannot-use-as-query', `Illegal reference to '${entry.as || entry.name}', query expected`);
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
else {
|
|
@@ -61,8 +62,8 @@ class SQReference extends source_query_element_1.SourceQueryElement {
|
|
|
61
62
|
return;
|
|
62
63
|
}
|
|
63
64
|
isSource() {
|
|
64
|
-
|
|
65
|
-
return
|
|
65
|
+
const refTo = this.ref.getNamed();
|
|
66
|
+
return refTo !== undefined && (0, model_1.modelObjIsSource)(refTo);
|
|
66
67
|
}
|
|
67
68
|
getSource() {
|
|
68
69
|
if (this.asSource) {
|
|
@@ -81,11 +82,11 @@ class SQReference extends source_query_element_1.SourceQueryElement {
|
|
|
81
82
|
const existingQuery = new query_reference_1.QueryReference(this.ref);
|
|
82
83
|
this.asSource = new query_source_1.QuerySource(existingQuery);
|
|
83
84
|
}
|
|
84
|
-
else if (
|
|
85
|
+
else if ((0, model_1.modelObjIsSource)(entry)) {
|
|
85
86
|
this.asSource = new named_source_1.NamedSource(this.ref, undefined, this.args);
|
|
86
87
|
}
|
|
87
88
|
else {
|
|
88
|
-
this.sqLog(
|
|
89
|
+
this.sqLog('cannot-use-struct-as-source', `Expected '${this.ref.refString}' to be of type query or source, not '${entry.type}'`);
|
|
89
90
|
return;
|
|
90
91
|
}
|
|
91
92
|
this.has({ asSource: this.asSource });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SQLPhraseSegment } from '../../../model/malloy_types';
|
|
2
2
|
import { MalloyElement } from '../types/malloy-element';
|
|
3
3
|
import { SourceQueryElement } from '../source-query-elements/source-query-element';
|
|
4
4
|
type SQLStringSegment = string | SourceQueryElement;
|
|
@@ -8,6 +8,6 @@ export declare class SQLString extends MalloyElement {
|
|
|
8
8
|
containsQueries: boolean;
|
|
9
9
|
complete(): void;
|
|
10
10
|
push(el: string | MalloyElement): void;
|
|
11
|
-
sqlPhrases():
|
|
11
|
+
sqlPhrases(): SQLPhraseSegment[];
|
|
12
12
|
}
|
|
13
13
|
export {};
|
|
@@ -56,7 +56,7 @@ class DefineSource extends malloy_element_1.MalloyElement {
|
|
|
56
56
|
const parameters = this.deduplicatedParameters();
|
|
57
57
|
const structDef = theSource.withParameters(undefined, this.parameters);
|
|
58
58
|
this.validateParameterShadowing(parameters, structDef);
|
|
59
|
-
if (error_factory_1.ErrorFactory.
|
|
59
|
+
if (error_factory_1.ErrorFactory.didCreate(structDef)) {
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
const entry = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FieldDef, PipeSegment, StructDef } from '../../model/malloy_types';
|
|
1
|
+
import { FieldDef, PipeSegment, SourceDef, StructDef } from '../../model/malloy_types';
|
|
2
2
|
import { MalloyElement } from './types/malloy-element';
|
|
3
|
-
export declare function opOutputStruct(logTo: MalloyElement, inputStruct:
|
|
4
|
-
export declare function getFinalStruct(logTo: MalloyElement, walkStruct:
|
|
3
|
+
export declare function opOutputStruct(logTo: MalloyElement, inputStruct: SourceDef, opDesc: PipeSegment): SourceDef;
|
|
4
|
+
export declare function getFinalStruct(logTo: MalloyElement, walkStruct: SourceDef, pipeline: PipeSegment[]): SourceDef;
|
|
5
5
|
export declare function getStructFieldDef(s: StructDef, fn: string): FieldDef | undefined;
|
|
@@ -28,7 +28,7 @@ const malloy_query_1 = require("../../model/malloy_query");
|
|
|
28
28
|
const malloy_types_1 = require("../../model/malloy_types");
|
|
29
29
|
const error_factory_1 = require("./error-factory");
|
|
30
30
|
function opOutputStruct(logTo, inputStruct, opDesc) {
|
|
31
|
-
const badModel = error_factory_1.ErrorFactory.
|
|
31
|
+
const badModel = error_factory_1.ErrorFactory.didCreate(inputStruct) || (0, malloy_types_1.structHasErrors)(inputStruct);
|
|
32
32
|
// We don't want to expose partial segments to the compiler
|
|
33
33
|
if ((0, malloy_types_1.isPartialSegment)(opDesc)) {
|
|
34
34
|
opDesc = { ...opDesc, type: 'reduce' };
|
|
@@ -37,14 +37,23 @@ function opOutputStruct(logTo, inputStruct, opDesc) {
|
|
|
37
37
|
// Don't call into the model code with a broken model
|
|
38
38
|
if (!badModel && !badOpDesc) {
|
|
39
39
|
try {
|
|
40
|
-
|
|
40
|
+
const pipeOutputStruct = malloy_query_1.Segment.nextStructDef(inputStruct, opDesc);
|
|
41
|
+
if ((0, malloy_types_1.isSourceDef)(pipeOutputStruct)) {
|
|
42
|
+
return pipeOutputStruct;
|
|
43
|
+
}
|
|
44
|
+
// Inconcievable, a pipe deosnt output a record or an array
|
|
45
|
+
logTo.logError('failed-to-compute-output-schema', 'INTERNAL ERROR model/Segment.nextStructDef: RETURNED A NON SOURCE\n' +
|
|
46
|
+
`STRUCTDEF: ${(0, util_1.inspect)(pipeOutputStruct, {
|
|
47
|
+
breakLength: 72,
|
|
48
|
+
depth: Infinity,
|
|
49
|
+
})}`);
|
|
41
50
|
}
|
|
42
51
|
catch (e) {
|
|
43
52
|
logTo.logError('failed-to-compute-output-schema', `INTERNAL ERROR model/Segment.nextStructDef: ${e.message}\n` +
|
|
44
53
|
`QUERY: ${(0, util_1.inspect)(opDesc, { breakLength: 72, depth: Infinity })}`);
|
|
45
54
|
}
|
|
46
55
|
}
|
|
47
|
-
return
|
|
56
|
+
return error_factory_1.ErrorFactory.structDef;
|
|
48
57
|
}
|
|
49
58
|
exports.opOutputStruct = opOutputStruct;
|
|
50
59
|
function getFinalStruct(logTo, walkStruct, pipeline) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Expr,
|
|
1
|
+
import { Expr, TemporalFieldType, TimestampUnit, FieldValueType, CastType, TypecastExpr, TimeDeltaExpr } from '../../model/malloy_types';
|
|
2
2
|
import { TimeResult } from './types/time-result';
|
|
3
|
-
export declare function timeOffset(timeType:
|
|
3
|
+
export declare function timeOffset(timeType: TemporalFieldType, from: Expr, op: '+' | '-', n: Expr, timeframe: TimestampUnit): TimeDeltaExpr;
|
|
4
4
|
export declare function castTo(castType: CastType | {
|
|
5
5
|
raw: string;
|
|
6
6
|
}, from: Expr, fromType: FieldValueType, safe?: boolean): TypecastExpr;
|
|
7
7
|
export declare function castTimestampToDate(from: Expr, safe?: boolean): TypecastExpr;
|
|
8
8
|
export declare function castDateToTimestamp(from: Expr, safe?: boolean): TypecastExpr;
|
|
9
|
-
export declare function resolution(timeframe: string):
|
|
9
|
+
export declare function resolution(timeframe: string): TemporalFieldType;
|
|
10
10
|
export declare function timeResult(t: TimeResult, tt: TimestampUnit | undefined): TimeResult;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ModelDef, Query,
|
|
1
|
+
import { ModelDef, Query, SQLSourceDef } from '../../../model/malloy_types';
|
|
2
2
|
import { ModelDataRequest } from '../../translate-response';
|
|
3
3
|
export interface DocumentCompileResult {
|
|
4
4
|
modelDef: ModelDef;
|
|
5
5
|
queryList: Query[];
|
|
6
|
-
sqlBlocks:
|
|
6
|
+
sqlBlocks: SQLSourceDef[];
|
|
7
7
|
needs: ModelDataRequest;
|
|
8
8
|
}
|
|
@@ -116,7 +116,7 @@ class ExprDuration extends ExpressionDef {
|
|
|
116
116
|
apply(fs, op, left) {
|
|
117
117
|
const lhs = left.getExpression(fs);
|
|
118
118
|
this.typeCheck(this, lhs);
|
|
119
|
-
if ((0, malloy_types_1.
|
|
119
|
+
if ((0, malloy_types_1.isTemporalField)(lhs.dataType) && (op === '+' || op === '-')) {
|
|
120
120
|
const num = this.n.getExpression(fs);
|
|
121
121
|
if (!fragtype_utils_1.FT.typeEq(num, fragtype_utils_1.FT.numberT)) {
|
|
122
122
|
this.logError('invalid-duration-quantity', `Duration quantity needs number not '${num.dataType}`);
|
|
@@ -182,8 +182,8 @@ function getMorphicValue(mv, mt) {
|
|
|
182
182
|
}
|
|
183
183
|
exports.getMorphicValue = getMorphicValue;
|
|
184
184
|
function timeCompare(left, lhs, op, rhs) {
|
|
185
|
-
const leftIsTime = (0, malloy_types_1.
|
|
186
|
-
const rightIsTime = (0, malloy_types_1.
|
|
185
|
+
const leftIsTime = (0, malloy_types_1.isTemporalField)(lhs.dataType);
|
|
186
|
+
const rightIsTime = (0, malloy_types_1.isTemporalField)(rhs.dataType);
|
|
187
187
|
const node = (0, binary_operators_1.getExprNode)(op);
|
|
188
188
|
if (leftIsTime && rightIsTime) {
|
|
189
189
|
if (lhs.dataType !== rhs.dataType) {
|
|
@@ -349,7 +349,7 @@ function delta(fs, left, op, right) {
|
|
|
349
349
|
if (noGo) {
|
|
350
350
|
return noGo;
|
|
351
351
|
}
|
|
352
|
-
const timeLHS = (0, malloy_types_1.
|
|
352
|
+
const timeLHS = (0, malloy_types_1.isTemporalField)(lhs.dataType);
|
|
353
353
|
const err = errorCascade(timeLHS ? 'error' : 'number', lhs, rhs);
|
|
354
354
|
if (err)
|
|
355
355
|
return err;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dialect } from '../../../dialect/dialect';
|
|
2
|
-
import { StructDef } from '../../../model/malloy_types';
|
|
2
|
+
import { SourceDef, StructDef } from '../../../model/malloy_types';
|
|
3
3
|
import { QueryOperationSpace } from '../field-space/query-spaces';
|
|
4
4
|
import { LookupResult } from './lookup-result';
|
|
5
5
|
import { MalloyElement } from './malloy-element';
|
|
@@ -16,11 +16,16 @@ export interface FieldSpace {
|
|
|
16
16
|
entry(symbol: string): SpaceEntry | undefined;
|
|
17
17
|
entries(): [string, SpaceEntry][];
|
|
18
18
|
dialectObj(): Dialect | undefined;
|
|
19
|
+
dialectName(): string;
|
|
19
20
|
isQueryFieldSpace(): this is QueryFieldSpace;
|
|
20
21
|
}
|
|
21
|
-
export interface
|
|
22
|
+
export interface SourceFieldSpace extends FieldSpace {
|
|
23
|
+
structDef(): SourceDef;
|
|
24
|
+
emptyStructDef(): SourceDef;
|
|
25
|
+
}
|
|
26
|
+
export interface QueryFieldSpace extends SourceFieldSpace {
|
|
22
27
|
outputSpace(): QueryOperationSpace;
|
|
23
|
-
inputSpace():
|
|
28
|
+
inputSpace(): SourceFieldSpace;
|
|
24
29
|
}
|
|
25
30
|
export declare class FieldName extends MalloyElement {
|
|
26
31
|
readonly name: string;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JoinElementType, JoinType } from '../../../model';
|
|
2
2
|
import { MessageCode } from '../../parse-log';
|
|
3
3
|
import { SpaceEntry } from './space-entry';
|
|
4
|
+
export interface JoinPathElement {
|
|
5
|
+
name: string;
|
|
6
|
+
joinElementType: JoinElementType;
|
|
7
|
+
joinType: JoinType;
|
|
8
|
+
}
|
|
9
|
+
export type JoinPath = JoinPathElement[];
|
|
4
10
|
export interface LookupFound {
|
|
5
11
|
found: SpaceEntry;
|
|
6
|
-
|
|
7
|
-
name: string;
|
|
8
|
-
structRelationship: StructRelationship;
|
|
9
|
-
}[];
|
|
12
|
+
joinPath: JoinPath;
|
|
10
13
|
error: undefined;
|
|
11
14
|
isOutputField: boolean;
|
|
12
15
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Annotation, DocumentLocation, DocumentReference, ModelDef, ModelAnnotation, NamedModelObject, Query,
|
|
1
|
+
import { Annotation, DocumentLocation, DocumentReference, ModelDef, ModelAnnotation, NamedModelObject, Query, SQLSourceDef, StructDef } from '../../../model/malloy_types';
|
|
2
2
|
import { Tag } from '../../../tags';
|
|
3
3
|
import { LogMessageOptions, MessageLogger, MessageParameterType, MessageCode } from '../../parse-log';
|
|
4
4
|
import { MalloyTranslation } from '../../parse-malloy';
|
|
@@ -121,7 +121,7 @@ export declare class Document extends MalloyElement implements NameSpace {
|
|
|
121
121
|
globalNameSpace: NameSpace;
|
|
122
122
|
documentModel: Record<string, ModelEntry>;
|
|
123
123
|
queryList: Query[];
|
|
124
|
-
sqlBlocks:
|
|
124
|
+
sqlBlocks: SQLSourceDef[];
|
|
125
125
|
statements: DocStatementList;
|
|
126
126
|
didInitModel: boolean;
|
|
127
127
|
annotation: Annotation;
|
|
@@ -134,7 +134,7 @@ export declare class Document extends MalloyElement implements NameSpace {
|
|
|
134
134
|
hasAnnotation(): boolean;
|
|
135
135
|
currentModelAnnotation(): ModelAnnotation | undefined;
|
|
136
136
|
modelDef(): ModelDef;
|
|
137
|
-
defineSQL(sql:
|
|
137
|
+
defineSQL(sql: SQLSourceDef, name?: string): boolean;
|
|
138
138
|
getEntry(str: string): ModelEntry;
|
|
139
139
|
setEntry(str: string, ent: ModelEntry): void;
|
|
140
140
|
/**
|
|
@@ -120,23 +120,13 @@ class MalloyElement {
|
|
|
120
120
|
location: reference.location,
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
|
-
else if (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
this.addReference({
|
|
134
|
-
type: 'exploreReference',
|
|
135
|
-
text: key,
|
|
136
|
-
definition: result.entry,
|
|
137
|
-
location: reference.location,
|
|
138
|
-
});
|
|
139
|
-
}
|
|
123
|
+
else if (result && (0, malloy_types_1.modelObjIsSource)(result.entry)) {
|
|
124
|
+
this.addReference({
|
|
125
|
+
type: 'exploreReference',
|
|
126
|
+
text: key,
|
|
127
|
+
definition: result.entry,
|
|
128
|
+
location: reference.location,
|
|
129
|
+
});
|
|
140
130
|
}
|
|
141
131
|
}
|
|
142
132
|
return result;
|
|
@@ -462,7 +452,7 @@ class Document extends MalloyElement {
|
|
|
462
452
|
}
|
|
463
453
|
for (const [nm, orig] of Object.entries(extendingModelDef.contents)) {
|
|
464
454
|
const entry = structuredClone(orig);
|
|
465
|
-
if (entry
|
|
455
|
+
if ((0, malloy_types_1.modelObjIsSource)(entry) ||
|
|
466
456
|
entry.type === 'query' ||
|
|
467
457
|
entry.type === 'function') {
|
|
468
458
|
const exported = extendingModelDef.exports.includes(nm);
|
|
@@ -521,7 +511,7 @@ class Document extends MalloyElement {
|
|
|
521
511
|
}
|
|
522
512
|
for (const entry in this.documentModel) {
|
|
523
513
|
const entryDef = this.documentModel[entry].entry;
|
|
524
|
-
if (entryDef
|
|
514
|
+
if ((0, malloy_types_1.modelObjIsSource)(entryDef) || entryDef.type === 'query') {
|
|
525
515
|
if (this.documentModel[entry].exported) {
|
|
526
516
|
def.exports.push(entry);
|
|
527
517
|
}
|
|
@@ -538,7 +528,6 @@ class Document extends MalloyElement {
|
|
|
538
528
|
const ret = {
|
|
539
529
|
...sql,
|
|
540
530
|
as: `$${this.sqlBlocks.length}`,
|
|
541
|
-
declaredSQLBlock: true,
|
|
542
531
|
};
|
|
543
532
|
if (name) {
|
|
544
533
|
if (this.getEntry(name)) {
|
|
@@ -559,7 +548,7 @@ class Document extends MalloyElement {
|
|
|
559
548
|
if (this.globalNameSpace.getEntry(str) !== undefined) {
|
|
560
549
|
this.logError('name-conflict-with-global', `Cannot redefine '${str}', which is in global namespace`);
|
|
561
550
|
}
|
|
562
|
-
if (ent.entry
|
|
551
|
+
if ((0, malloy_types_1.modelObjIsSource)(ent.entry)) {
|
|
563
552
|
this.checkExperimentalDialect(this, ent.entry.dialect);
|
|
564
553
|
}
|
|
565
554
|
this.documentModel[str] = ent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PipeSegment } from '../../../model/malloy_types';
|
|
2
|
-
import {
|
|
2
|
+
import { SourceFieldSpace } from './field-space';
|
|
3
3
|
export interface OpDesc {
|
|
4
4
|
segment: PipeSegment;
|
|
5
|
-
outputSpace: () =>
|
|
5
|
+
outputSpace: () => SourceFieldSpace;
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Annotation, PipeSegment,
|
|
1
|
+
import { Annotation, PipeSegment, SourceDef } from '../../../model/malloy_types';
|
|
2
2
|
export interface PipelineComp {
|
|
3
|
-
outputStruct:
|
|
3
|
+
outputStruct: SourceDef;
|
|
4
4
|
pipeline: PipeSegment[];
|
|
5
5
|
annotation?: Annotation;
|
|
6
6
|
name?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Query,
|
|
1
|
+
import { Query, SourceDef } from '../../../model/malloy_types';
|
|
2
2
|
export interface QueryComp {
|
|
3
|
-
outputStruct:
|
|
3
|
+
outputStruct: SourceDef;
|
|
4
4
|
query: Query;
|
|
5
|
-
inputStruct:
|
|
5
|
+
inputStruct: SourceDef;
|
|
6
6
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Dimensions } from '../source-properties/dimensions';
|
|
2
|
-
import { Joins } from '../source-properties/joins';
|
|
3
2
|
import { Measures } from '../source-properties/measures';
|
|
4
3
|
import { MalloyElement } from './malloy-element';
|
|
5
|
-
export type QueryExtendProperty = Dimensions | Measures
|
|
4
|
+
export type QueryExtendProperty = Dimensions | Measures;
|
|
6
5
|
export declare function isQueryExtendProperty(q: MalloyElement): q is QueryExtendProperty;
|
|
@@ -24,10 +24,12 @@
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.isQueryExtendProperty = void 0;
|
|
26
26
|
const dimensions_1 = require("../source-properties/dimensions");
|
|
27
|
-
const
|
|
27
|
+
const join_1 = require("../source-properties/join");
|
|
28
28
|
const measures_1 = require("../source-properties/measures");
|
|
29
29
|
function isQueryExtendProperty(q) {
|
|
30
|
-
return q instanceof dimensions_1.Dimensions ||
|
|
30
|
+
return (q instanceof dimensions_1.Dimensions ||
|
|
31
|
+
q instanceof measures_1.Measures ||
|
|
32
|
+
q instanceof join_1.JoinStatement);
|
|
31
33
|
}
|
|
32
34
|
exports.isQueryExtendProperty = isQueryExtendProperty;
|
|
33
35
|
//# sourceMappingURL=query-extend-property.js.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Filter } from '../query-properties/filters';
|
|
2
|
-
import { Joins } from '../source-properties/joins';
|
|
3
2
|
import { DeclareFields } from '../query-properties/declare-fields';
|
|
4
3
|
import { FieldListEdit } from '../source-properties/field-list-edit';
|
|
5
4
|
import { Renames } from '../source-properties/renames';
|
|
@@ -8,5 +7,6 @@ import { Views } from '../source-properties/views';
|
|
|
8
7
|
import { MalloyElement } from './malloy-element';
|
|
9
8
|
import { TimezoneStatement } from '../source-properties/timezone-statement';
|
|
10
9
|
import { ObjectAnnotation } from './annotation-elements';
|
|
11
|
-
|
|
10
|
+
import { JoinStatement } from '../source-properties/join';
|
|
11
|
+
export type SourceProperty = Filter | JoinStatement | DeclareFields | FieldListEdit | Renames | PrimaryKey | ObjectAnnotation | Views | TimezoneStatement;
|
|
12
12
|
export declare function isSourceProperty(p: MalloyElement): p is SourceProperty;
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.isSourceProperty = void 0;
|
|
26
26
|
const filters_1 = require("../query-properties/filters");
|
|
27
|
-
const joins_1 = require("../source-properties/joins");
|
|
28
27
|
const declare_fields_1 = require("../query-properties/declare-fields");
|
|
29
28
|
const field_list_edit_1 = require("../source-properties/field-list-edit");
|
|
30
29
|
const renames_1 = require("../source-properties/renames");
|
|
@@ -32,9 +31,10 @@ const primary_key_1 = require("../source-properties/primary-key");
|
|
|
32
31
|
const views_1 = require("../source-properties/views");
|
|
33
32
|
const timezone_statement_1 = require("../source-properties/timezone-statement");
|
|
34
33
|
const annotation_elements_1 = require("./annotation-elements");
|
|
34
|
+
const join_1 = require("../source-properties/join");
|
|
35
35
|
function isSourceProperty(p) {
|
|
36
36
|
return (p instanceof filters_1.Filter ||
|
|
37
|
-
p instanceof
|
|
37
|
+
p instanceof join_1.JoinStatement ||
|
|
38
38
|
p instanceof declare_fields_1.DeclareFields ||
|
|
39
39
|
p instanceof field_list_edit_1.FieldListEdit ||
|
|
40
40
|
p instanceof renames_1.Renames ||
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import { FieldDef, QueryFieldDef, TypeDesc } from '../../../model/malloy_types';
|
|
1
|
+
import { FieldDef, QueryFieldDef, TypeDesc, AtomicFieldDef } from '../../../model/malloy_types';
|
|
2
2
|
import { SpaceEntry } from './space-entry';
|
|
3
3
|
import { FieldSpace } from './field-space';
|
|
4
4
|
export declare abstract class SpaceField extends SpaceEntry {
|
|
5
5
|
readonly refType = "field";
|
|
6
|
-
|
|
7
|
-
protected fieldTypeFromFieldDef(def: FieldDef): TypeDesc;
|
|
6
|
+
protected fieldTypeFromFieldDef(def: AtomicFieldDef): TypeDesc;
|
|
8
7
|
getQueryFieldDef(_fs: FieldSpace): QueryFieldDef | undefined;
|
|
9
8
|
fieldDef(): FieldDef | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Called by field reference code generation to gain access to the
|
|
11
|
+
* annotation properties on the field being referenced. ColumnSpaceFields
|
|
12
|
+
* will have the original field def, and will implement this method,
|
|
13
|
+
* nothing else should be referencable, but if somehow one of those is
|
|
14
|
+
* referenced, don't bother to compute the fieldDef.
|
|
15
|
+
*/
|
|
16
|
+
constructorFieldDef(): FieldDef | undefined;
|
|
10
17
|
}
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.SpaceField = void 0;
|
|
26
|
-
const malloy_types_1 = require("../../../model/malloy_types");
|
|
27
26
|
const space_entry_1 = require("./space-entry");
|
|
28
27
|
class SpaceField extends space_entry_1.SpaceEntry {
|
|
29
28
|
constructor() {
|
|
@@ -36,7 +35,7 @@ class SpaceField extends space_entry_1.SpaceEntry {
|
|
|
36
35
|
expressionType: 'scalar',
|
|
37
36
|
evalSpace: 'input',
|
|
38
37
|
};
|
|
39
|
-
if (
|
|
38
|
+
if (def.expressionType) {
|
|
40
39
|
ref.expressionType = def.expressionType;
|
|
41
40
|
}
|
|
42
41
|
if (ref.dataType === 'sql native' &&
|
|
@@ -52,6 +51,16 @@ class SpaceField extends space_entry_1.SpaceEntry {
|
|
|
52
51
|
fieldDef() {
|
|
53
52
|
return undefined;
|
|
54
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Called by field reference code generation to gain access to the
|
|
56
|
+
* annotation properties on the field being referenced. ColumnSpaceFields
|
|
57
|
+
* will have the original field def, and will implement this method,
|
|
58
|
+
* nothing else should be referencable, but if somehow one of those is
|
|
59
|
+
* referenced, don't bother to compute the fieldDef.
|
|
60
|
+
*/
|
|
61
|
+
constructorFieldDef() {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
55
64
|
}
|
|
56
65
|
exports.SpaceField = SpaceField;
|
|
57
66
|
//# sourceMappingURL=space-field.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TemporalFieldType, TimestampUnit } from '../../../model/malloy_types';
|
|
2
2
|
import { ExprResult } from './expr-result';
|
|
3
3
|
export interface TimeResult extends ExprResult {
|
|
4
|
-
dataType:
|
|
4
|
+
dataType: TemporalFieldType;
|
|
5
5
|
timeframe?: TimestampUnit;
|
|
6
6
|
}
|