@malloydata/malloy-tests 0.0.138-dev240404193102 → 0.0.138-dev240404233606

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 (133) hide show
  1. package/jest.setup.ts +28 -0
  2. package/package.json +8 -8
  3. package/src/databases/all/db_index.spec.ts +4 -6
  4. package/src/databases/all/expr.spec.ts +27 -36
  5. package/src/databases/all/join.spec.ts +4 -4
  6. package/src/databases/all/nomodel.spec.ts +79 -99
  7. package/src/databases/all/orderby.spec.ts +7 -7
  8. package/src/databases/all/time.spec.ts +22 -30
  9. package/src/render/render.spec.ts +52 -55
  10. package/src/util/index.ts +0 -11
  11. package/tsconfig.json +2 -2
  12. package/types/jest.d.ts +8 -0
  13. package/dist/bin/ping_db.d.ts +0 -1
  14. package/dist/bin/ping_db.js +0 -44
  15. package/dist/bin/ping_db.js.map +0 -1
  16. package/dist/src/api.spec.d.ts +0 -1
  17. package/dist/src/api.spec.js +0 -113
  18. package/dist/src/api.spec.js.map +0 -1
  19. package/dist/src/databases/all/db_index.spec.d.ts +0 -1
  20. package/dist/src/databases/all/db_index.spec.js +0 -126
  21. package/dist/src/databases/all/db_index.spec.js.map +0 -1
  22. package/dist/src/databases/all/expr.spec.d.ts +0 -1
  23. package/dist/src/databases/all/expr.spec.js +0 -717
  24. package/dist/src/databases/all/expr.spec.js.map +0 -1
  25. package/dist/src/databases/all/functions.spec.d.ts +0 -1
  26. package/dist/src/databases/all/functions.spec.js +0 -1180
  27. package/dist/src/databases/all/functions.spec.js.map +0 -1
  28. package/dist/src/databases/all/join.spec.d.ts +0 -1
  29. package/dist/src/databases/all/join.spec.js +0 -255
  30. package/dist/src/databases/all/join.spec.js.map +0 -1
  31. package/dist/src/databases/all/lenses.spec.d.ts +0 -1
  32. package/dist/src/databases/all/lenses.spec.js +0 -374
  33. package/dist/src/databases/all/lenses.spec.js.map +0 -1
  34. package/dist/src/databases/all/nomodel.spec.d.ts +0 -1
  35. package/dist/src/databases/all/nomodel.spec.js +0 -1071
  36. package/dist/src/databases/all/nomodel.spec.js.map +0 -1
  37. package/dist/src/databases/all/orderby.spec.d.ts +0 -1
  38. package/dist/src/databases/all/orderby.spec.js +0 -170
  39. package/dist/src/databases/all/orderby.spec.js.map +0 -1
  40. package/dist/src/databases/all/problems.spec.d.ts +0 -1
  41. package/dist/src/databases/all/problems.spec.js +0 -106
  42. package/dist/src/databases/all/problems.spec.js.map +0 -1
  43. package/dist/src/databases/all/sql_expressions.spec.d.ts +0 -1
  44. package/dist/src/databases/all/sql_expressions.spec.js +0 -73
  45. package/dist/src/databases/all/sql_expressions.spec.js.map +0 -1
  46. package/dist/src/databases/all/time.spec.d.ts +0 -1
  47. package/dist/src/databases/all/time.spec.js +0 -602
  48. package/dist/src/databases/all/time.spec.js.map +0 -1
  49. package/dist/src/databases/bigquery/double_truncation.spec.d.ts +0 -1
  50. package/dist/src/databases/bigquery/double_truncation.spec.js +0 -50
  51. package/dist/src/databases/bigquery/double_truncation.spec.js.map +0 -1
  52. package/dist/src/databases/bigquery/handexpr.spec.d.ts +0 -1
  53. package/dist/src/databases/bigquery/handexpr.spec.js +0 -723
  54. package/dist/src/databases/bigquery/handexpr.spec.js.map +0 -1
  55. package/dist/src/databases/bigquery/injestion_time_partitioning.spec.d.ts +0 -1
  56. package/dist/src/databases/bigquery/injestion_time_partitioning.spec.js +0 -235
  57. package/dist/src/databases/bigquery/injestion_time_partitioning.spec.js.map +0 -1
  58. package/dist/src/databases/bigquery/joined_filters.spec.d.ts +0 -1
  59. package/dist/src/databases/bigquery/joined_filters.spec.js +0 -72
  60. package/dist/src/databases/bigquery/joined_filters.spec.js.map +0 -1
  61. package/dist/src/databases/bigquery/json.spec.d.ts +0 -1
  62. package/dist/src/databases/bigquery/json.spec.js +0 -66
  63. package/dist/src/databases/bigquery/json.spec.js.map +0 -1
  64. package/dist/src/databases/bigquery/malloy_query.spec.d.ts +0 -1
  65. package/dist/src/databases/bigquery/malloy_query.spec.js +0 -840
  66. package/dist/src/databases/bigquery/malloy_query.spec.js.map +0 -1
  67. package/dist/src/databases/bigquery/performance.skipped.spec.d.ts +0 -1
  68. package/dist/src/databases/bigquery/performance.skipped.spec.js +0 -70
  69. package/dist/src/databases/bigquery/performance.skipped.spec.js.map +0 -1
  70. package/dist/src/databases/bigquery/time.spec.d.ts +0 -1
  71. package/dist/src/databases/bigquery/time.spec.js +0 -52
  72. package/dist/src/databases/bigquery/time.spec.js.map +0 -1
  73. package/dist/src/databases/bigquery/wildcard_table_names.spec.d.ts +0 -1
  74. package/dist/src/databases/bigquery/wildcard_table_names.spec.js +0 -212
  75. package/dist/src/databases/bigquery/wildcard_table_names.spec.js.map +0 -1
  76. package/dist/src/databases/bigquery-duckdb/nested_source_table.spec.d.ts +0 -1
  77. package/dist/src/databases/bigquery-duckdb/nested_source_table.spec.js +0 -213
  78. package/dist/src/databases/bigquery-duckdb/nested_source_table.spec.js.map +0 -1
  79. package/dist/src/databases/duckdb/duckdb.spec.d.ts +0 -1
  80. package/dist/src/databases/duckdb/duckdb.spec.js +0 -124
  81. package/dist/src/databases/duckdb/duckdb.spec.js.map +0 -1
  82. package/dist/src/databases/duckdb/streaming.spec.d.ts +0 -1
  83. package/dist/src/databases/duckdb/streaming.spec.js +0 -142
  84. package/dist/src/databases/duckdb/streaming.spec.js.map +0 -1
  85. package/dist/src/databases/multi-connection/multi_connection.spec.d.ts +0 -1
  86. package/dist/src/databases/multi-connection/multi_connection.spec.js +0 -120
  87. package/dist/src/databases/multi-connection/multi_connection.spec.js.map +0 -1
  88. package/dist/src/databases/postgres/postgres.spec.d.ts +0 -1
  89. package/dist/src/databases/postgres/postgres.spec.js +0 -140
  90. package/dist/src/databases/postgres/postgres.spec.js.map +0 -1
  91. package/dist/src/databases/shared/test_list.d.ts +0 -3
  92. package/dist/src/databases/shared/test_list.js +0 -5
  93. package/dist/src/databases/shared/test_list.js.map +0 -1
  94. package/dist/src/databases/streaming/streaming.spec.d.ts +0 -1
  95. package/dist/src/databases/streaming/streaming.spec.js +0 -93
  96. package/dist/src/databases/streaming/streaming.spec.js.map +0 -1
  97. package/dist/src/dependencies.spec.d.ts +0 -1
  98. package/dist/src/dependencies.spec.js +0 -63
  99. package/dist/src/dependencies.spec.js.map +0 -1
  100. package/dist/src/index.d.ts +0 -4
  101. package/dist/src/index.js +0 -49
  102. package/dist/src/index.js.map +0 -1
  103. package/dist/src/jestMatcher.spec.d.ts +0 -1
  104. package/dist/src/jestMatcher.spec.js +0 -81
  105. package/dist/src/jestMatcher.spec.js.map +0 -1
  106. package/dist/src/model/sql_source.spec.d.ts +0 -1
  107. package/dist/src/model/sql_source.spec.js +0 -47
  108. package/dist/src/model/sql_source.spec.js.map +0 -1
  109. package/dist/src/models/faa_model.d.ts +0 -5
  110. package/dist/src/models/faa_model.js +0 -997
  111. package/dist/src/models/faa_model.js.map +0 -1
  112. package/dist/src/models/medicare_model.d.ts +0 -4
  113. package/dist/src/models/medicare_model.js +0 -259
  114. package/dist/src/models/medicare_model.js.map +0 -1
  115. package/dist/src/render/drill.spec.d.ts +0 -1
  116. package/dist/src/render/drill.spec.js +0 -107
  117. package/dist/src/render/drill.spec.js.map +0 -1
  118. package/dist/src/render/render.spec.d.ts +0 -1
  119. package/dist/src/render/render.spec.js +0 -548
  120. package/dist/src/render/render.spec.js.map +0 -1
  121. package/dist/src/runtimes.d.ts +0 -35
  122. package/dist/src/runtimes.js +0 -181
  123. package/dist/src/runtimes.js.map +0 -1
  124. package/dist/src/tags.spec.d.ts +0 -8
  125. package/dist/src/tags.spec.js +0 -490
  126. package/dist/src/tags.spec.js.map +0 -1
  127. package/dist/src/util/db-jest-matchers.d.ts +0 -30
  128. package/dist/src/util/db-jest-matchers.js +0 -157
  129. package/dist/src/util/db-jest-matchers.js.map +0 -1
  130. package/dist/src/util/index.d.ts +0 -15
  131. package/dist/src/util/index.js +0 -182
  132. package/dist/src/util/index.js.map +0 -1
  133. package/jest.setup.js +0 -8
