@malloydata/malloy-tests 0.0.144-dev240426151705 → 0.0.144-dev240503150037

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.144-dev240426151705",
25
- "@malloydata/db-duckdb": "^0.0.144-dev240426151705",
26
- "@malloydata/db-postgres": "^0.0.144-dev240426151705",
27
- "@malloydata/db-snowflake": "^0.0.144-dev240426151705",
28
- "@malloydata/db-trino": "^0.0.144-dev240426151705",
29
- "@malloydata/malloy": "^0.0.144-dev240426151705",
30
- "@malloydata/render": "^0.0.144-dev240426151705",
24
+ "@malloydata/db-bigquery": "^0.0.144-dev240503150037",
25
+ "@malloydata/db-duckdb": "^0.0.144-dev240503150037",
26
+ "@malloydata/db-postgres": "^0.0.144-dev240503150037",
27
+ "@malloydata/db-snowflake": "^0.0.144-dev240503150037",
28
+ "@malloydata/db-trino": "^0.0.144-dev240503150037",
29
+ "@malloydata/malloy": "^0.0.144-dev240503150037",
30
+ "@malloydata/render": "^0.0.144-dev240503150037",
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.144-dev240426151705"
39
+ "version": "0.0.144-dev240503150037"
40
40
  }
@@ -430,6 +430,33 @@ expressionModels.forEach((expressionModel, databaseName) => {
430
430
  expect(result.data.path(2, 'neg_r').value).toBe(-3);
431
431
  expect(result.data.path(3, 'neg_r').value).toBe(-3);
432
432
  });
433
+
434
+ it(`properly isolated nested calculations - ${databaseName}`, async () => {
435
+ const result = await expressionModel
436
+ .loadQuery(
437
+ `run: ${databaseName}.table('malloytest.airports') -> {
438
+ group_by: faa_region
439
+ aggregate: airport_count is count()
440
+ calculate: id is row_number()
441
+ nest: by_fac_type is {
442
+ group_by: fac_type
443
+ aggregate: airport_count is count()
444
+ calculate: id2 is row_number()
445
+ nest: elevation is {
446
+ aggregate: avg_elevation is elevation.avg()
447
+ }
448
+ limit: 2
449
+ }
450
+ }
451
+ -> {
452
+ // should be 2 rows, max of 2
453
+ group_by: by_fac_type.id2
454
+ order_by: id2 desc
455
+ }`
456
+ )
457
+ .run();
458
+ expect(result.data.path(0, 'id2').value).toBe(2);
459
+ });
433
460
  });
434
461
 
435
462
  describe('lag', () => {
@@ -1226,6 +1226,15 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
1226
1226
  `).malloyResultMatches(runtime, {back});
1227
1227
  });
1228
1228
 
1229
+ test('source with reserve word', async () => {
1230
+ await expect(`
1231
+ source: create is ${databaseName}.table('malloytest.state_facts')
1232
+ run: create -> {
1233
+ aggregate: c is count()
1234
+ }
1235
+ `).malloyResultMatches(runtime, {c: 51});
1236
+ });
1237
+
1229
1238
  test.when(runtime.supportsNesting)('spaces in names', async () => {
1230
1239
  await expect(`
1231
1240
  source: \`space race\` is ${databaseName}.table('malloytest.state_facts') extend {
@@ -33,7 +33,7 @@ describe('turducken', () => {
33
33
  run: duckdb.sql("""SELECT one as num FROM %{hasone->{select:*}}""")
34
34
  `);
35
35
  const qsql = await q.getSQL();
36
- expect(qsql).toContain(`FROM (${sql}) as hasone`);
36
+ expect(qsql).toContain(`FROM (${sql}) as base`);
37
37
  });
38
38
  test('malloy source code not double-wrapped in parens', async () => {
39
39
  const sql = 'SELECT 1 as one';
@@ -42,6 +42,6 @@ describe('turducken', () => {
42
42
  run: duckdb.sql("""SELECT one as num FROM (%{hasone->{select:*}})""")
43
43
  `);
44
44
  const qsql = await q.getSQL();
45
- expect(qsql).toContain(`FROM (${sql}) as hasone`);
45
+ expect(qsql).toContain(`FROM (${sql}) as base`);
46
46
  });
47
47
  });