@malloydata/malloy-interfaces 0.0.240-dev250311155207 → 0.0.240-dev250311213218
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/index.js +32 -14
- package/dist/nest_unions.spec.js +6 -3
- package/dist/to_malloy.js +27 -5
- package/dist/types.d.ts +32 -23
- package/package.json +1 -1
- package/thrift/malloy.thrift +20 -19
package/dist/index.js
CHANGED
|
@@ -150,10 +150,11 @@ exports.test = {
|
|
|
150
150
|
exports.res = {
|
|
151
151
|
connection_name: 'foo',
|
|
152
152
|
data: {
|
|
153
|
-
kind: '
|
|
154
|
-
|
|
153
|
+
kind: 'array_cell',
|
|
154
|
+
array_value: [
|
|
155
155
|
{
|
|
156
|
-
|
|
156
|
+
kind: 'record_cell',
|
|
157
|
+
record_value: [
|
|
157
158
|
{
|
|
158
159
|
kind: 'string_cell',
|
|
159
160
|
string_value: 'UA',
|
|
@@ -165,7 +166,8 @@ exports.res = {
|
|
|
165
166
|
],
|
|
166
167
|
},
|
|
167
168
|
{
|
|
168
|
-
|
|
169
|
+
kind: 'record_cell',
|
|
170
|
+
record_value: [
|
|
169
171
|
{
|
|
170
172
|
kind: 'string_cell',
|
|
171
173
|
string_value: 'AA',
|
|
@@ -208,7 +210,10 @@ exports.thingy1 = {
|
|
|
208
210
|
exports.thingy123r = {
|
|
209
211
|
definition: {
|
|
210
212
|
kind: 'arrow',
|
|
211
|
-
|
|
213
|
+
source: {
|
|
214
|
+
kind: 'source_reference',
|
|
215
|
+
name: 'flights',
|
|
216
|
+
},
|
|
212
217
|
view: {
|
|
213
218
|
kind: 'view_reference',
|
|
214
219
|
name: 'by_carrier',
|
|
@@ -218,7 +223,10 @@ exports.thingy123r = {
|
|
|
218
223
|
exports.thingyssdfg = {
|
|
219
224
|
definition: {
|
|
220
225
|
kind: 'refinement',
|
|
221
|
-
|
|
226
|
+
base: {
|
|
227
|
+
kind: 'query_reference',
|
|
228
|
+
name: 'flights',
|
|
229
|
+
},
|
|
222
230
|
refinement: {
|
|
223
231
|
kind: 'view_reference',
|
|
224
232
|
name: 'by_carrier',
|
|
@@ -228,7 +236,10 @@ exports.thingyssdfg = {
|
|
|
228
236
|
exports.thingy2asdf = {
|
|
229
237
|
definition: {
|
|
230
238
|
kind: 'arrow',
|
|
231
|
-
|
|
239
|
+
source: {
|
|
240
|
+
kind: 'source_reference',
|
|
241
|
+
name: 'flights',
|
|
242
|
+
},
|
|
232
243
|
view: {
|
|
233
244
|
kind: 'refinement',
|
|
234
245
|
base: {
|
|
@@ -254,7 +265,8 @@ exports.thingy2asdf = {
|
|
|
254
265
|
exports.thingy3 = {
|
|
255
266
|
definition: {
|
|
256
267
|
kind: 'arrow',
|
|
257
|
-
|
|
268
|
+
source: {
|
|
269
|
+
kind: 'source_reference',
|
|
258
270
|
name: 'flights',
|
|
259
271
|
},
|
|
260
272
|
view: {
|
|
@@ -292,7 +304,8 @@ exports.thingy3 = {
|
|
|
292
304
|
exports.thingy3dfdf = {
|
|
293
305
|
definition: {
|
|
294
306
|
kind: 'arrow',
|
|
295
|
-
|
|
307
|
+
source: {
|
|
308
|
+
kind: 'source_reference',
|
|
296
309
|
name: 'flights',
|
|
297
310
|
},
|
|
298
311
|
view: {
|
|
@@ -311,7 +324,8 @@ exports.thingy3dfdf = {
|
|
|
311
324
|
exports.thingy4asdfasdf = {
|
|
312
325
|
definition: {
|
|
313
326
|
kind: 'arrow',
|
|
314
|
-
|
|
327
|
+
source: {
|
|
328
|
+
kind: 'source_reference',
|
|
315
329
|
name: 'flights',
|
|
316
330
|
},
|
|
317
331
|
view: {
|
|
@@ -343,7 +357,8 @@ exports.thingy4asdfasdf = {
|
|
|
343
357
|
exports.thingy4asdfas = {
|
|
344
358
|
definition: {
|
|
345
359
|
kind: 'arrow',
|
|
346
|
-
|
|
360
|
+
source: {
|
|
361
|
+
kind: 'source_reference',
|
|
347
362
|
name: 'flights',
|
|
348
363
|
},
|
|
349
364
|
view: {
|
|
@@ -356,7 +371,8 @@ exports.thingy4asdfas = {
|
|
|
356
371
|
exports.thingy4dfdsfs = {
|
|
357
372
|
definition: {
|
|
358
373
|
kind: 'arrow',
|
|
359
|
-
|
|
374
|
+
source: {
|
|
375
|
+
kind: 'source_reference',
|
|
360
376
|
name: 'flights',
|
|
361
377
|
},
|
|
362
378
|
view: {
|
|
@@ -381,7 +397,8 @@ exports.thingy4dfdsfs = {
|
|
|
381
397
|
exports.thingy4sdfsd = {
|
|
382
398
|
definition: {
|
|
383
399
|
kind: 'arrow',
|
|
384
|
-
|
|
400
|
+
source: {
|
|
401
|
+
kind: 'source_reference',
|
|
385
402
|
name: 'flights',
|
|
386
403
|
},
|
|
387
404
|
view: {
|
|
@@ -408,7 +425,8 @@ exports.thingy4sdfsd = {
|
|
|
408
425
|
exports.thingy4sddfdfsd = {
|
|
409
426
|
definition: {
|
|
410
427
|
kind: 'arrow',
|
|
411
|
-
|
|
428
|
+
source: {
|
|
429
|
+
kind: 'source_reference',
|
|
412
430
|
name: 'flights',
|
|
413
431
|
},
|
|
414
432
|
view: {
|
package/dist/nest_unions.spec.js
CHANGED
|
@@ -12,7 +12,8 @@ describe('unnest unions', () => {
|
|
|
12
12
|
const query = {
|
|
13
13
|
definition: {
|
|
14
14
|
kind: 'arrow',
|
|
15
|
-
|
|
15
|
+
source: {
|
|
16
|
+
kind: 'source_reference',
|
|
16
17
|
name: 'flights',
|
|
17
18
|
},
|
|
18
19
|
view: {
|
|
@@ -38,8 +39,10 @@ describe('unnest unions', () => {
|
|
|
38
39
|
expect((0, nest_unions_1.nestUnions)(query)).toMatchObject({
|
|
39
40
|
definition: {
|
|
40
41
|
arrow: {
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
source: {
|
|
43
|
+
source_reference: {
|
|
44
|
+
name: 'flights',
|
|
45
|
+
},
|
|
43
46
|
},
|
|
44
47
|
view: {
|
|
45
48
|
segment: {
|
package/dist/to_malloy.js
CHANGED
|
@@ -39,11 +39,14 @@ function codeFromFragments(fragments, { tabWidth } = { tabWidth: 2 }) {
|
|
|
39
39
|
}
|
|
40
40
|
return code;
|
|
41
41
|
}
|
|
42
|
-
function wrap(open, block, close) {
|
|
42
|
+
function wrap(open, block, close, options) {
|
|
43
|
+
var _a;
|
|
43
44
|
if (block.includes(NEWLINE)) {
|
|
44
45
|
return [open, NEWLINE, INDENT, ...block, NEWLINE, OUTDENT, close];
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
+
const spaces = (_a = options === null || options === void 0 ? void 0 : options.spaces) !== null && _a !== void 0 ? _a : true;
|
|
48
|
+
const maybeSpace = spaces ? ' ' : '';
|
|
49
|
+
return [open, maybeSpace, ...block, maybeSpace, close];
|
|
47
50
|
}
|
|
48
51
|
function escapeString(str) {
|
|
49
52
|
return { contents: str, quoteCharacter: '"' }; // TODO
|
|
@@ -153,7 +156,7 @@ function referenceToFragments(reference) {
|
|
|
153
156
|
parameterFragments.push(',', NEWLINE);
|
|
154
157
|
}
|
|
155
158
|
}
|
|
156
|
-
fragments.push(...wrap('(', parameterFragments, ')'));
|
|
159
|
+
fragments.push(...wrap('(', parameterFragments, ')', { spaces: false }));
|
|
157
160
|
}
|
|
158
161
|
return fragments;
|
|
159
162
|
}
|
|
@@ -164,11 +167,24 @@ function queryToFragments(query) {
|
|
|
164
167
|
fragments.push(...queryDefinitionToFragments(query.definition));
|
|
165
168
|
return fragments;
|
|
166
169
|
}
|
|
170
|
+
function queryArrowSourceToFragments(query) {
|
|
171
|
+
const fragments = [];
|
|
172
|
+
switch (query.kind) {
|
|
173
|
+
case 'source_reference': {
|
|
174
|
+
fragments.push(...referenceToFragments(query));
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
case 'refinement':
|
|
178
|
+
fragments.push(...queryDefinitionToFragments(query));
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
return fragments;
|
|
182
|
+
}
|
|
167
183
|
function queryDefinitionToFragments(query) {
|
|
168
184
|
const fragments = [];
|
|
169
185
|
switch (query.kind) {
|
|
170
186
|
case 'arrow': {
|
|
171
|
-
fragments.push(...
|
|
187
|
+
fragments.push(...queryArrowSourceToFragments(query.source));
|
|
172
188
|
fragments.push(' -> ');
|
|
173
189
|
fragments.push(...viewDefinitionToFragments(query.view));
|
|
174
190
|
break;
|
|
@@ -178,7 +194,13 @@ function queryDefinitionToFragments(query) {
|
|
|
178
194
|
break;
|
|
179
195
|
}
|
|
180
196
|
case 'refinement': {
|
|
181
|
-
|
|
197
|
+
const baseFragments = queryDefinitionToFragments(query.base);
|
|
198
|
+
if (query.base.kind === 'arrow') {
|
|
199
|
+
fragments.push(...wrap('(', baseFragments, ')', { spaces: false }));
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
fragments.push(...baseFragments);
|
|
203
|
+
}
|
|
182
204
|
fragments.push(' + ');
|
|
183
205
|
fragments.push(...viewDefinitionToFragments(query.refinement));
|
|
184
206
|
break;
|
package/dist/types.d.ts
CHANGED
|
@@ -54,8 +54,8 @@ export type BooleanLiteral = {
|
|
|
54
54
|
boolean_value: boolean;
|
|
55
55
|
};
|
|
56
56
|
export type BooleanType = {};
|
|
57
|
-
export type CellType = 'string_cell' | 'boolean_cell' | 'date_cell' | 'timestamp_cell' | 'number_cell' | 'json_cell' | 'record_cell' | 'array_cell' | '
|
|
58
|
-
export type Cell = CellWithStringCell | CellWithBooleanCell | CellWithDateCell | CellWithTimestampCell | CellWithNumberCell | CellWithJSONCell | CellWithRecordCell | CellWithArrayCell |
|
|
57
|
+
export type CellType = 'string_cell' | 'boolean_cell' | 'date_cell' | 'timestamp_cell' | 'number_cell' | 'json_cell' | 'record_cell' | 'array_cell' | 'null_cell' | 'sql_native_cell';
|
|
58
|
+
export type Cell = CellWithStringCell | CellWithBooleanCell | CellWithDateCell | CellWithTimestampCell | CellWithNumberCell | CellWithJSONCell | CellWithRecordCell | CellWithArrayCell | CellWithNullCell | CellWithSQLNativeCell;
|
|
59
59
|
export type CellWithStringCell = {
|
|
60
60
|
kind: 'string_cell';
|
|
61
61
|
} & StringCell;
|
|
@@ -80,9 +80,12 @@ export type CellWithRecordCell = {
|
|
|
80
80
|
export type CellWithArrayCell = {
|
|
81
81
|
kind: 'array_cell';
|
|
82
82
|
} & ArrayCell;
|
|
83
|
-
export type
|
|
84
|
-
kind: '
|
|
85
|
-
} &
|
|
83
|
+
export type CellWithNullCell = {
|
|
84
|
+
kind: 'null_cell';
|
|
85
|
+
} & NullCell;
|
|
86
|
+
export type CellWithSQLNativeCell = {
|
|
87
|
+
kind: 'sql_native_cell';
|
|
88
|
+
} & SQLNativeCell;
|
|
86
89
|
export type CompileModelRequest = {
|
|
87
90
|
model_url: string;
|
|
88
91
|
extend_model_url?: string;
|
|
@@ -125,14 +128,14 @@ export type Connection = {
|
|
|
125
128
|
name: string;
|
|
126
129
|
dialect?: string;
|
|
127
130
|
};
|
|
128
|
-
export type DataType = '
|
|
129
|
-
export type Data =
|
|
130
|
-
export type
|
|
131
|
-
kind: '
|
|
131
|
+
export type DataType = 'record_cell' | 'array_cell';
|
|
132
|
+
export type Data = DataWithRecordCell | DataWithArrayCell;
|
|
133
|
+
export type DataWithRecordCell = {
|
|
134
|
+
kind: 'record_cell';
|
|
132
135
|
} & RecordCell;
|
|
133
|
-
export type
|
|
134
|
-
kind: '
|
|
135
|
-
} &
|
|
136
|
+
export type DataWithArrayCell = {
|
|
137
|
+
kind: 'array_cell';
|
|
138
|
+
} & ArrayCell;
|
|
136
139
|
export type DateCell = {
|
|
137
140
|
date_value: string;
|
|
138
141
|
};
|
|
@@ -274,6 +277,7 @@ export type Nest = {
|
|
|
274
277
|
name?: string;
|
|
275
278
|
view: View;
|
|
276
279
|
};
|
|
280
|
+
export type NullCell = {};
|
|
277
281
|
export type NullLiteral = {};
|
|
278
282
|
export type NumberCell = {
|
|
279
283
|
number_value: number;
|
|
@@ -308,9 +312,17 @@ export type Query = {
|
|
|
308
312
|
annotations?: Array<Annotation>;
|
|
309
313
|
};
|
|
310
314
|
export type QueryArrow = {
|
|
311
|
-
|
|
315
|
+
source: QueryArrowSource;
|
|
312
316
|
view: ViewDefinition;
|
|
313
317
|
};
|
|
318
|
+
export type QueryArrowSourceType = 'refinement' | 'source_reference';
|
|
319
|
+
export type QueryArrowSource = QueryArrowSourceWithRefinement | QueryArrowSourceWithSourceReference;
|
|
320
|
+
export type QueryArrowSourceWithRefinement = {
|
|
321
|
+
kind: 'refinement';
|
|
322
|
+
} & QueryRefinement;
|
|
323
|
+
export type QueryArrowSourceWithSourceReference = {
|
|
324
|
+
kind: 'source_reference';
|
|
325
|
+
} & Reference;
|
|
314
326
|
export type QueryDefinitionType = 'arrow' | 'query_reference' | 'refinement';
|
|
315
327
|
export type QueryDefinition = QueryDefinitionWithArrow | QueryDefinitionWithQueryReference | QueryDefinitionWithRefinement;
|
|
316
328
|
export type QueryDefinitionWithArrow = {
|
|
@@ -331,7 +343,7 @@ export type QueryInfo = {
|
|
|
331
343
|
location?: Location;
|
|
332
344
|
};
|
|
333
345
|
export type QueryRefinement = {
|
|
334
|
-
|
|
346
|
+
base: QueryDefinition;
|
|
335
347
|
refinement: ViewDefinition;
|
|
336
348
|
};
|
|
337
349
|
export type Range = {
|
|
@@ -355,9 +367,9 @@ export type Result = {
|
|
|
355
367
|
schema: Schema;
|
|
356
368
|
sql?: string;
|
|
357
369
|
connection_name: string;
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
370
|
+
annotations?: Array<Annotation>;
|
|
371
|
+
model_annotations?: Array<Annotation>;
|
|
372
|
+
query_timezone?: string;
|
|
361
373
|
};
|
|
362
374
|
export type RunIndexQueryRequest = {
|
|
363
375
|
model_url: string;
|
|
@@ -378,6 +390,9 @@ export type RunQueryResponse = {
|
|
|
378
390
|
logs?: Array<LogMessage>;
|
|
379
391
|
compiler_needs?: CompilerNeeds;
|
|
380
392
|
};
|
|
393
|
+
export type SQLNativeCell = {
|
|
394
|
+
sql_native_value: string;
|
|
395
|
+
};
|
|
381
396
|
export type SQLNativeType = {
|
|
382
397
|
sql_type?: string;
|
|
383
398
|
};
|
|
@@ -407,12 +422,6 @@ export type StringLiteral = {
|
|
|
407
422
|
string_value: string;
|
|
408
423
|
};
|
|
409
424
|
export type StringType = {};
|
|
410
|
-
export type Table = {
|
|
411
|
-
rows: Array<Row>;
|
|
412
|
-
};
|
|
413
|
-
export type TableCell = {
|
|
414
|
-
table_value: Table;
|
|
415
|
-
};
|
|
416
425
|
export type TimeTruncationFieldReference = {
|
|
417
426
|
field_reference: Reference;
|
|
418
427
|
truncation: TimestampTimeframe;
|
package/package.json
CHANGED
package/thrift/malloy.thrift
CHANGED
|
@@ -305,7 +305,6 @@ stages: [
|
|
|
305
305
|
]
|
|
306
306
|
}
|
|
307
307
|
]
|
|
308
|
-
|
|
309
308
|
*/
|
|
310
309
|
|
|
311
310
|
struct Query {
|
|
@@ -319,13 +318,18 @@ union QueryDefinition {
|
|
|
319
318
|
3: QueryRefinement refinement,
|
|
320
319
|
}
|
|
321
320
|
|
|
321
|
+
union QueryArrowSource {
|
|
322
|
+
3: QueryRefinement refinement,
|
|
323
|
+
2: Reference source_reference,
|
|
324
|
+
}
|
|
325
|
+
|
|
322
326
|
struct QueryArrow {
|
|
323
|
-
1: required
|
|
327
|
+
1: required QueryArrowSource source,
|
|
324
328
|
2: required ViewDefinition view,
|
|
325
329
|
}
|
|
326
330
|
|
|
327
331
|
struct QueryRefinement {
|
|
328
|
-
1: required
|
|
332
|
+
1: required QueryDefinition base,
|
|
329
333
|
2: required ViewDefinition refinement,
|
|
330
334
|
}
|
|
331
335
|
|
|
@@ -423,6 +427,8 @@ struct NumberCell {
|
|
|
423
427
|
1: required double number_value,
|
|
424
428
|
}
|
|
425
429
|
|
|
430
|
+
struct NullCell {}
|
|
431
|
+
|
|
426
432
|
struct TimestampCell {
|
|
427
433
|
1: required string timestamp_value, // TODO another way to represent dates?
|
|
428
434
|
}
|
|
@@ -435,6 +441,10 @@ struct JSONCell {
|
|
|
435
441
|
1: required string json_value,
|
|
436
442
|
}
|
|
437
443
|
|
|
444
|
+
struct SQLNativeCell {
|
|
445
|
+
1: required string sql_native_value,
|
|
446
|
+
}
|
|
447
|
+
|
|
438
448
|
struct ArrayCell {
|
|
439
449
|
1: required list<Cell> array_value,
|
|
440
450
|
}
|
|
@@ -444,10 +454,6 @@ struct RecordCell {
|
|
|
444
454
|
1: required list<Cell> record_value,
|
|
445
455
|
}
|
|
446
456
|
|
|
447
|
-
struct TableCell {
|
|
448
|
-
1: required Table table_value,
|
|
449
|
-
}
|
|
450
|
-
|
|
451
457
|
union Cell {
|
|
452
458
|
1: required StringCell string_cell,
|
|
453
459
|
2: required BooleanCell boolean_cell,
|
|
@@ -457,21 +463,13 @@ union Cell {
|
|
|
457
463
|
6: required JSONCell json_cell, // TODO does this need to be here?
|
|
458
464
|
7: required RecordCell record_cell,
|
|
459
465
|
8: required ArrayCell array_cell,
|
|
460
|
-
9: required
|
|
461
|
-
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
struct Row {
|
|
465
|
-
1: required list<Cell> cells,
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
struct Table {
|
|
469
|
-
1: required list<Row> rows,
|
|
466
|
+
9: required NullCell null_cell,
|
|
467
|
+
10: required SQLNativeCell sql_native_cell,
|
|
470
468
|
}
|
|
471
469
|
|
|
472
470
|
union Data {
|
|
473
|
-
1: required RecordCell
|
|
474
|
-
2: required
|
|
471
|
+
1: required RecordCell record_cell,
|
|
472
|
+
2: required ArrayCell array_cell,
|
|
475
473
|
}
|
|
476
474
|
|
|
477
475
|
// should this be one type "Result" with optional data/sql, or three different types?
|
|
@@ -480,6 +478,9 @@ struct Result {
|
|
|
480
478
|
2: required Schema schema,
|
|
481
479
|
3: optional string sql,
|
|
482
480
|
4: required string connection_name,
|
|
481
|
+
5: optional list<Annotation> annotations,
|
|
482
|
+
6: optional list<Annotation> model_annotations,
|
|
483
|
+
7: optional string query_timezone,
|
|
483
484
|
}
|
|
484
485
|
|
|
485
486
|
/*
|