@@ -1,1071 +0,0 @@
1
- "use strict";
2
- /* eslint-disable no-console */
3
- /*
4
- * Copyright 2023 Google LLC
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining
7
- * a copy of this software and associated documentation files
8
- * (the "Software"), to deal in the Software without restriction,
9
- * including without limitation the rights to use, copy, modify, merge,
10
- * publish, distribute, sublicense, and/or sell copies of the Software,
11
- * and to permit persons to whom the Software is furnished to do so,
12
- * subject to the following conditions:
13
- *
14
- * The above copyright notice and this permission notice shall be
15
- * included in all copies or substantial portions of the Software.
16
- *
17
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
- */
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
- const runtimes_1 = require("../../runtimes");
28
- const util_1 = require("../../util");
29
- require("../../util/db-jest-matchers");
30
- const runtimes = new runtimes_1.RuntimeList((0, util_1.databasesFromEnvironmentOr)(runtimes_1.allDatabases));
31
- // No prebuilt shared model, each test is complete. Makes debugging easier.
32
- function rootDbPath(databaseName) {
33
- return databaseName === 'bigquery' ? 'malloy-data.' : '';
34
- }
35
- // TODO: Figure out how to generalize this.
36
- function getSplitFunction(db) {
37
- return {
38
- 'bigquery': (column, splitChar) => `split(${column}, '${splitChar}')`,
39
- 'postgres': (column, splitChar) => `string_to_array(${column}, '${splitChar}')`,
40
- 'duckdb': (column, splitChar) => `string_to_array(${column}, '${splitChar}')`,
41
- 'duckdb_wasm': (column, splitChar) => `string_to_array(${column}, '${splitChar}')`,
42
- 'motherduck': (column, splitChar) => `string_to_array(${column}, '${splitChar}')`,
43
- 'snowflake': (column, splitChar) => `split(${column}, '${splitChar}')`,
44
- 'trino': (column, splitChar) => `split(${column}, '${splitChar}')`,
45
- }[db];
46
- }
47
- afterAll(async () => {
48
- await runtimes.closeAll();
49
- });
50
- runtimes.runtimeMap.forEach((runtime, databaseName) => {
51
- const q = runtime.getQuoter();
52
- // Issue: #1284
53
- it(`parenthesize output field values - ${databaseName}`, async () => {
54
- await expect(`
55
- run: ${databaseName}.table('malloytest.aircraft') -> {
56
- group_by: r is 1
57
-
58
- calculate:
59
- zero is 1 - rank()
60
- zero_bare is 0 - zero
61
- zero_paren is 0 - (zero)
62
- }
63
- `).malloyResultMatches(runtime, { zero_bare: 0, zero_paren: 0 });
64
- });
65
- // Issue: #151
66
- it(`bug 151 which used to throw unknown dialect is still fixed- ${databaseName}`, async () => {
67
- await expect(`
68
- query: q is ${databaseName}.table('malloytest.aircraft')->{
69
- where: state != null
70
- group_by: state
71
- }
72
- run: q extend {
73
- view: foo is {
74
- order_by: 1 desc
75
- group_by: state
76
- }
77
- } -> foo
78
- `).malloyResultMatches(runtime, { state: 'WY' });
79
- });
80
- // Issue #149
81
- it(`refine query from query - ${databaseName}`, async () => {
82
- await expect(`
83
- run: ${databaseName}.table('malloytest.state_facts')
84
- -> {group_by: state; order_by: 1 desc; limit: 1}
85
- extend {
86
- dimension: lower_state is lower(state)
87
- } -> {select: lower_state}
88
- `).malloyResultMatches(runtime, { lower_state: 'wy' });
89
- });
90
- // issue #157
91
- it(`source- not -found - ${databaseName}`, async () => {
92
- // console.log(result.data.toObject());
93
- let error;
94
- try {
95
- await runtime
96
- .loadQuery(`
97
- source: foo is ${databaseName}.table('malloytest.state_facts') extend {primary_key: state}
98
- run: foox->{aggregate: c is count()}
99
- `)
100
- .run();
101
- }
102
- catch (e) {
103
- error = e;
104
- }
105
- expect(error.toString()).not.toContain('Unknown Dialect');
106
- });
107
- it(`join_many - ${databaseName}`, async () => {
108
- await expect(`
109
- source: m is ${databaseName}.table('malloytest.aircraft_models') extend {
110
- join_many:
111
- a is ${databaseName}.table('malloytest.aircraft') extend {
112
- measure: avg_year is floor(avg(year_built))
113
- } on a.aircraft_model_code=aircraft_model_code
114
- measure: avg_seats is floor(avg(seats))
115
- }
116
- run: m->{aggregate: avg_seats, a.avg_year}
117
- `).malloyResultMatches(runtime, { avg_year: 1969, avg_seats: 7 });
118
- });
119
- it(`join_many condition no primary key - ${databaseName}`, async () => {
120
- await expect(`
121
- source: a is ${databaseName}.table('malloytest.airports')
122
- source: b is ${databaseName}.table('malloytest.state_facts') extend {
123
- join_many: a on state=a.state
124
- }
125
- run: b->{aggregate: c is airport_count.sum()}
126
- `).malloyResultMatches(runtime, { c: 19701 });
127
- });
128
- it(`join_many filter multiple values - ${databaseName}`, async () => {
129
- await expect(`
130
- source: a is ${databaseName}.table('malloytest.airports') extend {
131
- where: state = 'NH' | 'CA'
132
- }
133
- run: ${databaseName}.table('malloytest.state_facts') extend {
134
- join_many: a on state=a.state
135
- } -> {
136
- aggregate: c is airport_count.sum()
137
- group_by: a.state
138
- }
139
- `).malloyResultMatches(runtime, [
140
- { state: null, c: 18605 },
141
- { state: 'CA', c: 984 },
142
- { state: 'NH', c: 112 },
143
- ]);
144
- });
145
- it(`join_one condition no primary key - ${databaseName}`, async () => {
146
- await expect(`
147
- source: a is ${databaseName}.table('malloytest.state_facts')
148
- source: b is ${databaseName}.table('malloytest.airports') extend {
149
- join_one: a on state=a.state
150
- }
151
- run: b -> {
152
- aggregate: c is a.airport_count.sum()
153
- }
154
- `).malloyResultMatches(runtime, { c: 19701 });
155
- });
156
- it(`join_one filter multiple values - ${databaseName}`, async () => {
157
- await expect(`
158
- source: a is ${databaseName}.table('malloytest.state_facts') extend {
159
- where: state = 'TX' | 'LA'
160
- }
161
- source: b is ${databaseName}.table('malloytest.airports') extend {
162
- join_one: a on state=a.state
163
- }
164
- run: b-> {
165
- aggregate: c is a.airport_count.sum()
166
- group_by: a.state
167
- }
168
- `).malloyResultMatches(runtime, [
169
- { state: 'TX', c: 1845 },
170
- { state: 'LA', c: 500 },
171
- { state: null, c: 0 },
172
- ]);
173
- });
174
- it(`join_many cross from - ${databaseName}`, async () => {
175
- // a cross join produces a Many to Many result.
176
- // symmetric aggregate are needed on both sides of the join
177
- // Check the row count and that sums on each side work properly.
178
- await expect(`
179
- source: a is ${databaseName}.table('malloytest.state_facts')
180
- source: f is a extend {
181
- join_cross: a
182
- }
183
- run: f->{
184
- aggregate:
185
- row_count is count(concat(state,a.state))
186
- left_count is count()
187
- right_count is a.count()
188
- left_sum is airport_count.sum()
189
- right_sum is a.airport_count.sum()
190
- }
191
- `).malloyResultMatches(runtime, {
192
- row_count: 51 * 51,
193
- left_sum: 19701,
194
- right_sum: 19701,
195
- });
196
- });
197
- it(`join_one only - ${databaseName}`, async () => {
198
- // a cross join produces a Many to Many result.
199
- // symmetric aggregate are needed on both sides of the join
200
- // Check the row count and that sums on each side work properly.
201
- await expect(`
202
- query: q is ${databaseName}.table('malloytest.state_facts')->{
203
- aggregate: r is airport_count.sum()
204
- }
205
- source: f is ${databaseName}.table('malloytest.state_facts') extend {
206
- join_one: a is q
207
- }
208
- run: f->{
209
- aggregate:
210
- row_count is count(concat(state,a.r))
211
- left_sum is airport_count.sum()
212
- right_sum is a.r.sum()
213
- sum_sum is sum(airport_count + a.r)
214
- }
215
- `).malloyResultMatches(runtime, {
216
- row_count: 51,
217
- left_sum: 19701,
218
- right_sum: 19701,
219
- sum_sum: 19701 + 51 * 19701,
220
- });
221
- });
222
- it(`join_many cross ON - ${databaseName}`, async () => {
223
- // a cross join produces a Many to Many result.
224
- // symmetric aggregate are needed on both sides of the join
225
- // Check the row count and that sums on each side work properly.
226
- await expect(`
227
- source: a is ${databaseName}.table('malloytest.state_facts')
228
- source: f is a extend {
229
- join_cross: a on a.state = 'CA' | 'NY'
230
- }
231
- run: f->{
232
- aggregate:
233
- row_count is count(concat(state,a.state))
234
- left_sum is airport_count.sum()
235
- right_sum is a.airport_count.sum()
236
- }
237
- `).malloyResultMatches(runtime, {
238
- row_count: 51 * 2,
239
- left_sum: 19701,
240
- right_sum: 1560,
241
- });
242
- });
243
- it(`limit - provided - ${databaseName}`, async () => {
244
- // a cross join produces a Many to Many result.
245
- // symmetric aggregate are needed on both sides of the join
246
- // Check the row count and that sums on each side work properly.
247
- const result = await runtime
248
- .loadQuery(`
249
- run: ${databaseName}.table('malloytest.state_facts') -> {
250
- group_by: state
251
- aggregate: c is count()
252
- limit: 3
253
- }
254
- `)
255
- .run();
256
- expect(result.resultExplore.limit).toBe(3);
257
- });
258
- const matrixModel = `
259
- ##! experimental.join_types
260
- source: am_states is ${databaseName}.table('malloytest.state_facts') -> {
261
- select: *
262
- where: state ~ r'^(A|M)'
263
- } extend {
264
- measure:
265
- am_count is count()
266
- am_sum is airport_count.sum()
267
- }
268
-
269
- query: ac_states_base is ${databaseName}.table('malloytest.state_facts') -> {
270
- select: *
271
- where: state ~ r'^(A|C)'
272
- }
273
-
274
- // mulitply the number of rows in ac_states so we have a many to one join
275
- source: ac_states is ac_states_base -> {
276
- extend: {
277
- join_cross: b is ac_states_base
278
- }
279
- select:
280
- b.state
281
- b.airport_count
282
- } extend {
283
- measure:
284
- ac_count is count()
285
- ac_sum is airport_count.sum()
286
- }
287
- `;
288
- it(`join inner- ${databaseName}`, async () => {
289
- // a cross join produces a Many to Many result.
290
- // symmetric aggregate are needed on both sides of the join
291
- // Check the row count and that sums on each side work properly.
292
- await expect(`
293
- ${matrixModel}
294
- run: ac_states -> {
295
- extend: {
296
- join_one: am_states inner on state = am_states.state
297
- }
298
- aggregate:
299
- ac_count
300
- ac_sum
301
- am_states.am_sum
302
- am_states.am_count
303
-
304
- }
305
- `).malloyResultMatches(runtime, {
306
- ac_count: 28,
307
- ac_sum: 10402,
308
- am_count: 4,
309
- am_sum: 1486,
310
- //show_sql_fail: 1,
311
- });
312
- });
313
- it(`join left - ${databaseName}`, async () => {
314
- // a cross join produces a Many to Many result.
315
- // symmetric aggregate are needed on both sides of the join
316
- // Check the row count and that sums on each side work properly.
317
- await expect(`
318
- ${matrixModel}
319
- run: ac_states -> {
320
- extend: {
321
- join_one: am_states left on state = am_states.state
322
- }
323
- aggregate:
324
- ac_count
325
- ac_sum
326
- am_states.am_sum
327
- am_states.am_count
328
-
329
- }
330
- `).malloyResultMatches(runtime, {
331
- ac_count: 49,
332
- ac_sum: 21336,
333
- am_count: 4,
334
- am_sum: 1486,
335
- //show_sql_fail: 1,
336
- });
337
- });
338
- it(`join right - ${databaseName}`, async () => {
339
- // a cross join produces a Many to Many result.
340
- // symmetric aggregate are needed on both sides of the join
341
- // Check the row count and that sums on each side work properly.
342
- await expect(`
343
- ${matrixModel}
344
- run: ac_states -> {
345
- extend: {
346
- join_one: am_states right on state = am_states.state
347
- }
348
- aggregate:
349
- ac_count
350
- ac_sum
351
- am_states.am_sum
352
- am_states.am_count
353
-
354
- }
355
- `).malloyResultMatches(runtime, {
356
- ac_count: 28,
357
- ac_sum: 10402,
358
- am_count: 12,
359
- am_sum: 4139,
360
- //show_sql_fail: 1,
361
- });
362
- });
363
- it(`join full - ${databaseName}`, async () => {
364
- // a cross join produces a Many to Many result.
365
- // symmetric aggregate are needed on both sides of the join
366
- // Check the row count and that sums on each side work properly.
367
- await expect(`
368
- ${matrixModel}
369
- run: ac_states -> {
370
- extend: {
371
- join_one: am_states full on state = am_states.state
372
- }
373
- aggregate:
374
- ac_count
375
- ac_sum
376
- am_states.am_sum
377
- am_states.am_count
378
-
379
- }
380
- `).malloyResultMatches(runtime, {
381
- ac_count: 49,
382
- ac_sum: 21336,
383
- am_count: 12,
384
- am_sum: 4139,
385
- });
386
- });
387
- it(`leafy count - ${databaseName}`, async () => {
388
- // in a joined table when the joined is leafiest
389
- // we need to make sure we don't count rows that
390
- // don't match the join.
391
- await expect(`
392
- source: am_states is ${databaseName}.table('malloytest.state_facts') -> {
393
- select: *
394
- where: state ~ r'^(A|M)'
395
- }
396
-
397
- source: states is ${databaseName}.table('malloytest.state_facts') extend {
398
- join_many: am_states on state=am_states.state
399
- }
400
-
401
- run: states -> {
402
- where: state = 'CA'
403
- aggregate:
404
- leafy_count is am_states.count()
405
- root_count is count()
406
- }
407
- `).malloyResultMatches(runtime, {
408
- leafy_count: 0,
409
- root_count: 1,
410
- });
411
- });
412
- it(`nest/unnest -basic - ${databaseName}`, async () => {
413
- // in a joined table when the joined is leafiest
414
- // we need to make sure we don't count rows that
415
- // don't match the join.
416
- await expect(`
417
- run: ${databaseName}.table('malloytest.state_facts') -> {
418
- group_by: state
419
- aggregate: c is airport_count.sum()
420
- nest: p is {
421
- group_by: popular_name
422
- aggregate: d is airport_count.sum()
423
- }
424
- } -> {
425
- group_by: state, c
426
- aggregate: p.d.sum()
427
- }
428
- `).malloyResultMatches(runtime, {
429
- state: 'TX',
430
- c: 1845,
431
- d: 1845,
432
- });
433
- });
434
- it(`count at root should not use distinct key - ${databaseName}`, async () => {
435
- const q = await runtime
436
- .loadQuery(`
437
- source: states is ${databaseName}.table('malloytest.state_facts')
438
-
439
- run: states -> { aggregate: c is count() }
440
- `)
441
- .run();
442
- expect(q.sql.toLowerCase()).not.toContain('distinct');
443
- });
444
- it(`leafy nested count - ${databaseName}`, async () => {
445
- // in a joined table when the joined is leafiest
446
- // we need to make sure we don't count rows that
447
- // don't match the join.
448
- await expect(`
449
- source: am_states is ${databaseName}.table('malloytest.state_facts') -> {
450
- group_by: state,popular_name
451
- where: state ~ r'^(A|M)'
452
- nest: nested_state is {
453
- group_by: state,popular_name
454
- }
455
- }
456
-
457
- source: states is ${databaseName}.table('malloytest.state_facts') extend {
458
- join_many: am_states on state=am_states.state
459
- }
460
-
461
- run: states -> {
462
- where: state = 'CA'
463
- group_by:
464
- state
465
- am_state is am_states.state
466
- aggregate:
467
- leafy_count is am_states.nested_state.count()
468
- root_count is count()
469
- }
470
- `).malloyResultMatches(runtime, {
471
- leafy_count: 0,
472
- root_count: 1,
473
- state: 'CA',
474
- am_state: null,
475
- });
476
- });
477
- it(`basic index - ${databaseName}`, async () => {
478
- // Make sure basic indexing works.
479
- await expect(`
480
- run: ${databaseName}.table('malloytest.flights') -> {
481
- index: *
482
- }
483
- -> {
484
- select: *
485
- order_by: fieldValue
486
- where: fieldName = 'carrier'
487
- }
488
- `).malloyResultMatches(runtime, {
489
- fieldValue: 'AA',
490
- });
491
- });
492
- test(`number as null 2 - ${databaseName}`, (0, util_1.onlyIf)(runtime.supportsNesting, async () => {
493
- // a cross join produces a Many to Many result.
494
- // symmetric aggregate are needed on both sides of the join
495
- // Check the row count and that sums on each side work properly.
496
- await expect(`
497
- run: ${databaseName}.table('malloytest.state_facts') -> {
498
- group_by: state
499
- nest: ugly is {
500
- group_by: popular_name
501
- aggregate: foo is NULLIF(sum(airport_count)*0,0)+1
502
- }
503
- }
504
- `).malloyResultMatches(runtime, { 'ugly.foo': null });
505
- }));
506
- // average should only include non-null values in the denominator
507
- it(`avg ignore null- ${databaseName}`, async () => {
508
- await expect(`
509
- source: one is ${databaseName}.sql("""
510
- SELECT 2 as ${q `a`}
511
- UNION ALL SELECT 4
512
- UNION ALL SELECT null
513
- """)
514
- run: one -> {
515
- extend: { join_cross: x1 is one }
516
- aggregate:
517
- avg_a is a.avg()
518
- avg_b is x1.a.avg()
519
- }`).malloyResultMatches(runtime, { avg_a: 3 });
520
- });
521
- it(`limit - not provided - ${databaseName}`, async () => {
522
- // a cross join produces a Many to Many result.
523
- // symmetric aggregate are needed on both sides of the join
524
- // Check the row count and that sums on each side work properly.
525
- const result = await runtime
526
- .loadQuery(`run: ${databaseName}.table('malloytest.state_facts') -> {
527
- group_by: state
528
- aggregate: c is count()
529
- }`)
530
- .run();
531
- expect(result.resultExplore.limit).toBe(undefined);
532
- });
533
- it(`ungrouped top level - ${databaseName}`, async () => {
534
- await expect(`
535
- run: ${databaseName}.table('malloytest.state_facts') extend {
536
- measure: total_births is births.sum()
537
- measure: births_per_100k is floor(total_births/ all(total_births) * 100000)
538
- } -> {
539
- group_by: state
540
- aggregate: births_per_100k
541
- }`).malloyResultMatches(runtime, { births_per_100k: 9742 });
542
- });
543
- test(`ungrouped top level with nested - ${databaseName}`, (0, util_1.onlyIf)(runtime.supportsNesting, async () => {
544
- await expect(`
545
- run: ${databaseName}.table('malloytest.state_facts') extend {
546
- measure: total_births is births.sum()
547
- measure: births_per_100k is floor(total_births/ all(total_births) * 100000)
548
- } -> {
549
- group_by: state
550
- aggregate: births_per_100k
551
- nest: by_name is {
552
- group_by: popular_name
553
- aggregate: total_births
554
- }
555
- limit: 1000
556
- }`).malloyResultMatches(runtime, { births_per_100k: 9742 });
557
- }));
558
- it(`ungrouped - eliminate rows - ${databaseName}`, async () => {
559
- await expect(`
560
- run : ${databaseName}.table('malloytest.state_facts') extend {
561
- measure: m is all(births.sum())
562
- where: state='CA' | 'NY'
563
- } -> {
564
- order_by: state
565
- group_by: state
566
- aggregate: m
567
- }`).malloyResultMatches(runtime, [
568
- { state: 'CA', m: 52504699 },
569
- { state: 'NY', m: 52504699 },
570
- ]);
571
- });
572
- test(`ungrouped nested with no grouping above - ${databaseName}`, (0, util_1.onlyIf)(runtime.supportsNesting, async () => {
573
- await expect(`
574
- run: ${databaseName}.table('malloytest.state_facts') extend {
575
- measure: total_births is births.sum()
576
- measure: births_per_100k is floor(total_births/ all(total_births) * 100000)
577
- } -> {
578
- aggregate: total_births
579
- nest: by_name is {
580
- group_by: popular_name
581
- aggregate: births_per_100k
582
- }
583
- }`).malloyResultMatches(runtime, { 'by_name.births_per_100k': 66703 });
584
- }));
585
- test(`ungrouped - partial grouping - ${databaseName}`, (0, util_1.onlyIf)(runtime.supportsNesting, async () => {
586
- await expect(`
587
- run: ${databaseName}.table('malloytest.airports') extend {
588
- measure: c is count()
589
- } -> {
590
- where: state = 'TX' | 'NY'
591
- group_by:
592
- faa_region
593
- state
594
- aggregate:
595
- c
596
- all_ is all(c)
597
- airport_count is c { where: fac_type = 'AIRPORT'}
598
- nest: fac_type is {
599
- group_by: fac_type
600
- aggregate:
601
- c
602
- all_ is all(c)
603
- all_state_region is exclude(c,fac_type)
604
- all_of_this_type is exclude(c, state, faa_region)
605
- all_top is exclude(c, state, faa_region, fac_type)
606
- }
607
- }
608
- `).malloyResultMatches(runtime, {
609
- 'fac_type.all_': 1845,
610
- 'fac_type.all_state_region': 1845,
611
- 'fac_type.all_of_this_type': 1782,
612
- 'fac_type.all_top': 2421,
613
- });
614
- }));
615
- test(`ungrouped - all nested - ${databaseName}`, (0, util_1.onlyIf)(runtime.supportsNesting, async () => {
616
- await expect(`
617
- run: ${databaseName}.table('malloytest.airports') extend {
618
- measure: c is count()
619
- } -> {
620
- where: state = 'TX' | 'NY'
621
- group_by:
622
- state
623
- aggregate:
624
- c
625
- all_ is all(c)
626
- airport_count is c { where: fac_type = 'AIRPORT'}
627
- nest: fac_type is {
628
- group_by: fac_type, major
629
- aggregate:
630
- c
631
- all_ is all(c)
632
- all_major is all(c,major)
633
- }
634
- }
635
- `).malloyResultMatches(runtime, {
636
- 'fac_type.all_': 1845,
637
- 'fac_type.all_major': 1819,
638
- });
639
- }));
640
- test(`ungrouped nested - ${databaseName}`, (0, util_1.onlyIf)(runtime.supportsNesting, async () => {
641
- await expect(`
642
- run: ${databaseName}.table('malloytest.state_facts') extend {
643
- measure: total_births is births.sum()
644
- measure: births_per_100k is floor(total_births/ all(total_births) * 100000)
645
- } -> {
646
- group_by: popular_name
647
- nest: by_state is {
648
- group_by: state
649
- aggregate: births_per_100k
650
- }
651
- }
652
- `).malloyResultMatches(runtime, { 'by_state.births_per_100k': 36593 });
653
- }));
654
- test(`ungrouped nested expression - ${databaseName}`, (0, util_1.onlyIf)(runtime.supportsNesting, async () => {
655
- await expect(`
656
- run: ${databaseName}.table('malloytest.state_facts') extend {
657
- measure: total_births is births.sum()
658
- measure: births_per_100k is floor(total_births/ all(total_births) * 100000)
659
- } -> {
660
- group_by: upper_name is upper(popular_name)
661
- nest: by_state is {
662
- group_by: state
663
- aggregate: births_per_100k
664
- }
665
- }
666
- `).malloyResultMatches(runtime, { 'by_state.births_per_100k': 36593 });
667
- }));
668
- test(`ungrouped nested group by float - ${databaseName}`, (0, util_1.onlyIf)(runtime.supportsNesting, async () => {
669
- await expect(`
670
- run: ${databaseName}.table('malloytest.state_facts') extend {
671
- measure: total_births is births.sum()
672
- measure: ug is all(total_births)
673
- } -> {
674
- group_by: f is floor(airport_count/300.0)
675
- nest: by_state is {
676
- group_by: state
677
- aggregate: ug
678
- }
679
- }
680
- `).malloyResultMatches(runtime, { 'by_state.ug': 62742230 });
681
- }));
682
- it(`run simple sql - ${databaseName}`, async () => {
683
- const result = await runtime
684
- .loadQuery(`run: conn.sql('select 1 as ${q `one`}')`)
685
- .run();
686
- expect(result.data.value[0]['one']).toBe(1);
687
- });
688
- it(`simple sql is exactly as written - ${databaseName}`, async () => {
689
- const result = await runtime
690
- .loadQuery(`run: conn.sql('select 1 as ${q `one`}')`)
691
- .run();
692
- if (databaseName === 'postgres') {
693
- expect(result.sql).toBe(`WITH __stage0 AS (
694
- select 1 as ${q `one`})
695
- SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
696
- }
697
- else {
698
- expect(result.sql).toBe(`select 1 as ${q `one`}`);
699
- }
700
- expect(result.resultExplore).not.toBeUndefined();
701
- });
702
- it(`source from query defined as sql query - ${databaseName}`, async () => {
703
- const result = await runtime
704
- .loadQuery(`
705
- query: q is conn.sql('select 1 as ${q `one`}')
706
- source: s is q
707
- run: s -> { select: * }
708
- `)
709
- .run();
710
- expect(result.data.path(0, 'one').number.value).toBe(1);
711
- });
712
- it(`source from query defined as other query - ${databaseName}`, async () => {
713
- const result = await runtime
714
- .loadQuery(`
715
- query: q is conn.table('malloytest.flights') -> { group_by: carrier }
716
- source: s is q
717
- run: s -> { select: *; order_by: carrier }
718
- `)
719
- .run();
720
- expect(result.data.path(0, 'carrier').string.value).toBe('AA');
721
- });
722
- it(`all with parameters - basic - ${databaseName}`, async () => {
723
- await expect(`
724
- run: ${databaseName}.table('malloytest.state_facts') extend {
725
- measure: total_births is births.sum()
726
- } -> {
727
- group_by: popular_name, state
728
- aggregate:
729
- total_births
730
- all_births is all(total_births)
731
- all_name is exclude(total_births, state)
732
- }
733
- `).malloyResultMatches(runtime, {
734
- all_births: 295727065,
735
- all_name: 197260594,
736
- });
737
- });
738
- test(`all with parameters - nest - ${databaseName}`, (0, util_1.onlyIf)(runtime.supportsNesting, async () => {
739
- await expect(`
740
- run: ${databaseName}.table('malloytest.state_facts') extend {
741
- measure: total_births is births.sum()
742
- dimension: abc is floor(airport_count/300)
743
- } -> {
744
- group_by: abc
745
- aggregate: total_births
746
- nest: by_stuff is {
747
- group_by: popular_name, state
748
- aggregate:
749
- total_births
750
- all_births is all(total_births)
751
- all_name is exclude(total_births, state)
752
- }
753
- }
754
- `).malloyResultMatches(runtime, {
755
- 'by_stuff.all_births': 119809719,
756
- 'by_stuff.all_name': 61091215,
757
- });
758
- }));
759
- test(`single value to udf - ${databaseName}`, (0, util_1.onlyIf)(runtime.supportsNesting && runtime.dialect.supportsPipelinesInViews, async () => {
760
- await expect(`
761
- run: ${databaseName}.table('malloytest.state_facts') extend {
762
- view: fun is {
763
- aggregate: t is count()
764
- } -> { select: t1 is t+1 }
765
- } -> { nest: fun }
766
- `).malloyResultMatches(runtime, { 'fun.t1': 52 });
767
- }));
768
- test(`Multi value to udf - ${databaseName}`, (0, util_1.onlyIf)(runtime.supportsNesting && runtime.dialect.supportsPipelinesInViews, async () => {
769
- await expect(`
770
- run: ${databaseName}.table('malloytest.state_facts') extend {
771
- view: fun is {
772
- group_by: one is 1
773
- aggregate: t is count()
774
- } -> { select: t1 is t+1 }
775
- } -> {
776
- nest: fun
777
- }
778
- `).malloyResultMatches(runtime, { 'fun.t1': 52 });
779
- }));
780
- test(`Multi value to udf group by - ${databaseName}`, (0, util_1.onlyIf)(runtime.supportsNesting && runtime.dialect.supportsPipelinesInViews, async () => {
781
- await expect(`
782
- run: ${databaseName}.table('malloytest.state_facts') extend {
783
- view: fun is {
784
- group_by: one is 1
785
- aggregate: t is count()
786
- } -> { group_by: t1 is t+1 }
787
- } -> {
788
- nest: fun
789
- }
790
- `).malloyResultMatches(runtime, { 'fun.t1': 52 });
791
- }));
792
- const sql1234 = `${databaseName}.sql('SELECT 1 as ${q `a`}, 2 as ${q `b`} UNION ALL SELECT 3, 4')`;
793
- it(`sql as source - ${databaseName}`, async () => {
794
- await expect(`
795
- run: ${sql1234} -> { select: a }
796
- `).malloyResultMatches(runtime, { a: 1 });
797
- });
798
- it(`sql directly - ${databaseName}`, async () => {
799
- await expect(`run: ${sql1234}`).malloyResultMatches(runtime, { a: 1 });
800
- });
801
- it(`sql with turducken- ${databaseName}`, async () => {
802
- const turduckenQuery = `
803
- run: ${databaseName}.sql("""
804
- SELECT
805
- 'something' as SOMETHING,
806
- *
807
- FROM %{
808
- ${databaseName}.table('malloytest.state_facts') -> {
809
- group_by: popular_name
810
- aggregate: state_count is count()
811
- }
812
- } AS by_name_query
813
- """) -> {
814
- select: *; where: popular_name = 'Emma'
815
- }`;
816
- await expect(turduckenQuery).malloyResultMatches(runtime, { state_count: 6 });
817
- });
818
- // local declarations
819
- it(`local declarations external query - ${databaseName}`, async () => {
820
- await expect(`
821
- run: ${sql1234} -> {
822
- extend: { dimension: c is a + 1 }
823
- select: c
824
- }
825
- `).malloyResultMatches(runtime, { c: 2 });
826
- });
827
- it(`local declarations named query - ${databaseName}`, async () => {
828
- await expect(`
829
- run: ${sql1234} extend {
830
- view: bar is {
831
- extend: { dimension: c is a + 1 }
832
- select: c
833
- }
834
- } -> bar
835
- `).malloyResultMatches(runtime, { c: 2 });
836
- });
837
- it(`local declarations refined named query - ${databaseName}`, async () => {
838
- await expect(`
839
- run: ${sql1234} extend {
840
- view: bar is {
841
- extend: {dimension: c is a + 1}
842
- select: c
843
- }
844
- view: baz is bar + {
845
- extend: {dimension: d is c + 1}
846
- select: d
847
- }
848
- } -> baz
849
- `).malloyResultMatches(runtime, { d: 3 });
850
- });
851
- it(`regexp match- ${databaseName}`, async () => {
852
- await expect(`
853
- run: ${databaseName}.sql("""
854
- SELECT 'hello mom' as ${q `a`}, 'cheese tastes good' as ${q `b`}
855
- UNION ALL SELECT 'lloyd is a bozo', 'michael likes poetry'
856
- """) -> {
857
- aggregate: llo is count() {where: a ~ r'llo'}
858
- aggregate: m2 is count() {where: a !~ r'bozo'}
859
- }
860
- `).malloyResultMatches(runtime, { llo: 2, m2: 1 });
861
- });
862
- it(`substitution precedence- ${databaseName}`, async () => {
863
- await expect(`
864
- run: ${databaseName}.sql("""
865
- SELECT 5 as ${q `a`}, 2 as ${q `b`}
866
- UNION ALL SELECT 3, 4
867
- """) -> {
868
- extend: {dimension: c is b + 4}
869
- select: x is a * c
870
- }
871
- `).malloyResultMatches(runtime, { x: 30 });
872
- });
873
- test(`array unnest - ${databaseName}`, (0, util_1.onlyIf)(runtime.supportsNesting && runtime.dialect.supportsArraysInData, async () => {
874
- const splitFN = getSplitFunction(databaseName);
875
- await expect(`
876
- run: ${databaseName}.sql("""
877
- SELECT
878
- ${q `city`},
879
- ${splitFN(q `city`, ' ')} as ${q `words`}
880
- FROM ${rootDbPath(databaseName)}malloytest.aircraft
881
- """) -> {
882
- where: words.value != null
883
- group_by: words.value
884
- aggregate: c is count()
885
- }
886
- `).malloyResultMatches(runtime, { c: 145 });
887
- }));
888
- // make sure we can count the total number of elements when fanning out.
889
- test(`array unnest x 2 - ${databaseName}`, (0, util_1.onlyIf)(runtime.supportsNesting && runtime.dialect.supportsArraysInData, async () => {
890
- const splitFN = getSplitFunction(databaseName);
891
- await expect(`
892
- run: ${databaseName}.sql("""
893
- SELECT
894
- ${q `city`},
895
- ${splitFN(q `city`, ' ')} as ${q `words`},
896
- ${splitFN(q `city`, 'A')} as ${q `abreak`}
897
- FROM ${rootDbPath(databaseName)}malloytest.aircraft
898
- WHERE ${q `city`} IS NOT null
899
- """) -> {
900
- aggregate:
901
- b is count()
902
- c is words.count()
903
- a is abreak.count()
904
- }`).malloyResultMatches(runtime, { b: 3552, c: 4586, a: 6601 });
905
- }));
906
- test(`can unnest from file - ${databaseName}`, (0, util_1.onlyIf)(runtime.supportsNesting && runtime.dialect.readsNestedData, async () => {
907
- await expect(`
908
- source: ga_sample is ${databaseName}.table('malloytest.ga_sample')
909
-
910
- run: ga_sample -> {
911
- where: hits.product.productBrand != null
912
- group_by:
913
- hits.product.productBrand
914
- hits.product.productSKU
915
- aggregate:
916
- h is hits.count()
917
- c is count()
918
- p is hits.product.count()
919
- }
920
- `).malloyResultMatches(runtime, { h: 1192, c: 681, p: 1192 });
921
- }));
922
- test(`nest null - ${databaseName}`, (0, util_1.onlyIf)(runtime.supportsNesting, async () => {
923
- const result = await runtime
924
- .loadQuery(`
925
- run: ${databaseName}.table('malloytest.airports') -> {
926
- where: faa_region = null
927
- group_by: faa_region
928
- aggregate: airport_count is count()
929
- nest: by_state is {
930
- where: state != null
931
- group_by: state
932
- aggregate: airport_count is count()
933
- }
934
- nest: by_state1 is {
935
- where: state != null
936
- group_by: state
937
- aggregate: airport_count is count()
938
- limit: 1
939
- }
940
- }
941
- `)
942
- .run();
943
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
944
- const d = result.data.toObject();
945
- expect(d[0]['by_state']).not.toBe(null);
946
- expect(d[0]['by_state1']).not.toBe(null);
947
- }));
948
- test(`number as null- ${databaseName}`, (0, util_1.onlyIf)(runtime.supportsNesting, async () => {
949
- const result = await runtime
950
- .loadQuery(`
951
- source: s is ${databaseName}.table('malloytest.state_facts') extend {
952
- }
953
- run: s-> {
954
- group_by: state
955
- nest: ugly is {
956
- group_by: popular_name
957
- aggregate: foo is NULLIF(sum(airport_count)*0,0)+1
958
- }
959
- }
960
- `)
961
- .run();
962
- expect(result.data.path(0, 'ugly', 0, 'foo').value).toBe(null);
963
- }));
964
- it(`removes surpuflous order_by - solo aggregates - ${databaseName}`, async () => {
965
- const result = await runtime
966
- .loadQuery(`
967
- run: ${databaseName}.table('malloytest.state_facts') -> {
968
- aggregate: airport_count.sum()
969
- }
970
- `)
971
- .run();
972
- expect(result.sql).not.toContain('ORDER BY');
973
- });
974
- it(`removes surpuflous order_by - pipeline - ${databaseName}`, async () => {
975
- const result = await runtime
976
- .loadQuery(`
977
- run: ${databaseName}.table('malloytest.state_facts') -> {
978
- group_by: state
979
- aggregate: airport_count.sum()
980
- order_by: state desc
981
- }
982
- -> {
983
- aggregate: airport_count.sum()
984
- }
985
- `)
986
- .run();
987
- expect(result.sql).not.toContain('ORDER BY');
988
- });
989
- it(`removes surpuflous order_by - joined_query - ${databaseName}`, async () => {
990
- const result = await runtime
991
- .loadQuery(`
992
- query: foo is ${databaseName}.table('malloytest.state_facts') -> {
993
- group_by: state
994
- aggregate: airport_count.sum()
995
- order_by: state desc
996
- }
997
-
998
- run: ${databaseName}.table('malloytest.state_facts') -> {
999
- extend: {
1000
- join_one: foo on state = foo.state
1001
- }
1002
- aggregate: x is foo.airport_count.sum()
1003
- }
1004
- `)
1005
- .run();
1006
- expect(result.sql).not.toContain('ORDER BY');
1007
- });
1008
- it(`removes surpuflous order_by - joined_query pipeline - ${databaseName}`, async () => {
1009
- const result = await runtime
1010
- .loadQuery(`
1011
- query: foo is ${databaseName}.table('malloytest.state_facts') -> {
1012
- group_by: state
1013
- aggregate: airport_count.sum()
1014
- order_by: state desc
1015
- } -> {
1016
- group_by: state
1017
- aggregate: airport_count.sum()
1018
- order_by: state desc
1019
- }
1020
-
1021
- run: ${databaseName}.table('malloytest.state_facts') -> {
1022
- extend: {
1023
- join_one: foo on state = foo.state
1024
- }
1025
- aggregate: x is foo.airport_count.sum()
1026
- }
1027
- `)
1028
- .run();
1029
- expect(result.sql).not.toContain('ORDER BY');
1030
- });
1031
- describe('quoting and strings', () => {
1032
- const tick = "'";
1033
- const back = '\\';
1034
- test('backslash quote', async () => {
1035
- await expect(`
1036
- run: ${databaseName}.sql('SELECT 1 as one') -> {
1037
- select: tick is '${back}${tick}'
1038
- }
1039
- `).malloyResultMatches(runtime, { tick });
1040
- });
1041
- test('backslash backslash', async () => {
1042
- await expect(`
1043
- run: ${databaseName}.sql("SELECT 1 as one") -> {
1044
- select: back is '${back}${back}'
1045
- }
1046
- `).malloyResultMatches(runtime, { back });
1047
- });
1048
- test('spaces in names', (0, util_1.onlyIf)(runtime.supportsNesting, async () => {
1049
- await expect(`
1050
- source: \`space race\` is ${databaseName}.table('malloytest.state_facts') extend {
1051
- join_one: \`j space\` is ${databaseName}.table('malloytest.state_facts') on \`j space\`.state=state
1052
- view: \`q u e r y\` is {
1053
- group_by:
1054
- \`P O P\` is popular_name
1055
- \`J P O P\` is \`j space\`.popular_name
1056
- aggregate: \`c o u n t\` is count()
1057
- calculate:
1058
- \`R O W\` is row_number()
1059
- \`l a g\` is lag(\`P O P\`, 1)
1060
- nest: \`by state\` is {
1061
- group_by: \`J S\` is \`j space\`.state
1062
- aggregate: \`c o u n t\` is count()
1063
- }
1064
- }
1065
- }
1066
- run: \`space race\` -> \`q u e r y\`
1067
- `).malloyResultMatches(runtime, { 'c o u n t': 24 });
1068
- }));
1069
- });
1070
- });
1071
- //# sourceMappingURL=nomodel.spec.js.map