@malloydata/malloy 0.0.38-dev230609221655 → 0.0.38-dev230612191503
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/refined-source.js +1 -1
- package/dist/lang/ast/source-properties/timezone-statement.d.ts +1 -0
- package/dist/lang/ast/source-properties/timezone-statement.js +9 -0
- package/dist/lang/ast/sources/sql-source.js +3 -3
- package/dist/lang/lib/Malloy/MalloyLexer.d.ts +131 -132
- package/dist/lang/lib/Malloy/MalloyLexer.js +1051 -1063
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +233 -245
- package/dist/lang/lib/Malloy/MalloyParser.js +1437 -1513
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +0 -11
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +0 -7
- package/dist/lang/malloy-to-ast.js +8 -4
- package/dist/lang/test/document-help-context-walker.spec.js +1 -1
- package/dist/lang/test/document-symbol-walker.spec.js +10 -10
- package/dist/lang/test/parse-expects.d.ts +3 -1
- package/dist/lang/test/parse-expects.js +5 -2
- package/dist/lang/test/parse.spec.js +96 -96
- package/dist/lang/test/sql-block.spec.js +2 -2
- package/dist/lang/test/test-translator.js +1 -1
- package/dist/malloy.js +1 -1
- package/dist/model/malloy_query.js +2 -2
- package/package.json +1 -1
|
@@ -74,7 +74,6 @@ import { JoinOnContext } from "./MalloyParser";
|
|
|
74
74
|
import { MalloyDocumentContext } from "./MalloyParser";
|
|
75
75
|
import { MalloyStatementContext } from "./MalloyParser";
|
|
76
76
|
import { DefineSourceStatementContext } from "./MalloyParser";
|
|
77
|
-
import { ExploreKeywordContext } from "./MalloyParser";
|
|
78
77
|
import { DefineQueryContext } from "./MalloyParser";
|
|
79
78
|
import { TopLevelAnonQueryDefContext } from "./MalloyParser";
|
|
80
79
|
import { DefineSQLStatementContext } from "./MalloyParser";
|
|
@@ -1075,16 +1074,6 @@ export interface MalloyParserListener extends ParseTreeListener {
|
|
|
1075
1074
|
* @param ctx the parse tree
|
|
1076
1075
|
*/
|
|
1077
1076
|
exitDefineSourceStatement?: (ctx: DefineSourceStatementContext) => void;
|
|
1078
|
-
/**
|
|
1079
|
-
* Enter a parse tree produced by `MalloyParser.exploreKeyword`.
|
|
1080
|
-
* @param ctx the parse tree
|
|
1081
|
-
*/
|
|
1082
|
-
enterExploreKeyword?: (ctx: ExploreKeywordContext) => void;
|
|
1083
|
-
/**
|
|
1084
|
-
* Exit a parse tree produced by `MalloyParser.exploreKeyword`.
|
|
1085
|
-
* @param ctx the parse tree
|
|
1086
|
-
*/
|
|
1087
|
-
exitExploreKeyword?: (ctx: ExploreKeywordContext) => void;
|
|
1088
1077
|
/**
|
|
1089
1078
|
* Enter a parse tree produced by `MalloyParser.defineQuery`.
|
|
1090
1079
|
* @param ctx the parse tree
|
|
@@ -74,7 +74,6 @@ import { JoinOnContext } from "./MalloyParser";
|
|
|
74
74
|
import { MalloyDocumentContext } from "./MalloyParser";
|
|
75
75
|
import { MalloyStatementContext } from "./MalloyParser";
|
|
76
76
|
import { DefineSourceStatementContext } from "./MalloyParser";
|
|
77
|
-
import { ExploreKeywordContext } from "./MalloyParser";
|
|
78
77
|
import { DefineQueryContext } from "./MalloyParser";
|
|
79
78
|
import { TopLevelAnonQueryDefContext } from "./MalloyParser";
|
|
80
79
|
import { DefineSQLStatementContext } from "./MalloyParser";
|
|
@@ -706,12 +705,6 @@ export interface MalloyParserVisitor<Result> extends ParseTreeVisitor<Result> {
|
|
|
706
705
|
* @return the visitor result
|
|
707
706
|
*/
|
|
708
707
|
visitDefineSourceStatement?: (ctx: DefineSourceStatementContext) => Result;
|
|
709
|
-
/**
|
|
710
|
-
* Visit a parse tree produced by `MalloyParser.exploreKeyword`.
|
|
711
|
-
* @param ctx the parse tree
|
|
712
|
-
* @return the visitor result
|
|
713
|
-
*/
|
|
714
|
-
visitExploreKeyword?: (ctx: ExploreKeywordContext) => Result;
|
|
715
708
|
/**
|
|
716
709
|
* Visit a parse tree produced by `MalloyParser.defineQuery`.
|
|
717
710
|
* @param ctx the parse tree
|
|
@@ -98,7 +98,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
98
98
|
eps.push(el);
|
|
99
99
|
}
|
|
100
100
|
else {
|
|
101
|
-
this.astError(el, `Expected
|
|
101
|
+
this.astError(el, `Expected source property, not '${el.elementType}'`);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
return eps;
|
|
@@ -110,7 +110,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
110
110
|
eps.push(el);
|
|
111
111
|
}
|
|
112
112
|
else {
|
|
113
|
-
this.astError(el, `Expected
|
|
113
|
+
this.astError(el, `Expected source property, not '${el.elementType}'`);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
return eps;
|
|
@@ -244,7 +244,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
244
244
|
if (element instanceof ast.Source) {
|
|
245
245
|
return element;
|
|
246
246
|
}
|
|
247
|
-
throw this.internalError(pcx, `'${element.elementType}': illegal
|
|
247
|
+
throw this.internalError(pcx, `'${element.elementType}': illegal source`);
|
|
248
248
|
}
|
|
249
249
|
makeSqlString(pcx, sqlStr) {
|
|
250
250
|
var _a;
|
|
@@ -472,7 +472,11 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
472
472
|
return this.visitTimezoneStatement(cx.timezoneStatement());
|
|
473
473
|
}
|
|
474
474
|
visitTimezoneStatement(cx) {
|
|
475
|
-
|
|
475
|
+
const timezoneStatement = new ast.TimezoneStatement(this.stripQuotes(cx.STRING_LITERAL().text));
|
|
476
|
+
if (!timezoneStatement.isValid) {
|
|
477
|
+
this.astError(timezoneStatement, `Invalid timezone: ${timezoneStatement.tz}`);
|
|
478
|
+
}
|
|
479
|
+
return this.astAt(timezoneStatement, cx);
|
|
476
480
|
}
|
|
477
481
|
visitQueryProperties(pcx) {
|
|
478
482
|
const qProps = pcx
|
|
@@ -44,7 +44,7 @@ test('Supports model properties', () => {
|
|
|
44
44
|
testHelpContext((0, test_translator_1.markSource) `${source}`, { line: 0, character: 1 }, 'model_property', 'source:');
|
|
45
45
|
testHelpContext((0, test_translator_1.markSource) `${source}`, { line: 8, character: 1 }, 'model_property', 'query:');
|
|
46
46
|
});
|
|
47
|
-
test('Supports
|
|
47
|
+
test('Supports source properties', () => {
|
|
48
48
|
testHelpContext((0, test_translator_1.markSource) `${source}`, { line: 1, character: 3 }, 'explore_property', 'where:');
|
|
49
49
|
testHelpContext((0, test_translator_1.markSource) `${source}`, { line: 2, character: 3 }, 'explore_property', 'query:');
|
|
50
50
|
});
|
|
@@ -45,64 +45,64 @@ function testSymbol(source, name, type, path) {
|
|
|
45
45
|
type,
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
test('
|
|
49
|
-
testSymbol((0, test_translator_1.markSource) `
|
|
48
|
+
test('source symbols are included', () => {
|
|
49
|
+
testSymbol((0, test_translator_1.markSource) `source: ${"flights is table('my.table.flights')"}`, 'flights', 'explore', [0]);
|
|
50
50
|
});
|
|
51
51
|
test('query symbols are included', () => {
|
|
52
52
|
testSymbol((0, test_translator_1.markSource) `query: ${'flights_by_carrier is flights -> by_carrier'}`, 'flights_by_carrier', 'query', [0]);
|
|
53
53
|
});
|
|
54
54
|
test('expression field defs are included', () => {
|
|
55
55
|
testSymbol((0, test_translator_1.markSource) `
|
|
56
|
-
|
|
56
|
+
source: flights is table('my.table.flights') {
|
|
57
57
|
dimension: ${'one is 1'}
|
|
58
58
|
}
|
|
59
59
|
`, 'one', 'field', [0, 0]);
|
|
60
60
|
});
|
|
61
61
|
test('renamed fields are included', () => {
|
|
62
62
|
testSymbol((0, test_translator_1.markSource) `
|
|
63
|
-
|
|
63
|
+
source: flights is table('my.table.flights') {
|
|
64
64
|
rename: ${'field_two is field_2'}
|
|
65
65
|
}
|
|
66
66
|
`, 'field_two', 'field', [0, 0]);
|
|
67
67
|
});
|
|
68
68
|
test('name only fields are included', () => {
|
|
69
69
|
testSymbol((0, test_translator_1.markSource) `
|
|
70
|
-
|
|
70
|
+
source: flights is table('my.table.flights') {
|
|
71
71
|
dimension: ${'field_two is field_2'}
|
|
72
72
|
}
|
|
73
73
|
`, 'field_two', 'field', [0, 0]);
|
|
74
74
|
});
|
|
75
75
|
test('turtle fields are included', () => {
|
|
76
76
|
testSymbol((0, test_translator_1.markSource) `
|
|
77
|
-
|
|
77
|
+
source: flights is table('my.table.flights') {
|
|
78
78
|
query: ${'my_turtle is { group_by: a }'}
|
|
79
79
|
}
|
|
80
80
|
`, 'my_turtle', 'query', [0, 0]);
|
|
81
81
|
});
|
|
82
82
|
test('turtle children fields are included', () => {
|
|
83
83
|
testSymbol((0, test_translator_1.markSource) `
|
|
84
|
-
|
|
84
|
+
source: flights is table('my.table.flights') {
|
|
85
85
|
query: my_turtle is { group_by: ${'a'} }
|
|
86
86
|
}
|
|
87
87
|
`, 'a', 'field', [0, 0, 0]);
|
|
88
88
|
});
|
|
89
89
|
test('turtle children turtles are included', () => {
|
|
90
90
|
testSymbol((0, test_translator_1.markSource) `
|
|
91
|
-
|
|
91
|
+
source: flights is table('my.table.flights') {
|
|
92
92
|
query: my_turtle is { nest: ${'inner_turtle is { group_by: a }'} }
|
|
93
93
|
}
|
|
94
94
|
`, 'inner_turtle', 'query', [0, 0, 0]);
|
|
95
95
|
});
|
|
96
96
|
test('join withs are included', () => {
|
|
97
97
|
testSymbol((0, test_translator_1.markSource) `
|
|
98
|
-
|
|
98
|
+
source: flights is table('my.table.flights') {
|
|
99
99
|
join_one: ${'a is b with c'}
|
|
100
100
|
}
|
|
101
101
|
`, 'a', 'join', [0, 0]);
|
|
102
102
|
});
|
|
103
103
|
test('join ons are included', () => {
|
|
104
104
|
testSymbol((0, test_translator_1.markSource) `
|
|
105
|
-
|
|
105
|
+
source: flights is table('my.table.flights') {
|
|
106
106
|
join_one: ${'a is b on c'}
|
|
107
107
|
}
|
|
108
108
|
`, 'a', 'join', [0, 0]);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DocumentLocation } from '../../model';
|
|
2
|
+
declare type ErrorSpec = string | RegExp;
|
|
2
3
|
declare global {
|
|
3
4
|
namespace jest {
|
|
4
5
|
interface Matchers<R> {
|
|
@@ -8,8 +9,9 @@ declare global {
|
|
|
8
9
|
modelCompiled(): R;
|
|
9
10
|
expressionCompiled(): R;
|
|
10
11
|
toReturnType(tp: string): R;
|
|
11
|
-
compileToFailWith(...expectedErrors:
|
|
12
|
+
compileToFailWith(...expectedErrors: ErrorSpec[]): R;
|
|
12
13
|
isLocationIn(at: DocumentLocation, txt: string): R;
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
}
|
|
17
|
+
export {};
|
|
@@ -129,7 +129,7 @@ expect.extend({
|
|
|
129
129
|
return checkForErrors(trans);
|
|
130
130
|
},
|
|
131
131
|
toReturnType: function (functionCall, returnType) {
|
|
132
|
-
const exprModel = new test_translator_1.TestTranslator(`
|
|
132
|
+
const exprModel = new test_translator_1.TestTranslator(`source: x is a { dimension: d is ${functionCall} }`);
|
|
133
133
|
expect(exprModel).modelCompiled();
|
|
134
134
|
const x = exprModel.getSourceDef('x');
|
|
135
135
|
expect(x).toBeDefined();
|
|
@@ -191,7 +191,10 @@ expect.extend({
|
|
|
191
191
|
for (i = 0; i < msgs.length && errList[i]; i += 1) {
|
|
192
192
|
const msg = msgs[i];
|
|
193
193
|
const err = errList[i];
|
|
194
|
-
|
|
194
|
+
const matched = typeof msg === 'string'
|
|
195
|
+
? msg === err.message
|
|
196
|
+
: err.message.match(msg);
|
|
197
|
+
if (!matched) {
|
|
195
198
|
explain.push(`Expected: ${msg}\nGot: ${err.message}`);
|
|
196
199
|
}
|
|
197
200
|
else {
|