@malloydata/malloy-tests 0.0.138-dev240405003346 → 0.0.138-dev240408220220

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/package.json CHANGED
@@ -21,13 +21,13 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@jest/globals": "^29.4.3",
24
- "@malloydata/db-bigquery": "^0.0.138-dev240405003346",
25
- "@malloydata/db-duckdb": "^0.0.138-dev240405003346",
26
- "@malloydata/db-postgres": "^0.0.138-dev240405003346",
27
- "@malloydata/db-snowflake": "^0.0.138-dev240405003346",
28
- "@malloydata/db-trino": "^0.0.138-dev240405003346",
29
- "@malloydata/malloy": "^0.0.138-dev240405003346",
30
- "@malloydata/render": "^0.0.138-dev240405003346",
24
+ "@malloydata/db-bigquery": "^0.0.138-dev240408220220",
25
+ "@malloydata/db-duckdb": "^0.0.138-dev240408220220",
26
+ "@malloydata/db-postgres": "^0.0.138-dev240408220220",
27
+ "@malloydata/db-snowflake": "^0.0.138-dev240408220220",
28
+ "@malloydata/db-trino": "^0.0.138-dev240408220220",
29
+ "@malloydata/malloy": "^0.0.138-dev240408220220",
30
+ "@malloydata/render": "^0.0.138-dev240408220220",
31
31
  "jsdom": "^22.1.0",
32
32
  "luxon": "^2.4.0",
33
33
  "madge": "^6.0.0"
@@ -36,5 +36,5 @@
36
36
  "@types/jsdom": "^21.1.1",
37
37
  "@types/luxon": "^2.4.0"
38
38
  },
39
- "version": "0.0.138-dev240405003346"
39
+ "version": "0.0.138-dev240408220220"
40
40
  }
