@malloydata/malloy-tests 0.0.88-dev231002231014 → 0.0.88-dev231003001139
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/api.spec.js +2 -2
- package/dist/api.spec.js.map +1 -1
- package/dist/databases/all/db_index.spec.js +3 -3
- package/dist/databases/all/expr.spec.js +9 -9
- package/dist/databases/all/expr.spec.js.map +1 -1
- package/dist/databases/all/functions.spec.js +3 -3
- package/dist/databases/all/join.spec.js +35 -37
- package/dist/databases/all/join.spec.js.map +1 -1
- package/dist/databases/all/nomodel.spec.js +19 -19
- package/dist/databases/all/nomodel.spec.js.map +1 -1
- package/dist/databases/all/orderby.spec.js +5 -5
- package/dist/databases/all/problems.spec.js +5 -5
- package/dist/databases/all/problems.spec.js.map +1 -1
- package/dist/databases/all/sql_expressions.spec.js +3 -3
- package/dist/databases/all/time.spec.js +10 -10
- package/dist/databases/bigquery/json.spec.js +1 -1
- package/dist/databases/bigquery/malloy_query.spec.js +7 -7
- package/dist/databases/bigquery/time.spec.js +1 -1
- package/dist/databases/bigquery-duckdb/nested_source_table.spec.js +4 -4
- package/dist/databases/bigquery-postgres/multi_connection.spec.js +4 -4
- package/dist/databases/bigquery-postgres/streaming.spec.js +3 -3
- package/dist/databases/bigquery-postgres/streaming.spec.js.map +1 -1
- package/dist/databases/duckdb/duckdb.spec.js +2 -2
- package/dist/databases/postgres/postgres.spec.js +7 -7
- package/dist/render/render.spec.js +12 -12
- package/dist/tags.spec.js +46 -46
- package/dist/tags.spec.js.map +1 -1
- package/dist/util/index.js +8 -8
- package/dist/util/index.js.map +1 -1
- package/package.json +6 -6
- package/src/api.spec.ts +2 -2
- package/src/databases/all/db_index.spec.ts +3 -3
- package/src/databases/all/expr.spec.ts +9 -9
- package/src/databases/all/functions.spec.ts +3 -3
- package/src/databases/all/join.spec.ts +35 -37
- package/src/databases/all/nomodel.spec.ts +19 -19
- package/src/databases/all/orderby.spec.ts +5 -5
- package/src/databases/all/problems.spec.ts +5 -5
- package/src/databases/all/sql_expressions.spec.ts +3 -3
- package/src/databases/all/time.spec.ts +10 -10
- package/src/databases/bigquery/json.spec.ts +1 -1
- package/src/databases/bigquery/malloy_query.spec.ts +7 -7
- package/src/databases/bigquery/time.spec.ts +1 -1
- package/src/databases/bigquery-duckdb/nested_source_table.spec.ts +4 -4
- package/src/databases/bigquery-postgres/multi_connection.spec.ts +4 -4
- package/src/databases/bigquery-postgres/streaming.spec.ts +3 -3
- package/src/databases/duckdb/duckdb.spec.ts +2 -2
- package/src/databases/postgres/postgres.spec.ts +7 -7
- package/src/render/render.spec.ts +12 -12
- package/src/tags.spec.ts +46 -46
- package/src/util/index.ts +8 -8
|
@@ -29,26 +29,26 @@ import '../../util/db-jest-matchers';
|
|
|
29
29
|
|
|
30
30
|
const runtimes = new RuntimeList(databasesFromEnvironmentOr(allDatabases));
|
|
31
31
|
const joinModelText = `
|
|
32
|
-
source: aircraft_models is table('malloytest.aircraft_models') {
|
|
32
|
+
source: aircraft_models is table('malloytest.aircraft_models') extend {
|
|
33
33
|
primary_key: aircraft_model_code
|
|
34
34
|
measure: model_count is count()
|
|
35
|
-
|
|
35
|
+
view: manufacturer_models is {
|
|
36
36
|
group_by: manufacturer
|
|
37
37
|
aggregate: num_models is count()
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
view: manufacturer_seats is {
|
|
40
40
|
group_by: manufacturer
|
|
41
41
|
aggregate: total_seats is seats.sum()
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
source: aircraft is table('malloytest.aircraft'){
|
|
45
|
+
source: aircraft is table('malloytest.aircraft') extend {
|
|
46
46
|
primary_key: tail_num
|
|
47
47
|
measure: aircraft_count is count()
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
source: funnel is
|
|
51
|
-
join_one: seats is
|
|
50
|
+
source: funnel is aircraft_models->manufacturer_models extend {
|
|
51
|
+
join_one: seats is aircraft_models->manufacturer_seats
|
|
52
52
|
with manufacturer
|
|
53
53
|
}
|
|
54
54
|
`;
|
|
@@ -69,11 +69,11 @@ describe('join expression tests', () => {
|
|
|
69
69
|
.loadModel(joinModelText)
|
|
70
70
|
.loadQuery(
|
|
71
71
|
`
|
|
72
|
-
source: a2 is aircraft {
|
|
72
|
+
source: a2 is aircraft extend {
|
|
73
73
|
join_one: aircraft_models with aircraft_model_code
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
run: a2 -> {
|
|
77
77
|
aggregate:
|
|
78
78
|
aircraft_count
|
|
79
79
|
aircraft_models.model_count
|
|
@@ -89,7 +89,7 @@ describe('join expression tests', () => {
|
|
|
89
89
|
.loadModel(joinModelText)
|
|
90
90
|
.loadQuery(
|
|
91
91
|
`
|
|
92
|
-
|
|
92
|
+
run: aircraft {
|
|
93
93
|
join_one: aircraft_models with aircraft_model_code
|
|
94
94
|
} -> {
|
|
95
95
|
aggregate:
|
|
@@ -107,14 +107,14 @@ describe('join expression tests', () => {
|
|
|
107
107
|
.loadModel(joinModelText)
|
|
108
108
|
.loadQuery(
|
|
109
109
|
`
|
|
110
|
-
|
|
111
|
-
join_one: am_facts is
|
|
110
|
+
run: aircraft_models {
|
|
111
|
+
join_one: am_facts is
|
|
112
112
|
aircraft_models->{
|
|
113
113
|
group_by: m is manufacturer
|
|
114
114
|
aggregate: num_models is count()
|
|
115
|
-
}
|
|
115
|
+
} with manufacturer
|
|
116
116
|
} -> {
|
|
117
|
-
|
|
117
|
+
select:
|
|
118
118
|
manufacturer
|
|
119
119
|
am_facts.num_models
|
|
120
120
|
order_by: 2 desc
|
|
@@ -131,13 +131,13 @@ describe('join expression tests', () => {
|
|
|
131
131
|
.loadModel(joinModelText)
|
|
132
132
|
.loadQuery(
|
|
133
133
|
`
|
|
134
|
-
|
|
134
|
+
run:
|
|
135
135
|
aircraft_models-> {
|
|
136
136
|
group_by: m is manufacturer
|
|
137
137
|
aggregate: num_models is count()
|
|
138
138
|
}
|
|
139
139
|
-> {
|
|
140
|
-
|
|
140
|
+
select:
|
|
141
141
|
m
|
|
142
142
|
num_models
|
|
143
143
|
order_by: 2 desc
|
|
@@ -154,19 +154,18 @@ describe('join expression tests', () => {
|
|
|
154
154
|
.loadModel(joinModelText)
|
|
155
155
|
.loadQuery(
|
|
156
156
|
`
|
|
157
|
-
|
|
157
|
+
run: aircraft_models->{
|
|
158
158
|
group_by: m is manufacturer
|
|
159
159
|
aggregate: num_models is count()
|
|
160
|
-
}
|
|
161
|
-
join_one: seats is
|
|
160
|
+
} extend {
|
|
161
|
+
join_one: seats is
|
|
162
162
|
aircraft_models->{
|
|
163
163
|
group_by: m is manufacturer
|
|
164
164
|
aggregate: total_seats is seats.sum()
|
|
165
|
-
}
|
|
166
|
-
) with m
|
|
165
|
+
} with m
|
|
167
166
|
}
|
|
168
167
|
-> {
|
|
169
|
-
|
|
168
|
+
select:
|
|
170
169
|
m
|
|
171
170
|
num_models
|
|
172
171
|
seats.total_seats
|
|
@@ -185,12 +184,11 @@ describe('join expression tests', () => {
|
|
|
185
184
|
.loadModel(joinModelText)
|
|
186
185
|
.loadQuery(
|
|
187
186
|
`
|
|
188
|
-
source: foo is
|
|
189
|
-
join_one: seats is
|
|
190
|
-
with manufacturer
|
|
187
|
+
source: foo is aircraft_models-> manufacturer_models extend {
|
|
188
|
+
join_one: seats is aircraft_models->manufacturer_seats with manufacturer
|
|
191
189
|
}
|
|
192
|
-
|
|
193
|
-
|
|
190
|
+
run: foo-> {
|
|
191
|
+
select:
|
|
194
192
|
manufacturer,
|
|
195
193
|
num_models,
|
|
196
194
|
seats.total_seats
|
|
@@ -209,8 +207,8 @@ describe('join expression tests', () => {
|
|
|
209
207
|
.loadModel(joinModelText)
|
|
210
208
|
.loadQuery(
|
|
211
209
|
`
|
|
212
|
-
|
|
213
|
-
|
|
210
|
+
run: funnel->{
|
|
211
|
+
select:
|
|
214
212
|
manufacturer
|
|
215
213
|
num_models
|
|
216
214
|
seats.total_seats
|
|
@@ -229,13 +227,13 @@ describe('join expression tests', () => {
|
|
|
229
227
|
.loadModel(joinModelText)
|
|
230
228
|
.loadQuery(
|
|
231
229
|
`
|
|
232
|
-
|
|
230
|
+
run: aircraft_models->{
|
|
233
231
|
group_by: manufacturer
|
|
234
232
|
aggregate: f is count()
|
|
235
233
|
}->{
|
|
236
234
|
aggregate: f_sum is f.sum()
|
|
237
235
|
}->{
|
|
238
|
-
|
|
236
|
+
select: f_sum2 is f_sum+1
|
|
239
237
|
}
|
|
240
238
|
`
|
|
241
239
|
)
|
|
@@ -258,8 +256,8 @@ describe('join expression tests', () => {
|
|
|
258
256
|
// join the 4 rows and reference the
|
|
259
257
|
// nested column. should return all the rows.
|
|
260
258
|
// If the unnest is an inner join, we'll get back just 4 rows.
|
|
261
|
-
|
|
262
|
-
join_one: a_states is
|
|
259
|
+
run: table('malloytest.state_facts') {
|
|
260
|
+
join_one: a_states is a_states with state
|
|
263
261
|
}
|
|
264
262
|
-> {
|
|
265
263
|
group_by: state
|
|
@@ -280,14 +278,14 @@ describe('join expression tests', () => {
|
|
|
280
278
|
const result = await runtime
|
|
281
279
|
.loadQuery(
|
|
282
280
|
`
|
|
283
|
-
source: flights is table('malloytest.flights') {
|
|
281
|
+
source: flights is table('malloytest.flights') extend {
|
|
284
282
|
join_one: aircraft is table('malloytest.aircraft')
|
|
285
283
|
on tail_num = aircraft.tail_num
|
|
286
284
|
join_one: aircraft_models is table('malloytest.aircraft_models')
|
|
287
285
|
on aircraft.aircraft_model_code = aircraft_models.aircraft_model_code
|
|
288
286
|
}
|
|
289
287
|
|
|
290
|
-
|
|
288
|
+
run: flights -> {
|
|
291
289
|
group_by: aircraft_models.seats
|
|
292
290
|
aggregate: flight_count is count()
|
|
293
291
|
}
|
|
@@ -306,12 +304,12 @@ describe('join expression tests', () => {
|
|
|
306
304
|
|
|
307
305
|
source: aircraft is table('malloytest.aircraft')
|
|
308
306
|
|
|
309
|
-
source: flights is table('malloytest.flights'){
|
|
307
|
+
source: flights is table('malloytest.flights') extend {
|
|
310
308
|
join_one: aircraft on aircraft.tail_num = tail_num
|
|
311
309
|
join_one: aircraft_models on aircraft_models.aircraft_model_code = aircraft.aircraft_model_code
|
|
312
310
|
}
|
|
313
311
|
|
|
314
|
-
|
|
312
|
+
run: flights-> {
|
|
315
313
|
group_by: testingtwo is aircraft_models.model
|
|
316
314
|
}
|
|
317
315
|
`
|
|
@@ -325,7 +323,7 @@ describe('join expression tests', () => {
|
|
|
325
323
|
const result = await runtime
|
|
326
324
|
.loadQuery(
|
|
327
325
|
`
|
|
328
|
-
|
|
326
|
+
run: table('malloytest.state_facts') -> {
|
|
329
327
|
join_one: sf is table('malloytest.state_facts') on sf.state = state
|
|
330
328
|
aggregate: x is sf.births.sum() { ? state = 'CA' }
|
|
331
329
|
}
|
|
@@ -111,7 +111,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
111
111
|
{
|
|
112
112
|
dimension: lower_state is lower(state)
|
|
113
113
|
}
|
|
114
|
-
-> {
|
|
114
|
+
-> {select: lower_state}
|
|
115
115
|
`
|
|
116
116
|
)
|
|
117
117
|
.run();
|
|
@@ -250,7 +250,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
250
250
|
}
|
|
251
251
|
query: f->{
|
|
252
252
|
aggregate:
|
|
253
|
-
row_count is count(
|
|
253
|
+
row_count is count(concat(state,a.state))
|
|
254
254
|
left_count is count()
|
|
255
255
|
right_count is a.count()
|
|
256
256
|
left_sum is airport_count.sum()
|
|
@@ -279,7 +279,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
279
279
|
}
|
|
280
280
|
query: f->{
|
|
281
281
|
aggregate:
|
|
282
|
-
row_count is count(
|
|
282
|
+
row_count is count(concat(state,a.r))
|
|
283
283
|
left_sum is airport_count.sum()
|
|
284
284
|
right_sum is a.r.sum()
|
|
285
285
|
sum_sum is sum(airport_count + a.r)
|
|
@@ -306,7 +306,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
306
306
|
}
|
|
307
307
|
query: f->{
|
|
308
308
|
aggregate:
|
|
309
|
-
row_count is count(
|
|
309
|
+
row_count is count(concat(state,a.state))
|
|
310
310
|
left_sum is airport_count.sum()
|
|
311
311
|
right_sum is a.airport_count.sum()
|
|
312
312
|
}
|
|
@@ -409,11 +409,11 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
409
409
|
.loadQuery(
|
|
410
410
|
`
|
|
411
411
|
query: table('malloytest.state_facts') -> {
|
|
412
|
-
|
|
412
|
+
select: state
|
|
413
413
|
limit: 10
|
|
414
414
|
}
|
|
415
415
|
-> {
|
|
416
|
-
|
|
416
|
+
select: state
|
|
417
417
|
limit: 3
|
|
418
418
|
}
|
|
419
419
|
`
|
|
@@ -762,7 +762,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
762
762
|
aggregate: t is count()
|
|
763
763
|
}
|
|
764
764
|
-> {
|
|
765
|
-
|
|
765
|
+
select: t1 is t+1
|
|
766
766
|
}
|
|
767
767
|
}
|
|
768
768
|
query: f-> {
|
|
@@ -788,7 +788,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
788
788
|
aggregate: t is count()
|
|
789
789
|
}
|
|
790
790
|
-> {
|
|
791
|
-
|
|
791
|
+
select: t1 is t+1
|
|
792
792
|
}
|
|
793
793
|
}
|
|
794
794
|
query: f-> {
|
|
@@ -843,7 +843,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
843
843
|
${sql1234}
|
|
844
844
|
source: eone is from_sql(one) {}
|
|
845
845
|
|
|
846
|
-
query: eone -> {
|
|
846
|
+
query: eone -> { select: a }
|
|
847
847
|
`
|
|
848
848
|
)
|
|
849
849
|
.run();
|
|
@@ -855,7 +855,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
855
855
|
.loadQuery(
|
|
856
856
|
`
|
|
857
857
|
${sql1234}
|
|
858
|
-
query: from_sql(one) -> {
|
|
858
|
+
query: from_sql(one) -> { select: a }
|
|
859
859
|
`
|
|
860
860
|
)
|
|
861
861
|
.run();
|
|
@@ -880,7 +880,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
880
880
|
"""
|
|
881
881
|
}
|
|
882
882
|
query: from_sql(state_as_sql) -> {
|
|
883
|
-
|
|
883
|
+
select: *; where: popular_name = 'Emma'
|
|
884
884
|
}`;
|
|
885
885
|
const result = await runtime.loadQuery(turduckenQuery).run();
|
|
886
886
|
expect(result.data.value[0]['state_count']).toBe(6);
|
|
@@ -895,7 +895,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
895
895
|
// select version() as version
|
|
896
896
|
// ;;
|
|
897
897
|
|
|
898
|
-
// query: from_sql(one) -> {
|
|
898
|
+
// query: from_sql(one) -> { select: version }
|
|
899
899
|
// `
|
|
900
900
|
// )
|
|
901
901
|
// .run();
|
|
@@ -910,7 +910,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
910
910
|
${sql1234}
|
|
911
911
|
query: from_sql(one) -> {
|
|
912
912
|
declare: c is a + 1
|
|
913
|
-
|
|
913
|
+
select: c
|
|
914
914
|
}
|
|
915
915
|
`
|
|
916
916
|
)
|
|
@@ -926,7 +926,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
926
926
|
source: foo is from_sql(one) + {
|
|
927
927
|
query: bar is {
|
|
928
928
|
declare: c is a + 1
|
|
929
|
-
|
|
929
|
+
select: c
|
|
930
930
|
}
|
|
931
931
|
}
|
|
932
932
|
|
|
@@ -945,12 +945,12 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
945
945
|
source: foo is from_sql(one) + {
|
|
946
946
|
query: bar is {
|
|
947
947
|
declare: c is a + 1
|
|
948
|
-
|
|
948
|
+
select: c
|
|
949
949
|
}
|
|
950
950
|
|
|
951
951
|
query: baz is bar + {
|
|
952
952
|
declare: d is c + 1
|
|
953
|
-
|
|
953
|
+
select: d
|
|
954
954
|
}
|
|
955
955
|
}
|
|
956
956
|
|
|
@@ -992,7 +992,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
992
992
|
|
|
993
993
|
query: from_sql(one) -> {
|
|
994
994
|
declare: c is b + 4
|
|
995
|
-
|
|
995
|
+
select: x is a * c
|
|
996
996
|
}
|
|
997
997
|
`
|
|
998
998
|
)
|
|
@@ -1114,7 +1114,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
1114
1114
|
.loadQuery(
|
|
1115
1115
|
`
|
|
1116
1116
|
query: table('malloytest.state_facts') -> {
|
|
1117
|
-
|
|
1117
|
+
select: tick is '${back}${tick}'
|
|
1118
1118
|
}
|
|
1119
1119
|
`
|
|
1120
1120
|
)
|
|
@@ -1126,7 +1126,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
1126
1126
|
.loadQuery(
|
|
1127
1127
|
`
|
|
1128
1128
|
query: table('malloytest.state_facts') -> {
|
|
1129
|
-
|
|
1129
|
+
select: back is '${back}${back}'
|
|
1130
1130
|
}
|
|
1131
1131
|
`
|
|
1132
1132
|
)
|
|
@@ -141,7 +141,7 @@ expressionModels.forEach((orderByModel, databaseName) => {
|
|
|
141
141
|
aggregate: fetch is count()
|
|
142
142
|
}
|
|
143
143
|
} -> {
|
|
144
|
-
|
|
144
|
+
select:
|
|
145
145
|
withxz is lower(withx.select)
|
|
146
146
|
fetch is withx.fetch
|
|
147
147
|
}
|
|
@@ -161,8 +161,8 @@ expressionModels.forEach((orderByModel, databaseName) => {
|
|
|
161
161
|
aggregate: fetch is count()
|
|
162
162
|
}
|
|
163
163
|
} -> {
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
select: withxis lower(withx.select)
|
|
165
|
+
select: fetch is with.fetch
|
|
166
166
|
}
|
|
167
167
|
`
|
|
168
168
|
)
|
|
@@ -196,7 +196,7 @@ expressionModels.forEach((orderByModel, databaseName) => {
|
|
|
196
196
|
|
|
197
197
|
query: popular_names->{
|
|
198
198
|
order_by: 2
|
|
199
|
-
|
|
199
|
+
select: manufacturer, model_count
|
|
200
200
|
}
|
|
201
201
|
`
|
|
202
202
|
)
|
|
@@ -221,7 +221,7 @@ expressionModels.forEach((orderByModel, databaseName) => {
|
|
|
221
221
|
|
|
222
222
|
query: popular_names->{
|
|
223
223
|
order_by: 2
|
|
224
|
-
|
|
224
|
+
select: manufacturer, model_count
|
|
225
225
|
}
|
|
226
226
|
`
|
|
227
227
|
)
|
|
@@ -46,8 +46,8 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
46
46
|
// so this can't work yet.
|
|
47
47
|
it.skip(`can appear after errors - ${databaseName}`, async () => {
|
|
48
48
|
const source = `
|
|
49
|
-
source: foo is table('asdfds');
|
|
50
|
-
source: bar is table('malloytest.state_facts') {
|
|
49
|
+
source: foo is ${databaseName}.table('asdfds');
|
|
50
|
+
source: bar is ${databaseName}.table('malloytest.state_facts') extend {
|
|
51
51
|
dimension: a is LENGTH('foo')
|
|
52
52
|
}
|
|
53
53
|
`;
|
|
@@ -69,10 +69,10 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
69
69
|
|
|
70
70
|
it(`can appear before errors - ${databaseName}`, async () => {
|
|
71
71
|
const source = `
|
|
72
|
-
source: bar is table('malloytest.state_facts') {
|
|
72
|
+
source: bar is ${databaseName}.table('malloytest.state_facts') extend {
|
|
73
73
|
dimension: a is LENGTH('foo')
|
|
74
74
|
}
|
|
75
|
-
source: foo is table('asdfds');
|
|
75
|
+
source: foo is ${databaseName}.table('asdfds');
|
|
76
76
|
`;
|
|
77
77
|
const error = await getError(() => runtime.getModel(source));
|
|
78
78
|
expect(error).not.toBeUndefined();
|
|
@@ -92,7 +92,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
92
92
|
|
|
93
93
|
it(`can appear alone - ${databaseName}`, async () => {
|
|
94
94
|
const source = `
|
|
95
|
-
source: bar is table('malloytest.state_facts') {
|
|
95
|
+
source: bar is ${databaseName}.table('malloytest.state_facts') extend {
|
|
96
96
|
dimension: a is LENGTH('foo')
|
|
97
97
|
}
|
|
98
98
|
`;
|
|
@@ -47,7 +47,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
47
47
|
}
|
|
48
48
|
}) AS state_facts """
|
|
49
49
|
) -> {
|
|
50
|
-
|
|
50
|
+
select: *
|
|
51
51
|
}
|
|
52
52
|
`
|
|
53
53
|
)
|
|
@@ -63,9 +63,9 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
63
63
|
aggregate: c is count()
|
|
64
64
|
}
|
|
65
65
|
b is ${databaseName}.sql(
|
|
66
|
-
"""SELECT * FROM (%{ -> a -> {
|
|
66
|
+
"""SELECT * FROM (%{ -> a -> { select: * } }) AS state_facts """
|
|
67
67
|
) -> {
|
|
68
|
-
|
|
68
|
+
select: *
|
|
69
69
|
}
|
|
70
70
|
run: b
|
|
71
71
|
`
|
|
@@ -502,7 +502,7 @@ describe.each(runtimes.runtimeList)('%s date and time', (dbName, runtime) => {
|
|
|
502
502
|
dimension: default_time is @2021-02-24 03:05:06
|
|
503
503
|
query: la_query is {
|
|
504
504
|
timezone: 'America/Los_Angeles'
|
|
505
|
-
|
|
505
|
+
select: la_time is @2021-02-24 03:05:06
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
508
|
|
|
@@ -533,7 +533,7 @@ describe.each(runtimes.runtimeList)('%s date and time', (dbName, runtime) => {
|
|
|
533
533
|
source: timezone is from_sql(timeData) + {
|
|
534
534
|
dimension: default_time is @2021-02-24 03:05:06
|
|
535
535
|
query: undef_query is {
|
|
536
|
-
|
|
536
|
+
select: undef_time is @2021-02-24 03:05:06
|
|
537
537
|
}
|
|
538
538
|
}
|
|
539
539
|
|
|
@@ -560,11 +560,11 @@ describe.each(runtimes.runtimeList)('%s date and time', (dbName, runtime) => {
|
|
|
560
560
|
dimension: ny_time is @2021-02-24 03:05:06
|
|
561
561
|
query: la_query is {
|
|
562
562
|
timezone: 'America/Los_Angeles'
|
|
563
|
-
|
|
563
|
+
select: la_time is @2021-02-24 03:05:06
|
|
564
564
|
}
|
|
565
565
|
query: mex_query is {
|
|
566
566
|
timezone: 'America/Mexico_City'
|
|
567
|
-
|
|
567
|
+
select: mex_time is @2021-02-24 03:05:06
|
|
568
568
|
}
|
|
569
569
|
}
|
|
570
570
|
|
|
@@ -681,7 +681,7 @@ describe.each(runtimes.runtimeList)('%s: query tz', (dbName, runtime) => {
|
|
|
681
681
|
query: from_sql(tzTest) -> {
|
|
682
682
|
timezone: '${zone}'
|
|
683
683
|
declare: utc_midnight is @2020-02-20 00:00:00[UTC]
|
|
684
|
-
|
|
684
|
+
select:
|
|
685
685
|
mex_midnight is hour(utc_midnight)
|
|
686
686
|
mex_day is day(utc_midnight)
|
|
687
687
|
}`,
|
|
@@ -698,7 +698,7 @@ describe.each(runtimes.runtimeList)('%s: query tz', (dbName, runtime) => {
|
|
|
698
698
|
query: from_sql(tzTest) -> {
|
|
699
699
|
timezone: '${zone}'
|
|
700
700
|
declare: utc_midnight is @2020-02-20 00:00:00[UTC]
|
|
701
|
-
|
|
701
|
+
select:
|
|
702
702
|
mex_day is utc_midnight.day
|
|
703
703
|
}`,
|
|
704
704
|
{mex_day: mex_19.toJSDate()}
|
|
@@ -713,7 +713,7 @@ describe.each(runtimes.runtimeList)('%s: query tz', (dbName, runtime) => {
|
|
|
713
713
|
query: from_sql(tzTest) -> {
|
|
714
714
|
timezone: '${zone}'
|
|
715
715
|
declare: utc_midnight is @2020-02-20 00:00:00[UTC]
|
|
716
|
-
|
|
716
|
+
select: mex_day is day(utc_midnight::date)
|
|
717
717
|
}`,
|
|
718
718
|
{mex_day: 19}
|
|
719
719
|
);
|
|
@@ -726,7 +726,7 @@ describe.each(runtimes.runtimeList)('%s: query tz', (dbName, runtime) => {
|
|
|
726
726
|
""" }
|
|
727
727
|
query: from_sql(tzTest) -> {
|
|
728
728
|
timezone: '${zone}'
|
|
729
|
-
|
|
729
|
+
select: mex_ts is mex_20::timestamp
|
|
730
730
|
}`,
|
|
731
731
|
{mex_ts: zone_2020.toJSDate()}
|
|
732
732
|
);
|
|
@@ -739,7 +739,7 @@ describe.each(runtimes.runtimeList)('%s: query tz', (dbName, runtime) => {
|
|
|
739
739
|
SELECT DATETIME '2020-02-20 00:00:00' as t_datetime
|
|
740
740
|
"""}
|
|
741
741
|
query: from_sql(timeData) -> {
|
|
742
|
-
|
|
742
|
+
select: mex_220 is t_datetime::timestamp
|
|
743
743
|
}`,
|
|
744
744
|
{mex_220: utc_2020.toJSDate()}
|
|
745
745
|
);
|
|
@@ -749,7 +749,7 @@ describe.each(runtimes.runtimeList)('%s: query tz', (dbName, runtime) => {
|
|
|
749
749
|
SELECT TIMESTAMPTZ '2020-02-20 00:00:00 ${zone}' as t_tstz
|
|
750
750
|
"""}
|
|
751
751
|
query: from_sql(timeData) -> {
|
|
752
|
-
|
|
752
|
+
select: mex_220 is t_tstz::timestamp
|
|
753
753
|
}`,
|
|
754
754
|
{mex_220: zone_2020.toJSDate()}
|
|
755
755
|
);
|
|
@@ -625,7 +625,7 @@ describe('BigQuery expression tests', () => {
|
|
|
625
625
|
faa,
|
|
626
626
|
`
|
|
627
627
|
query: flights->{
|
|
628
|
-
aggregate: carrier_count is count(
|
|
628
|
+
aggregate: carrier_count is count(carrier)
|
|
629
629
|
}
|
|
630
630
|
`
|
|
631
631
|
);
|
|
@@ -763,7 +763,7 @@ describe('airport_tests', () => {
|
|
|
763
763
|
}
|
|
764
764
|
}
|
|
765
765
|
} -> { limit: 1
|
|
766
|
-
|
|
766
|
+
select: zero.by_faa_region_Z.by_state.by_county.county
|
|
767
767
|
}
|
|
768
768
|
|
|
769
769
|
`
|
|
@@ -778,13 +778,13 @@ describe('airport_tests', () => {
|
|
|
778
778
|
query: airports -> {
|
|
779
779
|
group_by: county
|
|
780
780
|
nest: stuff is {
|
|
781
|
-
|
|
781
|
+
select: elevation
|
|
782
782
|
order_by: 1 desc
|
|
783
783
|
limit: 10
|
|
784
784
|
}
|
|
785
785
|
order_by: 1
|
|
786
786
|
} -> {
|
|
787
|
-
|
|
787
|
+
select: stuff.elevation
|
|
788
788
|
limit: 1
|
|
789
789
|
}
|
|
790
790
|
`
|
|
@@ -827,7 +827,7 @@ describe('airport_tests', () => {
|
|
|
827
827
|
query: pipe_turtle is {
|
|
828
828
|
aggregate: a is airport_count
|
|
829
829
|
} -> {
|
|
830
|
-
|
|
830
|
+
select: a
|
|
831
831
|
}
|
|
832
832
|
}
|
|
833
833
|
query: my_airports->pipe_turtle
|
|
@@ -848,7 +848,7 @@ describe('airport_tests', () => {
|
|
|
848
848
|
county
|
|
849
849
|
aggregate: a is count()
|
|
850
850
|
} -> {
|
|
851
|
-
|
|
851
|
+
select:
|
|
852
852
|
state is upper(state)
|
|
853
853
|
a
|
|
854
854
|
} -> {
|
|
@@ -1027,7 +1027,7 @@ describe('unsupported type tests', () => {
|
|
|
1027
1027
|
sql: badType is {
|
|
1028
1028
|
select: """SELECT ST_GEOGFROMTEXT('LINESTRING(1 2, 3 4)') as geo"""
|
|
1029
1029
|
}
|
|
1030
|
-
query: from_sql(badType)->{
|
|
1030
|
+
query: from_sql(badType)->{ select: *}
|
|
1031
1031
|
`
|
|
1032
1032
|
)
|
|
1033
1033
|
.run();
|
|
@@ -51,7 +51,7 @@ describe('BigQuery double truncation', () => {
|
|
|
51
51
|
SELECT DATETIME '2020-02-20 00:00:00' as t_datetime
|
|
52
52
|
"""}
|
|
53
53
|
query: from_sql(timeData) -> {
|
|
54
|
-
|
|
54
|
+
select: mex_220 is t_datetime::timestamp
|
|
55
55
|
}`,
|
|
56
56
|
{mex_220: utc_2020.toJSDate()}
|
|
57
57
|
);
|
|
@@ -39,7 +39,7 @@ const modelText = `
|
|
|
39
39
|
source:ga_sessions is table('malloytest.ga_sample'){
|
|
40
40
|
|
|
41
41
|
measure:
|
|
42
|
-
user_count is count(
|
|
42
|
+
user_count is count(fullVisitorId)
|
|
43
43
|
session_count is count()
|
|
44
44
|
total_visits is totals.visits.sum()
|
|
45
45
|
total_hits is totals.hits.sum()
|
|
@@ -162,7 +162,7 @@ describe.each(runtimes.runtimeList)(
|
|
|
162
162
|
`
|
|
163
163
|
query: ga_sessions->search_index -> {
|
|
164
164
|
where: fieldName != null
|
|
165
|
-
|
|
165
|
+
select: *
|
|
166
166
|
order_by: fieldName, weight desc
|
|
167
167
|
limit: 10
|
|
168
168
|
}
|
|
@@ -188,7 +188,7 @@ describe.each(runtimes.runtimeList)(
|
|
|
188
188
|
sample: ${sampleSize}
|
|
189
189
|
}
|
|
190
190
|
-> {
|
|
191
|
-
aggregate: field_count is count(
|
|
191
|
+
aggregate: field_count is count(fieldName)
|
|
192
192
|
nest: top_fields is {
|
|
193
193
|
group_by: fieldName
|
|
194
194
|
aggregate: row_count is count()
|
|
@@ -249,7 +249,7 @@ describe.each(runtimes.runtimeList)(
|
|
|
249
249
|
source: eone is table('malloytest.airports') {}
|
|
250
250
|
|
|
251
251
|
query: eone -> {
|
|
252
|
-
|
|
252
|
+
select:
|
|
253
253
|
bad_date is '123':::date
|
|
254
254
|
bad_number is 'abc':::number
|
|
255
255
|
limit: 1
|
|
@@ -67,15 +67,15 @@ describe('Multi-connection', () => {
|
|
|
67
67
|
|
|
68
68
|
const expressionModelText = `
|
|
69
69
|
source: default_aircraft is table('malloytest.aircraft'){
|
|
70
|
-
measure: aircraft_count is count(
|
|
70
|
+
measure: aircraft_count is count(tail_num)
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
source: bigquery_state_facts is table('malloytest.state_facts'){
|
|
74
|
-
measure: state_count is count(
|
|
74
|
+
measure: state_count is count(state)+2
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
source: postgres_aircraft is table('postgres:malloytest.aircraft'){
|
|
78
|
-
measure: aircraft_count is count(
|
|
78
|
+
measure: aircraft_count is count(tail_num)+4
|
|
79
79
|
}
|
|
80
80
|
`;
|
|
81
81
|
|
|
@@ -130,7 +130,7 @@ source: postgres_aircraft is table('postgres:malloytest.aircraft'){
|
|
|
130
130
|
group_by:
|
|
131
131
|
version is version!()
|
|
132
132
|
aggregate:
|
|
133
|
-
code_count is count(
|
|
133
|
+
code_count is count(code)
|
|
134
134
|
airport_count is count()
|
|
135
135
|
}
|
|
136
136
|
`
|