@malloydata/malloy-tests 0.0.222-dev241211235345 → 0.0.222-dev241212021944

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.222-dev241211235345",
25
- "@malloydata/db-duckdb": "^0.0.222-dev241211235345",
26
- "@malloydata/db-postgres": "^0.0.222-dev241211235345",
27
- "@malloydata/db-snowflake": "^0.0.222-dev241211235345",
28
- "@malloydata/db-trino": "^0.0.222-dev241211235345",
29
- "@malloydata/malloy": "^0.0.222-dev241211235345",
30
- "@malloydata/render": "^0.0.222-dev241211235345",
24
+ "@malloydata/db-bigquery": "^0.0.222-dev241212021944",
25
+ "@malloydata/db-duckdb": "^0.0.222-dev241212021944",
26
+ "@malloydata/db-postgres": "^0.0.222-dev241212021944",
27
+ "@malloydata/db-snowflake": "^0.0.222-dev241212021944",
28
+ "@malloydata/db-trino": "^0.0.222-dev241212021944",
29
+ "@malloydata/malloy": "^0.0.222-dev241212021944",
30
+ "@malloydata/render": "^0.0.222-dev241212021944",
31
31
  "events": "^3.3.0",
32
32
  "jsdom": "^22.1.0",
33
33
  "luxon": "^2.4.0",
@@ -37,5 +37,5 @@
37
37
  "@types/jsdom": "^21.1.1",
38
38
  "@types/luxon": "^2.4.0"
39
39
  },
40
- "version": "0.0.222-dev241211235345"
40
+ "version": "0.0.222-dev241212021944"
41
41
  }
@@ -14,6 +14,7 @@ import {
14
14
  ArrayTypeDef,
15
15
  FieldDef,
16
16
  Expr,
17
+ SQLSourceDef,
17
18
  } from '@malloydata/malloy';
18
19
 
19
20
  const runtimes = new RuntimeList(databasesFromEnvironmentOr(allDatabases));
@@ -198,6 +199,44 @@ describe.each(runtimes.runtimeList)(
198
199
  }
199
200
  }
200
201
  );
202
+ test.when(supportsNestedArrays && canReadCompoundSchema)(
203
+ 'Can read schema for array of arrays',
204
+ async () => {
205
+ // a lot of work to make [[1],[2]] on all dialects
206
+ const aLit: ArrayLiteralNode = {
207
+ node: 'arrayLiteral',
208
+ typeDef: {type: 'array', elementTypeDef: {type: 'number'}},
209
+ kids: {values: []},
210
+ };
211
+ const aOne = {...aLit};
212
+ aOne.kids.values[0] = {node: 'numberLiteral', literal: '1', sql: '1'};
213
+ aOne.sql = runtime.dialect.sqlLiteralArray(aOne);
214
+ const aTwo = {...aLit, sql: '2'};
215
+ aTwo.kids.values[0] = {node: 'numberLiteral', literal: '2', sql: '2'};
216
+ aTwo.sql = runtime.dialect.sqlLiteralArray(aTwo);
217
+ const aoa: ArrayLiteralNode = {
218
+ node: 'arrayLiteral',
219
+ typeDef: {type: 'array', elementTypeDef: aLit.typeDef},
220
+ kids: {values: [aOne, aTwo]},
221
+ };
222
+ const sql_aoa = runtime.dialect.sqlLiteralArray(aoa);
223
+ const asStruct: SQLSourceDef = {
224
+ name: 'select_with_aoa',
225
+ type: 'sql_select',
226
+ connection: conName,
227
+ dialect: runtime.dialect.name,
228
+ selectStr: `SELECT ${sql_aoa} AS aoa`,
229
+ fields: [],
230
+ };
231
+ const ret = await runtime.connection.fetchSchemaForSQLStruct(
232
+ asStruct,
233
+ {}
234
+ );
235
+ expect(ret.structDef).toBeDefined();
236
+ const aoa_ent = ret.structDef!.fields[0];
237
+ expect(aoa_ent).toMatchObject(aoa.typeDef);
238
+ }
239
+ );
201
240
  test.when(supportsNestedArrays)('bare array of array', async () => {
202
241
  await expect(`
203
242
  run: ${empty} -> { select: aoa is [[1,2]] }
@@ -1170,6 +1170,7 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
1170
1170
  test.when(
1171
1171
  runtime.supportsNesting && runtime.dialect.supportsPipelinesInViews
1172
1172
  )(`Nested pipelines sort properly - ${databaseName}`, async () => {
1173
+ const doTrace = false; // Have to turn this on to debug this test
1173
1174
  const result = await runtime
1174
1175
  .loadQuery(
1175
1176
  `
@@ -1217,11 +1218,11 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
1217
1218
  `
1218
1219
  )
1219
1220
  .run();
1220
- console.log(result.sql);
1221
+ if (doTrace) console.log(result.sql);
1221
1222
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1222
1223
  const d: any = result.data.toObject();
1223
1224
  const baseView: {state: string; airports: number}[] = d[0]['base_view'];
1224
- console.log(baseView);
1225
+ if (doTrace) console.log(baseView);
1225
1226
  let baseMax = baseView[0];
1226
1227
  for (const b of baseView) {
1227
1228
  expect(b.airports).toBeGreaterThanOrEqual(baseMax.airports);
@@ -1229,7 +1230,7 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
1229
1230
  }
1230
1231
 
1231
1232
  const baseView2: {state: string; aircrafts: number}[] = d[0]['base_view2'];
1232
- console.log(baseView2);
1233
+ if (doTrace) console.log(baseView2);
1233
1234
  let baseMax2 = baseView2[0];
1234
1235
  for (const b of baseView2) {
1235
1236
  expect(b.aircrafts).toBeGreaterThanOrEqual(baseMax2.aircrafts);
@@ -1237,7 +1238,7 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
1237
1238
  }
1238
1239
  // implicit order by
1239
1240
  const baseView3: {state: string; aircrafts: number}[] = d[0]['base_view3'];
1240
- console.log(baseView3);
1241
+ if (doTrace) console.log(baseView3);
1241
1242
  let baseMax3 = baseView3[0];
1242
1243
  for (const b of baseView3) {
1243
1244
  expect(b.aircrafts).toBeLessThanOrEqual(baseMax3.aircrafts);
@@ -131,7 +131,7 @@ describe.each(allDucks.runtimeList)('duckdb:%s', (dbName, runtime) => {
131
131
  ).malloyResultMatches(runtime, {abc: 'a', abc3: 'a3'});
132
132
  });
133
133
 
134
- describe('time', () => {
134
+ describe('time oddities', () => {
135
135
  const zone = 'America/Mexico_City'; // -06:00 no DST
136
136
  const zone_2020 = DateTime.fromObject(
137
137
  {
@@ -147,13 +147,12 @@ describe.each(allDucks.runtimeList)('duckdb:%s', (dbName, runtime) => {
147
147
  }
148
148
  );
149
149
  test('can cast TIMESTAMPTZ to timestamp', async () => {
150
- await expect(
151
- `run: duckdb.sql("""
150
+ await expect(`
151
+ run: duckdb.sql("""
152
152
  SELECT TIMESTAMPTZ '2020-02-20 00:00:00 ${zone}' as t_tstz
153
153
  """) -> {
154
154
  select: mex_220 is t_tstz::timestamp
155
- }`
156
- ).malloyResultMatches(runtime, {mex_220: zone_2020.toJSDate()});
155
+ }`).malloyResultMatches(runtime, {mex_220: zone_2020.toJSDate()});
157
156
  });
158
157
  });
159
158
  });