@malloydata/malloy-tests 0.0.301 → 0.0.303

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,14 +21,14 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@jest/globals": "^29.4.3",
24
- "@malloydata/db-bigquery": "0.0.301",
25
- "@malloydata/db-duckdb": "0.0.301",
26
- "@malloydata/db-postgres": "0.0.301",
27
- "@malloydata/db-snowflake": "0.0.301",
28
- "@malloydata/db-trino": "0.0.301",
29
- "@malloydata/malloy": "0.0.301",
30
- "@malloydata/malloy-tag": "0.0.301",
31
- "@malloydata/render": "0.0.301",
24
+ "@malloydata/db-bigquery": "0.0.303",
25
+ "@malloydata/db-duckdb": "0.0.303",
26
+ "@malloydata/db-postgres": "0.0.303",
27
+ "@malloydata/db-snowflake": "0.0.303",
28
+ "@malloydata/db-trino": "0.0.303",
29
+ "@malloydata/malloy": "0.0.303",
30
+ "@malloydata/malloy-tag": "0.0.303",
31
+ "@malloydata/render": "0.0.303",
32
32
  "events": "^3.3.0",
33
33
  "jsdom": "^22.1.0",
34
34
  "luxon": "^2.4.0",
@@ -38,5 +38,5 @@
38
38
  "@types/jsdom": "^21.1.1",
39
39
  "@types/luxon": "^2.4.0"
40
40
  },
41
- "version": "0.0.301"
41
+ "version": "0.0.303"
42
42
  }
@@ -43,6 +43,16 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
43
43
  run: x -> multistage
44
44
  `).malloyResultMatches(runtime, {foo: 1});
45
45
  });
46
+ it('SQL function contributes to field usage', async () => {
47
+ await expect(`
48
+ ##! experimental {composite_sources sql_functions}
49
+ source: state_facts is ${databaseName}.table('malloytest.state_facts')
50
+ source: x is compose(state_facts, state_facts extend { dimension: foo is 1 }) extend {
51
+ dimension: foo_copy is sql_number('\${foo}')
52
+ }
53
+ run: x -> { group_by: foo_copy }
54
+ `).malloyResultMatches(runtime, {foo_copy: 1});
55
+ });
46
56
  describe('composited joins', () => {
47
57
  it('basic composited join', async () => {
48
58
  await expect(`
@@ -559,6 +569,41 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
559
569
  }
560
570
  `).malloyResultMatches(runtime, {a_avg: 15, c: 2});
561
571
  });
572
+ test('sql function contributes to partition composite selection', async () => {
573
+ await expect(`
574
+ ##! experimental.sql_functions
575
+ #! experimental { partition_composite { partition_field=p partitions={a={a} b={b}} } }
576
+ source: comp is ${databaseName}.sql("""
577
+ SELECT 10 AS ${id('a')}, 0 AS ${id('b')}, 'a' AS ${id('p')}
578
+ UNION ALL SELECT 20 AS ${id('a')}, 0 AS ${id('b')}, 'a' AS ${id('p')}
579
+ UNION ALL SELECT 0 AS ${id('a')}, 1 AS ${id('b')}, 'b' AS ${id('p')}
580
+ UNION ALL SELECT 0 AS ${id('a')}, 2 AS ${id('b')}, 'b' AS ${id('p')}
581
+ """)
582
+
583
+ run: comp -> {
584
+ // a partition comes first, so it would be selected if there was no field usage
585
+ group_by: b_copy is sql_number('\${b}')
586
+ limit: 1
587
+ order_by: b_copy asc
588
+ }
589
+ `).malloyResultMatches(runtime, {b_copy: 1});
590
+ });
591
+ test('partition composite with fields different from partition name', async () => {
592
+ await expect(`
593
+ #! experimental { partition_composite { partition_field=p partitions={x={a} y={b}} } }
594
+ source: comp is ${databaseName}.sql("""
595
+ SELECT 10 AS ${id('a')}, 0 AS ${id('b')}, 'x' AS ${id('p')}
596
+ UNION ALL SELECT 20 AS ${id('a')}, 0 AS ${id('b')}, 'x' AS ${id('p')}
597
+ UNION ALL SELECT 0 AS ${id('a')}, 1 AS ${id('b')}, 'y' AS ${id('p')}
598
+ UNION ALL SELECT 0 AS ${id('a')}, 2 AS ${id('b')}, 'y' AS ${id('p')}
599
+ """)
600
+
601
+ run: comp -> {
602
+ aggregate: a_avg is a.avg()
603
+ aggregate: c is count()
604
+ }
605
+ `).malloyResultMatches(runtime, {a_avg: 15, c: 2});
606
+ });
562
607
  test('extended partition composite', async () => {
563
608
  await expect(`
564
609
  #! experimental { partition_composite { partition_field=p partitions={a={a} b={b}} } }