@malloydata/malloy 0.0.88-dev231002231014 → 0.0.88-dev231002235732

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.
Files changed (50) hide show
  1. package/dist/lang/ast/elements/define-query.d.ts +3 -3
  2. package/dist/lang/ast/elements/define-query.js +9 -4
  3. package/dist/lang/ast/elements/define-source.d.ts +3 -3
  4. package/dist/lang/ast/elements/define-source.js +12 -4
  5. package/dist/lang/ast/elements/pipeline-desc.d.ts +1 -0
  6. package/dist/lang/ast/elements/pipeline-desc.js +3 -0
  7. package/dist/lang/ast/elements/source-query-nodes.d.ts +72 -0
  8. package/dist/lang/ast/elements/source-query-nodes.js +368 -0
  9. package/dist/lang/ast/elements/source-query.d.ts +11 -0
  10. package/dist/lang/ast/{query-elements/run-query.js → elements/source-query.js} +32 -21
  11. package/dist/lang/ast/index.d.ts +2 -2
  12. package/dist/lang/ast/index.js +2 -2
  13. package/dist/lang/ast/query-elements/anonymous-query.d.ts +3 -3
  14. package/dist/lang/ast/query-elements/anonymous-query.js +15 -8
  15. package/dist/lang/ast/query-elements/existing-query.js +1 -1
  16. package/dist/lang/ast/query-items/field-references.d.ts +4 -0
  17. package/dist/lang/ast/query-items/field-references.js +11 -1
  18. package/dist/lang/ast/query-items/typecheck_utils.js +5 -5
  19. package/dist/lang/ast/query-properties/joins.d.ts +7 -5
  20. package/dist/lang/ast/query-properties/joins.js +22 -8
  21. package/dist/lang/ast/sources/sql-source.js +5 -0
  22. package/dist/lang/ast/sql-elements/sql-string.d.ts +2 -2
  23. package/dist/lang/ast/sql-elements/sql-string.js +19 -9
  24. package/dist/lang/ast/types/malloy-element.d.ts +3 -1
  25. package/dist/lang/ast/types/malloy-element.js +16 -5
  26. package/dist/lang/lib/Malloy/MalloyParser.d.ts +179 -184
  27. package/dist/lang/lib/Malloy/MalloyParser.js +3141 -2928
  28. package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +147 -199
  29. package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +88 -120
  30. package/dist/lang/malloy-to-ast.d.ts +16 -15
  31. package/dist/lang/malloy-to-ast.js +147 -141
  32. package/dist/lang/parse-tree-walkers/document-symbol-walker.js +1 -1
  33. package/dist/lang/parse-utils.js +2 -2
  34. package/dist/lang/test/annotation.spec.js +35 -46
  35. package/dist/lang/test/document-symbol-walker.spec.js +2 -2
  36. package/dist/lang/test/expressions.spec.js +16 -16
  37. package/dist/lang/test/imports.spec.js +10 -8
  38. package/dist/lang/test/literals.spec.js +4 -4
  39. package/dist/lang/test/locations.spec.js +82 -80
  40. package/dist/lang/test/parse-expects.js +5 -1
  41. package/dist/lang/test/parse.spec.js +173 -117
  42. package/dist/lang/test/query.spec.js +199 -203
  43. package/dist/lang/test/source.spec.js +54 -45
  44. package/dist/lang/test/sql-block.spec.js +19 -12
  45. package/dist/lang/test/test-translator.js +8 -5
  46. package/dist/malloy.js +2 -2
  47. package/package.json +1 -2
  48. package/dist/lang/ast/query-elements/run-query.d.ts +0 -13
  49. package/dist/lang/ast/sources/named-source-or-query.d.ts +0 -10
  50. package/dist/lang/ast/sources/named-source-or-query.js +0 -71
@@ -27,31 +27,31 @@ const test_translator_1 = require("./test-translator");
27
27
  require("./parse-expects");
