@malloydata/malloy 0.0.43-dev230622180905 → 0.0.43-dev230622192152
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/executors/reduce-executor.js +8 -0
- package/dist/lang/ast/expressions/expr-func.js +6 -0
- package/dist/lang/ast/index.d.ts +3 -0
- package/dist/lang/ast/index.js +3 -0
- package/dist/lang/ast/query-elements/run-query.d.ts +18 -0
- package/dist/lang/ast/query-elements/run-query.js +67 -0
- package/dist/lang/ast/query-properties/extend.d.ts +5 -0
- package/dist/lang/ast/query-properties/extend.js +33 -0
- package/dist/lang/ast/types/query-extend-property.d.ts +6 -0
- package/dist/lang/ast/types/query-extend-property.js +33 -0
- package/dist/lang/ast/types/query-property.d.ts +2 -1
- package/dist/lang/ast/types/query-property.js +2 -0
- package/dist/lang/lib/Malloy/MalloyLexer.d.ts +134 -132
- package/dist/lang/lib/Malloy/MalloyLexer.js +1136 -1119
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +344 -239
- package/dist/lang/lib/Malloy/MalloyParser.js +2218 -1547
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +134 -20
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +84 -12
- package/dist/lang/malloy-to-ast.d.ts +6 -2
- package/dist/lang/malloy-to-ast.js +54 -6
- package/dist/lang/parse-tree-walkers/document-symbol-walker.js +16 -0
- package/dist/lang/test/document-symbol-walker.spec.js +7 -0
- package/dist/lang/test/parse.spec.js +49 -7
- package/package.json +1 -1
|
@@ -45,6 +45,22 @@ class DocumentSymbolWalker {
|
|
|
45
45
|
children: [],
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
+
enterRunStatementDef(pcx) {
|
|
49
|
+
this.symbols.push({
|
|
50
|
+
range: this.translator.rangeFromContext(pcx.topLevelAnonQueryDef()),
|
|
51
|
+
name: 'unnamed_query',
|
|
52
|
+
type: 'unnamed_query',
|
|
53
|
+
children: [],
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
enterRunStatementRef(pcx) {
|
|
57
|
+
this.symbols.push({
|
|
58
|
+
range: this.translator.rangeFromContext(pcx.queryName()),
|
|
59
|
+
name: pcx.queryName().id().text,
|
|
60
|
+
type: 'query',
|
|
61
|
+
children: [],
|
|
62
|
+
});
|
|
63
|
+
}
|
|
48
64
|
enterTopLevelAnonQueryDef(pcx) {
|
|
49
65
|
this.symbols.push({
|
|
50
66
|
range: this.translator.rangeFromContext(pcx),
|
|
@@ -51,6 +51,13 @@ test('source symbols are included', () => {
|
|
|
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
|
+
test('run (def) symbols are included', () => {
|
|
55
|
+
testSymbol((0, test_translator_1.markSource) `run: ${'flights -> by_carrier'}`, 'unnamed_query', 'unnamed_query', [0]);
|
|
56
|
+
});
|
|
57
|
+
test('run (ref) symbols are included', () => {
|
|
58
|
+
testSymbol((0, test_translator_1.markSource) `query: by_carrier is flights -> by_carrier
|
|
59
|
+
run: ${'by_carrier'}`, 'by_carrier', 'query', [1]);
|
|
60
|
+
});
|
|
54
61
|
test('expression field defs are included', () => {
|
|
55
62
|
testSymbol((0, test_translator_1.markSource) `
|
|
56
63
|
source: flights is table('my.table.flights') {
|
|
@@ -59,9 +59,20 @@ describe('model statements', () => {
|
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
61
|
describe('query:', () => {
|
|
62
|
+
// Delete this when ENABLE_M4_WARNINGS is converted to an annotation
|
|
62
63
|
test('anonymous query', () => {
|
|
63
|
-
expect(
|
|
64
|
-
});
|
|
64
|
+
expect((0, test_translator_1.markSource) `query: ${"table('aTable') -> { group_by: astr }"}`).toTranslate();
|
|
65
|
+
});
|
|
66
|
+
// Unskip this when ENABLE_M4_WARNINGS is converted to an annotation
|
|
67
|
+
test.skip('anonymous query', () => {
|
|
68
|
+
expect((0, test_translator_1.markSource) `query: ${"table('aTable') -> { group_by: astr }"}`).toTranslateWithWarnings('Anonymous `query:` statements are deprecated, use `run:` instead');
|
|
69
|
+
});
|
|
70
|
+
test('run query', () => expect("run: table('aTable') -> { group_by: astr }").toTranslate());
|
|
71
|
+
test('run query ref', () => expect(`
|
|
72
|
+
query: foo is table('aTable') -> { group_by: astr }
|
|
73
|
+
run: foo
|
|
74
|
+
`).toTranslate());
|
|
75
|
+
test('query', () => expect("query: name is table('aTable') -> { group_by: astr }").toTranslate());
|
|
65
76
|
test('query', () => {
|
|
66
77
|
expect("query: name is table('aTable') -> { group_by: astr }").toTranslate();
|
|
67
78
|
});
|
|
@@ -946,18 +957,49 @@ describe('qops', () => {
|
|
|
946
957
|
}
|
|
947
958
|
`).toTranslate();
|
|
948
959
|
});
|
|
949
|
-
test('nest multiple', () =>
|
|
950
|
-
expect(`
|
|
960
|
+
test('nest multiple', () => expect(`
|
|
951
961
|
query: a->{
|
|
952
962
|
group_by: ai
|
|
953
963
|
nest:
|
|
954
964
|
nestbystr is { group_by: astr; aggregate: N is count() },
|
|
955
965
|
renest is { group_by: astr; aggregate: N is count() }
|
|
956
966
|
}
|
|
957
|
-
`).toTranslate();
|
|
967
|
+
`).toTranslate());
|
|
968
|
+
test('nest ref', () => expect('query: ab->{group_by: ai; nest: aturtle}').toTranslate());
|
|
969
|
+
describe('extend block', () => {
|
|
970
|
+
test('works with dimension', () => {
|
|
971
|
+
expect('query: a -> { extend: { dimension: x is 1 }; group_by: x }').toTranslate();
|
|
972
|
+
});
|
|
973
|
+
test('works with measure', () => {
|
|
974
|
+
expect('query: a -> { extend: { measure: x is count() }; aggregate: x }').toTranslate();
|
|
975
|
+
});
|
|
976
|
+
test('works with join_one', () => {
|
|
977
|
+
expect('query: a -> { extend: { join_one: bb is b on bb.astr = astr }; group_by: bb.astr }').toTranslate();
|
|
978
|
+
});
|
|
979
|
+
test('works with join_many', () => {
|
|
980
|
+
expect('query: a -> { extend: { join_many: b on astr = b.astr }; group_by: b.astr }').toTranslate();
|
|
981
|
+
});
|
|
982
|
+
test('works with join_cross', () => {
|
|
983
|
+
expect('query: a -> { extend: { join_cross: b on true }; group_by: b.astr }').toTranslate();
|
|
984
|
+
});
|
|
985
|
+
test('works with multiple in one block', () => {
|
|
986
|
+
expect('query: a -> { extend: { dimension: x is 1, y is 2 }; group_by: x, y }').toTranslate();
|
|
987
|
+
});
|
|
988
|
+
test('works with multiple blocks', () => {
|
|
989
|
+
expect('query: a -> { extend: { dimension: x is 1; dimension: y is 2; measure: c is count() }; group_by: x, y; aggregate: c }').toTranslate();
|
|
990
|
+
});
|
|
958
991
|
});
|
|
959
|
-
|
|
960
|
-
|
|
992
|
+
// TODO ENABLE_M4_WARNINGS: unskip when we have an M4 warning flag
|
|
993
|
+
describe.skip('declare/query join warnings', () => {
|
|
994
|
+
test('declare warning in query', () => {
|
|
995
|
+
expect((0, test_translator_1.markSource) `query: a -> { declare: ${'x is 1'}; group_by: x, y }`).toTranslateWithWarnings('`declare:` is deprecated; use `dimension:` or `measure:` inside a source or `extend:` block');
|
|
996
|
+
});
|
|
997
|
+
test('declare warning in source', () => {
|
|
998
|
+
expect((0, test_translator_1.markSource) `source: a2 is a { declare: ${'x is 1'} }`).toTranslateWithWarnings('`declare:` is deprecated; use `dimension:` or `measure:` inside a source or `extend:` block');
|
|
999
|
+
});
|
|
1000
|
+
test('joins in query', () => {
|
|
1001
|
+
expect((0, test_translator_1.markSource) `query: a -> { ${'join_one: b on true'}; ${'join_many: c is b on true'}; ${'join_cross: d is b on true'}; group_by: b.astr }`).toTranslateWithWarnings('Joins in queries are deprecated, move into an `extend:` block.', 'Joins in queries are deprecated, move into an `extend:` block.', 'Joins in queries are deprecated, move into an `extend:` block.');
|
|
1002
|
+
});
|
|
961
1003
|
});
|
|
962
1004
|
test('refine query with extended source', () => {
|
|
963
1005
|
const m = new test_translator_1.TestTranslator(`
|