@@ -105,6 +105,8 @@ expressionModels.forEach((expressionModel, databaseName) => {
105
105
 
106
106
  const result = await run();
107
107
  testCases.forEach((testCase, i) => {
108
+ // console.log(databaseName, result.sql);
109
+ // console.log(result.data);
108
110
  expect(result.data.path(0, `f${i}`).value).toBe(testCase[1]);
109
111
  });
110
112
  };
@@ -170,11 +172,7 @@ expressionModels.forEach((expressionModel, databaseName) => {
170
172
  it(`works - ${databaseName}`, async () => {
171
173
  await funcTestMultiple(
172
174
  ['ceil(1.9)', 2],
173
- // TODO Remove when we upgrade to DuckDB 0.8.X -- DuckDB has some bugs with rounding
174
- // that are fixed in 0.8.
175
- ...(databaseName === 'duckdb_wasm'
176
- ? []
177
- : ([['ceil(-1.9)', -1]] as [string, number][])),
175
+ ['ceil(-1.9)', -1],
178
176
  ['ceil(null)', null]
179
177
  );
180
178
  });
@@ -216,9 +214,16 @@ expressionModels.forEach((expressionModel, databaseName) => {
216
214
  ["replace('aaaa', r'.', 'c')", 'cccc'],
217
215
  [
218
216
  "replace('axbxc', r'(a).(b).(c)', '\\\\0 - \\\\1 - \\\\2 - \\\\3')",
219
- databaseName === 'postgres' ? '\\0 - a - b - c' : 'axbxc - a - b - c',
217
+ databaseName === 'postgres'
218
+ ? '\\0 - a - b - c'
219
+ : databaseName === 'trino'
220
+ ? '0 - 1 - 2 - 3'
221
+ : 'axbxc - a - b - c',
222
+ ],
223
+ [
224
+ "replace('aaaa', '', 'c')",
225
+ databaseName === 'trino' ? 'cacacacac' : 'aaaa',
220
226
  ],
221
- ["replace('aaaa', '', 'c')", 'aaaa'],
222
227
  ["replace(null, 'a', 'c')", null],
223
228
  ["replace('aaaa', null, 'c')", null],
224
229
  ["replace('aaaa', 'a', null)", null]
@@ -232,7 +237,7 @@ expressionModels.forEach((expressionModel, databaseName) => {
232
237
  ["substr('foo', 2)", 'oo'],
233
238
  ["substr('foo', 2, 1)", 'o'],
234
239
  ["substr('foo bar baz', -3)", 'baz'],
235
- ['substr(null, 1, 2)', null],
240
+ ["substr(nullif('x','x'), 1, 2)", null], // nullMatchesFunctionSignature.
236
241
  ["substr('aaaa', null, 1)", null],
237
242
  ["substr('aaaa', 1, null)", null]
238
243
  );
@@ -245,7 +250,7 @@ expressionModels.forEach((expressionModel, databaseName) => {
245
250
  ['floor(cbrt!(27)::number)', 3],
246
251
  ['floor(cbrt!number(27))', 3],
247
252
  ["substr('foo bar baz', -3)", 'baz'],
248
- ['substr(null, 1, 2)', null],
253
+ ["substr(nullif('x','x'), 1, 2)", null], // nullMatchesFunctionSignature
249
254
  ["substr('aaaa', null, 1)", null],
250
255
  ["substr('aaaa', 1, null)", null]
251
256
  );
@@ -254,7 +259,7 @@ expressionModels.forEach((expressionModel, databaseName) => {
254
259
 
255
260
  describe('stddev', () => {
256
261
  // TODO symmetric aggregates don't work with custom aggregate functions in BQ currently
257
- if (['bigquery', 'snowflake'].includes(databaseName)) return;
262
+ if (['bigquery', 'snowflake', 'trino'].includes(databaseName)) return;
258
263
  it(`works - ${databaseName}`, async () => {
259
264
  await funcTestAgg('round(stddev(aircraft_models.seats))', 29);
260
265
  });
@@ -7,7 +7,7 @@
7
7
  * (the "Software"), to deal in the Software without restriction,
8
8
  * including without limitation the rights to use, copy, modify, merge,
9
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,
10
+ * and to permit persons to whom the Software is furnished to do so
11
11
  * subject to the following conditions:
12
12
  *
13
13
  * The above copyright notice and this permission notice shall be
@@ -231,7 +231,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
231
231
  }
232
232
  run: f->{
233
233
  aggregate:
234
- row_count is count(concat(state,a.r))
234
+ row_count is count(concat(state,a.r::string))
235
235
  left_sum is airport_count.sum()
236
236
  right_sum is a.r.sum()
237
237
  sum_sum is sum(airport_count + a.r)
@@ -897,7 +897,10 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
897
897
 
898
898
  it(`sql as source - ${databaseName}`, async () => {
899
899
  await expect(`
900
- run: ${sql1234} -> { select: a }
900
+ run: ${sql1234} -> {
901
+ select: a
902
+ order_by: 1
903
+ }
901
904
  `).malloyResultMatches(runtime, {a: 1});
902
905
  });
903
906
 
@@ -919,6 +922,7 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
919
922
  } AS by_name_query
920
923
  """) -> {
921
924
  select: *; where: popular_name = 'Emma'
925
+ order_by: state_count DESC
922
926
  }`;
923
927
  await expect(turduckenQuery).malloyResultMatches(runtime, {state_count: 6});
924
928
  });
@@ -929,6 +933,7 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
929
933
  run: ${sql1234} -> {
930
934
  extend: { dimension: c is a + 1 }
931
935
  select: c
936
+ order_by: 1
932
937
  }
933
938
  `).malloyResultMatches(runtime, {c: 2});
934
939
  });
@@ -939,6 +944,7 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
939
944
  view: bar is {
940
945
  extend: { dimension: c is a + 1 }
941
946
  select: c
947
+ order_by: 1
942
948
  }
943
949
  } -> bar
944
950
  `).malloyResultMatches(runtime, {c: 2});
@@ -950,10 +956,12 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
950
956
  view: bar is {
951
957
  extend: {dimension: c is a + 1}
952
958
  select: c
959
+ order_by: 1
953
960
  }
954
961
  view: baz is bar + {
955
962
  extend: {dimension: d is c + 1}
956
963
  select: d
964
+ order_by: 1
957
965
  }
958
966
  } -> baz
959
967
  `).malloyResultMatches(runtime, {d: 3});