28
28
  describe('source:', () => {
29
29
  test('table', () => {
30
- expect("source: testA is table('aTable')").toTranslate();
30
+ expect("source: testA is _db_.table('aTable')").toTranslate();
31
31
  });
32
32
  test('shorcut fitlered table', () => {
33
- expect("source: xA is table('aTable') {? astr ~ 'a%' }").toTranslate();
33
+ expect("source: xA is _db_.table('aTable') extend { where: astr ~ 'a%' }").toTranslate();
34
34
  });
35
35
  test('shorcut fitlered table m4warning', () => {
36
36
  expect(`
37
37
  ##! m4warnings
38
- source: xA is conn.table('aTable') extend {? astr ~ 'a%' }
38
+ source: xA is _db_.table('aTable') extend {? astr ~ 'a%' }
39
39
  `).toTranslateWithWarnings('Filter shortcut `{? condition }` is deprecated; use `{ where: condition } instead');
40
40
  });
41
41
  test('fitlered table', () => {
42
- expect("source: testA is table('aTable') { where: astr ~ 'a%' }").toTranslate();
42
+ expect("source: testA is _db_.table('aTable') extend { where: astr ~ 'a%' }").toTranslate();
43
43
  });
44
44
  test('ref source with no refinement', () => {
45
45
  expect('source: testA is a').toTranslate();
46
46
  });
47
- test('from(query)', () => {
48
- expect('source: testA is from(a->{group_by: astr})').toTranslate();
47
+ test('source from query', () => {
48
+ expect('source: testA is a->{group_by: astr}').toTranslate();
49
49
  });
50
50
  test('refine source', () => {
51
- expect('source: aa is a { dimension: a is astr }').toTranslate();
51
+ expect('source: aa is a extend { dimension: a is astr }').toTranslate();
52
52
  });
53
53
  test('source refinement preserves original', () => {
54
- const x = new test_translator_1.TestTranslator('source: na is a + { dimension: one is 1 }');
54
+ const x = new test_translator_1.TestTranslator('source: na is a extend { dimension: one is 1 }');
55
55
  expect(x).toTranslate();
56
56
  const a = x.getSourceDef('a');
57
57
  if (a) {
@@ -62,23 +62,24 @@ describe('source:', () => {
62
62
  });
63
63
  describe('source properties', () => {
64
64
  test('single dimension', () => {
65
- expect('source: aa is a { dimension: x is 1 }').toTranslate();
65
+ expect('source: aa is a extend { dimension: x is 1 }').toTranslate();
66
66
  });
67
67
  test('multiple dimensions', () => {
68
68
  expect(`
69
- source: aa is a {
69
+ source: aa is a extend {
70
70
  dimension:
71
71
  x is 1
72
72
  y is 2
73
73
  }
74
74
  `).toTranslate();
75
75
  });
76
- test('single declare', () => {
77
- expect('source: aa is a { declare: x is 1 }').toTranslate();
76
+ test('single declare ok b4 m4', () => {
77
+ expect('##! -m4warnings\nsource: aa is a extend { declare: x is 1 }').toTranslate();
78
78
  });
79
- test('multiple declare', () => {
79
+ test('multiple declare ok b4 m4', () => {
80
80
  expect(`
81
- source: aa is a {
81
+ ##! -m4warnings
82
+ source: aa is a extend {
82
83
  declare:
83
84
  x is 1
84
85
  y is 2
@@ -86,11 +87,11 @@ describe('source:', () => {
86
87
  `).toTranslate();
87
88
  });
88
89
  test('single measure', () => {
89
- expect('source: aa is a { measure: x is count() }').toTranslate();
90
+ expect('source: aa is a extend { measure: x is count() }').toTranslate();
90
91
  });
91
92
  test('multiple measures', () => {
92
93
  expect(`
93
- source: aa is a {
94
+ source: aa is a extend {
94
95
  measure:
95
96
  x is count()
96
97
  y is x * x
@@ -98,11 +99,11 @@ describe('source:', () => {
98
99
  `).toTranslate();
99
100
  });
100
101
  test('single where', () => {
101
- expect('source: aa is a { where: ai > 10 }').toTranslate();
102
+ expect('source: aa is a extend { where: ai > 10 }').toTranslate();
102
103
  });
103
104
  test('multiple where', () => {
104
105
  expect(`
105
- source: aa is a {
106
+ source: aa is a extend {
106
107
  where:
107
108
  ai > 10,
108
109
  af < 1000
@@ -111,9 +112,9 @@ describe('source:', () => {
111
112
  });
112
113
  test('where clause can use the join namespace in source refined query', () => {
113
114
  expect(`
114
- source: flights is table('malloytest.flights') + {
115
+ source: flights is _db_.table('malloytest.flights') extend {
115
116
  view: boo is {
116
- join_one: carriers is table('malloytest.carriers') on carrier = carriers.code
117
+ extend: { join_one: carriers is _db_.table('malloytest.carriers') on carrier = carriers.code }
117
118
  where: carriers.code = 'WN' | 'AA'
118
119
  group_by: carriers.nickname
119
120
  aggregate: flight_count is count()
@@ -122,38 +123,38 @@ describe('source:', () => {
122
123
  });
123
124
  describe('joins', () => {
124
125
  test('with', () => {
125
- expect('source: x is a { join_one: b with astr }').toTranslate();
126
+ expect('source: x is a extend { join_one: b with astr }').toTranslate();
126
127
  });
127
128
  test('with', () => {
128
- expect((0, test_translator_1.model) `source: x is a { join_one: y is b with astr }`).toTranslate();
129
+ expect((0, test_translator_1.model) `source: x is a extend { join_one: y is b with astr }`).toTranslate();
129
130
  });
130
131
  test('with dotted ref', () => {
131
- expect((0, test_translator_1.model) `source: x is ab { join_one: xz is a with b.astr }`).toTranslate();
132
+ expect((0, test_translator_1.model) `source: x is ab extend { join_one: xz is a with b.astr }`).toTranslate();
132
133
  });
133
134
  test('one on', () => {
134
- expect((0, test_translator_1.model) `source: x is a { join_one: b on astr = b.astr }`).toTranslate();
135
+ expect((0, test_translator_1.model) `source: x is a extend { join_one: b on astr = b.astr }`).toTranslate();
135
136
  });
136
137
  test('one is on', () => {
137
- expect('source: x is a { join_one: y is b on astr = y.astr }').toTranslate();
138
+ expect('source: x is a extend { join_one: y is b on astr = y.astr }').toTranslate();
138
139
  });
139
140
  test('many on', () => {
140
- expect('source: nab is a { join_many: b on astr = b.astr }').toTranslate();
141
+ expect('source: nab is a extend { join_many: b on astr = b.astr }').toTranslate();
141
142
  });
142
143
  test('many is on', () => {
143
- expect('source: y is a { join_many: x is b on astr = x.astr }').toTranslate();
144
+ expect('source: y is a extend { join_many: x is b on astr = x.astr }').toTranslate();
144
145
  });
145
146
  test('cross', () => {
146
- expect('source: nab is a { join_cross: b }').toTranslate();
147
+ expect('source: nab is a extend { join_cross: b }').toTranslate();
147
148
  });
148
149
  test('cross is', () => {
149
- expect('source: nab is a { join_cross: xb is b }').toTranslate();
150
+ expect('source: nab is a extend { join_cross: xb is b }').toTranslate();
150
151
  });
151
152
  test('cross on', () => {
152
- expect('source: nab is a { join_cross: b on true}').toTranslate();
153
+ expect('source: nab is a extend { join_cross: b on true}').toTranslate();
153
154
  });
154
155
  test('multiple joins', () => {
155
156
  expect(`
156
- source: nab is a {
157
+ source: nab is a extend {
157
158
  join_one:
158
159
  b with astr,
159
160
  br is b with astr
@@ -162,20 +163,28 @@ describe('source:', () => {
162
163
  });
163
164
  test('with requires primary key', () => {
164
165
  expect((0, test_translator_1.markSource) `
165
- source: nb is b {
166
- join_one: ${"bb is table('aTable') with astr"}
166
+ source: nb is b extend {
167
+ join_one: ${'bb is _db_.table("aTable") with astr'}
167
168
  }
168
169
  `).translationToFailWith('join_one: Cannot use with unless source has a primary key');
169
170
  });
171
+ test('can join a query without a rename', () => {
172
+ expect(`
173
+ query: aq is a -> {select: *}
174
+ source: aqs is a extend {
175
+ join_one: aq on ai = aq.ai
176
+ }
177
+ `).toTranslate();
178
+ });
170
179
  });
171
180
  test('primary_key', () => {
172
- expect('source: c is a { primary_key: ai }').toTranslate();
181
+ expect('source: c is a extend { primary_key: ai }').toTranslate();
173
182
  });
174
183
  test('rename', () => {
175
- expect('source: c is a { rename: nn is ai }').toTranslate();
184
+ expect('source: c is a extend { rename: nn is ai }').toTranslate();
176
185
  });
177
186
  test('accept single', () => {
178
- const onlyAstr = new test_translator_1.TestTranslator('source: c is a { accept: astr }');
187
+ const onlyAstr = new test_translator_1.TestTranslator('source: c is a extend { accept: astr }');
179
188
  expect(onlyAstr).toTranslate();
180
189
  const c = onlyAstr.getSourceDef('c');
181
190
  if (c) {
@@ -183,10 +192,10 @@ describe('source:', () => {
183
192
  }
184
193
  });
185
194
  test('accept multi', () => {
186
- expect('source: c is a { accept: astr, af }').toTranslate();
195
+ expect('source: c is a extend { accept: astr, af }').toTranslate();
187
196
  });
188
197
  test('except single', () => {
189
- const noAstr = new test_translator_1.TestTranslator('source: c is a { except: astr }');
198
+ const noAstr = new test_translator_1.TestTranslator('source: c is a extend { except: astr }');
190
199
  expect(noAstr).toTranslate();
191
200
  const c = noAstr.getSourceDef('c');
192
201
  if (c) {
@@ -195,7 +204,7 @@ describe('source:', () => {
195
204
  }
196
205
  });
197
206
  test('except multi', () => {
198
- expect('source: c is a { except: astr, af }').toTranslate();
207
+ expect('source: c is a extend { except: astr, af }').toTranslate();
199
208
  });
200
209
  test('turtle in a source can be called view', () => {
201
210
  expect('source: c is a extend {view: q is { group_by: astr } }').toTranslate();
@@ -212,8 +221,8 @@ describe('source:', () => {
212
221
  });
213
222
  test('refined explore-query', () => {
214
223
  expect(`
215
- source: abNew is ab {
216
- view: for1 is aturtle {? ai = 1 }
224
+ source: abNew is ab extend {
225
+ view: for1 is aturtle + { where: ai = 1 }
217
226
  }
218
227
  `).toTranslate();
219
228
  });
@@ -221,25 +230,25 @@ describe('source:', () => {
221
230
  expect(`
222
231
  ##! m4warnings
223
232
  source: abNew is ab extend {
224
- view: for1 is aturtle refine {? ai = 1 }
233
+ view: for1 is aturtle + {? ai = 1 }
225
234
  }
226
235
  `).toTranslateWithWarnings('Filter shortcut `{? condition }` is deprecated; use `{ where: condition } instead');
227
236
  });
228
237
  test('chained explore-query', () => {
229
238
  expect(`
230
- source: c is a {
239
+ source: c is a extend {
231
240
  view: chain is {
232
241
  group_by: astr
233
242
  } -> {
234
243
  top: 10; order_by: astr
235
- project: *
244
+ select: *
236
245
  }
237
246
  }
238
247
  `).toTranslate();
239
248
  });
240
249
  test('multiple explore-query', () => {
241
250
  expect(`
242
- source: abNew is ab {
251
+ source: abNew is ab extend {
243
252
  view:
244
253
  q1 is { group_by: astr },
245
254
  q2 is { group_by: ai }
@@ -61,6 +61,7 @@ describe('sql:', () => {
61
61
  }
62
62
  test('definition', () => {
63
63
  const model = new test_translator_1.TestTranslator(`
64
+ ##! -m4warnings
64
65
  sql: users IS {
65
66
  select: """${selStmt}"""
66
67
  connection: "aConnection"
@@ -83,12 +84,15 @@ describe('sql:', () => {
83
84
  if ((0, model_1.isSQLBlockStruct)(expectThis)) {
84
85
  expectThis.declaredSQLBlock = true;
85
86
  }
86
- expect(unlocatedStructDef(model.sqlBlocks[0])).toEqual(expectThis);
87
+ const got = unlocatedStructDef(model.sqlBlocks[0]);
88
+ delete got.modelAnnotation;
89
+ expect(got).toEqual(expectThis);
87
90
  }
88
91
  }
89
92
  });
90
93
  test('source from sql', () => {
91
94
  const model = new test_translator_1.TestTranslator(`
95
+ ##! -m4warnings
92
96
  sql: users IS { select: """${selStmt}""" }
93
97
  source: malloyUsers is from_sql(users) { primary_key: ai }
94
98
  `);
@@ -110,26 +114,26 @@ describe('sql:', () => {
110
114
  });
111
115
  test('source from imported sql-based-source', () => {
112
116
  const createModel = `
113
- sql: users IS { select: """${selStmt}""" }
114
- source: malloyUsers is from_sql(users) { primary_key: ai }
117
+ source: malloyUsers is _db_.sql('${selStmt}') extend { primary_key: ai }
115
118
  `;
116
119
  const model = new test_translator_1.TestTranslator(`
117
120
  import "createModel.malloy"
118
121
  source: importUsers is malloyUsers
119
- query: malloyUsers -> { project: * }
120
- query: importUsers -> { project: * }
122
+ run: malloyUsers -> { select: * }
123
+ run: importUsers -> { select: * }
121
124
  `);
122
125
  model.importZone.define('internal://test/langtests/createModel.malloy', createModel);
123
126
  expect(model).toParse();
124
127
  const needReq = model.translate();
125
128
  const needs = needReq === null || needReq === void 0 ? void 0 : needReq.compileSQL;
126
129
  expect(needs).toBeDefined();
127
- const sql = (0, sql_block_1.makeSQLBlock)([{ sql: selStmt }]);
130
+ const sql = (0, sql_block_1.makeSQLBlock)([{ sql: selStmt }], '_db_');
128
131
  model.update({ compileSQL: { [sql.name]: makeSchemaResponse(sql) } });
129
132
  expect(model).toTranslate();
130
133
  });
131
134
  it('simple turducken', () => {
132
135
  const m = new test_translator_1.TestTranslator(`
136
+ ##! -m4warnings
133
137
  sql: someSql is {
134
138
  select: """SELECT * FROM %{ a -> { group_by: astr } } WHERE 1=1"""
135
139
  }
@@ -148,6 +152,7 @@ describe('sql:', () => {
148
152
  });
149
153
  it('old style ', () => {
150
154
  const m = new test_translator_1.TestTranslator(`
155
+ ##! -m4warnings
151
156
  sql: someSql is {
152
157
  select: """SELECT * FROM %{ a -> { group_by: astr } } WHERE 1=1"""
153
158
  }
@@ -168,14 +173,14 @@ describe('sql:', () => {
168
173
  const m = new test_translator_1.TestTranslator(`
169
174
  run: duckdb.sql("""
170
175
  SELECT * from (%{
171
- duckdb.sql("""SELECT 2 as two""") {
172
- query: b is {
176
+ duckdb.sql("""SELECT 2 as two""") extend {
177
+ view: b is {
173
178
  nest: c is {
174
179
  extend: {
175
180
  join_one: d is duckdb.sql("""
176
181
  SELECT * from (%{
177
- duckdb.sql("""SELECT 3 as three""") {
178
- query: b is {
182
+ duckdb.sql("""SELECT 3 as three""") extend {
183
+ view: b is {
179
184
  nest: c is {
180
185
  extend: {
181
186
  join_one: d is duckdb.sql("""SELECT 4 as four""") on three = d.four - 1
@@ -198,6 +203,7 @@ describe('sql:', () => {
198
203
  });
199
204
  it('model preserved', () => {
200
205
  const shouldBeOK = `
206
+ ##! -m4warnings
201
207
  source: newa is a
202
208
  sql: someSql is { select: """${selStmt}""" }
203
209
  source: newaa is newa
@@ -211,9 +217,10 @@ describe('sql:', () => {
211
217
  model.update({ compileSQL: { [sql.name]: makeSchemaResponse(sql) } });
212
218
  expect(model).toTranslate();
213
219
  });
214
- test('source from extended sql-based-source', () => {
220
+ test('pre m4 source from extended sql-based-source', () => {
215
221
  var _a, _b;
216
222
  const model = new test_translator_1.TestTranslator(`
223
+ ##! -m4warnings
217
224
  sql: sql_block IS { select: """${selStmt}""" }
218
225
  source: malloy_source is from_sql(sql_block) { primary_key: ai }
219
226
  `);
@@ -223,7 +230,7 @@ describe('sql:', () => {
223
230
  const modelDef = (_b = (_a = model === null || model === void 0 ? void 0 : model.translate()) === null || _a === void 0 ? void 0 : _a.translated) === null || _b === void 0 ? void 0 : _b.modelDef;
224
231
  // this tests the underlying api that .extendModel calls
225
232
  const extModel = new parse_malloy_1.MalloyTranslator('sqlblocktest://main');
226
- extModel.importZone.define('sqlblocktest://main', 'query: malloy_source -> { project: * }');
233
+ extModel.importZone.define('sqlblocktest://main', 'run: malloy_source -> { select: * }');
227
234
  const tr = extModel.translate(modelDef);
228
235
  // because extModel is not a TestTranslator we can't use the hotness
229
236
  expect(tr.problems).toEqual([]);
@@ -210,20 +210,23 @@ class TestTranslator extends parse_malloy_1.MalloyTranslator {
210
210
  /*
211
211
  * All test source files can assume that an import of this
212
212
  * model has already happened.
213
- * source: a is table('aTable') { primary_key: astr }
213
+ *
214
+ * Also the following tables will be available on _db_
215
+ * aTable, malloytest.carriers, malloytest.flights, malloytest.airports
216
+ *
217
+ * source: a is _db_.table('aTable') extend { primary_key: astr }
214
218
  * source: b is a
215
- * source: ab is a {
219
+ * source: ab is a extend {
216
220
  * join_one: b with astr
217
221
  * measure: acount is count()
218
222
  * query: aturtle is { group_by: astr; aggregate: acount }
219
223
  * }
220
- * Also the following tables will be available
221
- * 'aTable', 'malloytest.carriers'
222
224
  */
223
225
  this.internalModel = {
224
226
  name: testURI,
225
227
  exports: [],
226
228
  contents: {
229
+ _db_: { type: 'connection', name: '_db_' },
227
230
  a: { ...exports.aTableDef, primaryKey: 'astr', as: 'a' },
228
231
  b: { ...exports.aTableDef, primaryKey: 'astr', as: 'b' },
229
232
  ab: {
@@ -273,7 +276,7 @@ class TestTranslator extends parse_malloy_1.MalloyTranslator {
273
276
  }
274
277
  for (const tableName in mockSchema) {
275
278
  this.schemaZone.define(tableName, mockSchema[tableName]);
276
- this.schemaZone.define('conn:' + tableName, mockSchema[tableName]);
279
+ this.schemaZone.define(`_db_:${tableName}`, mockSchema[tableName]);
277
280
  }
278
281
  }
279
282
  translate() {
package/dist/malloy.js CHANGED
@@ -1830,9 +1830,9 @@ class ModelMaterializer extends FluentState {
1830
1830
  -> {
1831
1831
  where: fieldType = 'string'
1832
1832
  group_by: fieldName
1833
- aggregate: cardinality is count(distinct fieldValue)
1833
+ aggregate: cardinality is count(fieldValue)
1834
1834
  nest: values is {
1835
- project: fieldValue, weight
1835
+ select: fieldValue, weight
1836
1836
  order_by: weight desc
1837
1837
  limit: ${limit}
1838
1838
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.88-dev231002231014",
3
+ "version": "0.0.88-dev231002235732",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,7 +15,6 @@
15
15
  "scripts": {
16
16
  "test": "jest --config=../../jest.config.js",
17
17
  "build-parser": "node src/lang/grammar/build_parser.js",
18
- "testLang": "npm run test --testPathPattern=packages/malloy/src/lang",
19
18
  "clean": "tsc --build --clean && rm -rf src/lang/lib dist",
20
19
  "build": "npm run build-parser && tsc --build",
21
20
  "malloyc": "ts-node ../../scripts/malloy-to-json",
@@ -1,13 +0,0 @@
1
- import { Annotation } from '../../../model';
2
- import { DocStatement, Document, MalloyElement } from '../types/malloy-element';
3
- import { Noteable, extendNoteMethod } from '../types/noteable';
4
- import { QueryElement } from '../types/query-element';
5
- export declare class RunQuery extends MalloyElement implements DocStatement, Noteable {
6
- readonly theQuery: QueryElement;
7
- elementType: string;
8
- note?: Annotation;
9
- readonly isNoteableObj = true;
10
- extendNote: typeof extendNoteMethod;
11
- constructor(theQuery: QueryElement);
12
- execute(doc: Document): void;
13
- }
@@ -1,10 +0,0 @@
1
- import { StructDef } from '../../../model';
2
- import { Source } from '../elements/source';
3
- import { ModelEntryReference } from '../types/malloy-element';
4
- export declare class NamedSourceOrQuery extends Source {
5
- readonly ref: ModelEntryReference;
6
- elementType: string;
7
- constructor(ref: ModelEntryReference);
8
- private getSource;
9
- structDef(): StructDef;
10
- }
@@ -1,71 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright 2023 Google LLC
4
- *
5
- * Permission is hereby granted, free of charge, to any person obtaining
6
- * a copy of this software and associated documentation files
7
- * (the "Software"), to deal in the Software without restriction,
8
- * including without limitation the rights to use, copy, modify, merge,
9
- * publish, distribute, sublicense, and/or sell copies of the Software,
10
- * and to permit persons to whom the Software is furnished to do so,
11
- * subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be
14
- * included in all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
- */
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.NamedSourceOrQuery = void 0;
26
- const source_1 = require("../elements/source");
27
- const error_factory_1 = require("../error-factory");
28
- const existing_query_1 = require("../query-elements/existing-query");
29
- const named_source_1 = require("./named-source");
30
- const query_source_1 = require("./query-source");
31
- class NamedSourceOrQuery extends source_1.Source {
32
- constructor(ref) {
33
- super();
34
- this.ref = ref;
35
- this.elementType = 'namedSourceOrQuery';
36
- this.has({ ref: ref });
37
- }
38
- getSource() {
39
- const modelEnt = this.modelEntry(this.ref);
40
- const entry = modelEnt === null || modelEnt === void 0 ? void 0 : modelEnt.entry;
41
- if (!entry) {
42
- const undefMsg = `Undefined query or source '${this.ref.refString}'`;
43
- this.ref.log(undefMsg);
44
- return;
45
- }
46
- if (entry.type === 'query') {
47
- const existingQuery = new existing_query_1.ExistingQuery();
48
- existingQuery.head = this.ref;
49
- return new query_source_1.QuerySource(existingQuery);
50
- }
51
- else if (entry.type === 'struct') {
52
- return new named_source_1.NamedSource(this.ref);
53
- }
54
- else {
55
- this.log(`'${this.ref.refString}' is a ${entry.type}, not a query or source`);
56
- }
57
- }
58
- structDef() {
59
- var _a;
60
- const source = this.getSource();
61
- this.has({ source });
62
- if (source === undefined) {
63
- return error_factory_1.ErrorFactory.structDef;
64
- }
65
- const ret = source.structDef();
66
- (_a = this.document()) === null || _a === void 0 ? void 0 : _a.rememberToAddModelAnnotations(ret);
67
- return ret;
68
- }
69
- }
70
- exports.NamedSourceOrQuery = NamedSourceOrQuery;
71
- //# sourceMappingURL=named-source-or-query.js.map