@malloydata/malloy-tests 0.0.280 → 0.0.281

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.280",
25
- "@malloydata/db-duckdb": "0.0.280",
26
- "@malloydata/db-postgres": "0.0.280",
27
- "@malloydata/db-snowflake": "0.0.280",
28
- "@malloydata/db-trino": "0.0.280",
29
- "@malloydata/malloy": "0.0.280",
30
- "@malloydata/malloy-tag": "0.0.280",
31
- "@malloydata/render": "0.0.280",
24
+ "@malloydata/db-bigquery": "0.0.281",
25
+ "@malloydata/db-duckdb": "0.0.281",
26
+ "@malloydata/db-postgres": "0.0.281",
27
+ "@malloydata/db-snowflake": "0.0.281",
28
+ "@malloydata/db-trino": "0.0.281",
29
+ "@malloydata/malloy": "0.0.281",
30
+ "@malloydata/malloy-tag": "0.0.281",
31
+ "@malloydata/render": "0.0.281",
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.280"
41
+ "version": "0.0.281"
42
42
  }
@@ -591,54 +591,60 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
591
591
  });
592
592
  });
593
593
 
594
- describe('[not yet supported]', () => {
595
- // See ${...} documentation for lookml here for guidance on remaining work:
596
- // https://cloud.google.com/looker/docs/reference/param-field-sql#sql_for_dimensions
597
- it('${view_name.dimension_name} - one path', async () => {
598
- const query = await expressionModel.loadQuery(
599
- `
600
- ##! experimental { sql_functions }
601
- source: a is ${databaseName}.table('malloytest.aircraft_models') extend { where: aircraft_model_code ? '0270202' }
594
+ it('${view_name.dimension_name} - one path', async () => {
595
+ await expect(`
596
+ ##! experimental { sql_functions }
597
+ source: a0 is ${databaseName}.table('malloytest.aircraft_models')
598
+ source: a is ${databaseName}.table('malloytest.aircraft_models') extend {
599
+ where: aircraft_model_code ? '0270202'
600
+ join_one: a0 on aircraft_model_code = a0.aircraft_model_code
601
+ }
602
602
 
603
- run: a -> {
604
- group_by: string_1 is sql_string("UPPER(\${a.manufacturer})")
605
- }
606
- `
607
- );
608
- await expect(query.run()).rejects.toThrow(
609
- "'.' paths are not yet supported in sql interpolations, found ${a.manufacturer}"
610
- );
603
+ run: a -> {
604
+ group_by: string_1 is sql_string("UPPER(\${a0.manufacturer})")
605
+ }
606
+ `).malloyResultMatches(expressionModel, {
607
+ string_1: 'AHRENS AIRCRAFT CORP.',
611
608
  });
609
+ });
612
610
 
613
- it('${view_name.dimension_name} - multiple paths', async () => {
614
- const query = await expressionModel.loadQuery(
615
- `
616
- ##! experimental { sql_functions }
617
- source: a is ${databaseName}.table('malloytest.aircraft_models') extend { where: aircraft_model_code ? '0270202' }
611
+ it('${view_name.dimension_name} - multiple paths', async () => {
612
+ await expect(`
613
+ ##! experimental { sql_functions }
614
+ source: a0 is ${databaseName}.table('malloytest.aircraft_models')
615
+ source: a is ${databaseName}.table('malloytest.aircraft_models') extend {
616
+ where: aircraft_model_code ? '0270202'
617
+ join_one: a0 on aircraft_model_code = a0.aircraft_model_code
618
+ }
618
619
 
619
- run: a -> {
620
- group_by: number_1 is sql_number("\${a.seats} * \${a.seats} + \${a.total_seats}")
621
- }
622
- `
623
- );
624
- await expect(query.run()).rejects.toThrow(
625
- "'.' paths are not yet supported in sql interpolations, found (${a.seats}, ${a.seats}, ${a.total_seats})"
626
- );
620
+ run: a -> {
621
+ group_by: number_1 is sql_number("\${seats} + \${a0.seats}")
622
+ }
623
+ `).malloyResultMatches(expressionModel, {
624
+ number_1: 58,
627
625
  });
626
+ });
628
627
 
629
- it('${view_name.SQL_TABLE_NAME}', async () => {
628
+ describe('[not yet supported]', () => {
629
+ // See ${...} documentation for lookml here for guidance on remaining work:
630
+ // https://cloud.google.com/looker/docs/reference/param-field-sql#sql_for_dimensions
631
+ it('${SQL_TABLE_NAME}', async () => {
630
632
  const query = await expressionModel.loadQuery(
631
633
  `
632
634
  ##! experimental { sql_functions }
633
- source: a is ${databaseName}.table('malloytest.aircraft_models') extend { where: aircraft_model_code ? '0270202' }
635
+ source: a0 is ${databaseName}.table('malloytest.aircraft_models')
636
+ source: a is ${databaseName}.table('malloytest.aircraft_models') extend {
637
+ where: aircraft_model_code ? '0270202'
638
+ join_one: a0 on aircraft_model_code = a0.aircraft_model_code
639
+ }
634
640
 
635
641
  run: a -> {
636
- group_by: number_1 is sql_number("\${a.SQL_TABLE_NAME}.seats")
637
- }
642
+ group_by: number_1 is sql_number("\${a0.SQL_TABLE_NAME}.seats")
643
+ }
638
644
  `
639
645
  );
640
646
  await expect(query.run()).rejects.toThrow(
641
- "'.' paths are not yet supported in sql interpolations, found ${a.SQL_TABLE_NAME}"
647
+ "Invalid interpolation: 'SQL_TABLE_NAME' is not defined"
642
648
  );
643
649
  });
644
650
  });
@@ -1796,6 +1796,42 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
1796
1796
  },
1797
1797
  ]);
1798
1798
  });
1799
+ // TODO remove the need for the `##! unsafe_complex_select_query` compiler flag
1800
+ it('can be used in a select in a composite source', async () => {
1801
+ await expect(`
1802
+ ##! experimental { function_order_by partition_by composite_sources }
1803
+ ##! unsafe_complex_select_query
1804
+ source: state_facts_composite is compose(state_facts, state_facts)
1805
+ run: state_facts_composite -> {
1806
+ select: state, births, popular_name
1807
+ calculate: prev_births_by_name is lag(births) {
1808
+ partition_by: popular_name
1809
+ order_by: births desc
1810
+ }
1811
+ order_by: births desc
1812
+ limit: 3
1813
+ }
1814
+ `).malloyResultMatches(expressionModel, [
1815
+ {
1816
+ state: 'CA',
1817
+ births: 28810563,
1818
+ popular_name: 'Isabella',
1819
+ prev_births_by_name: null,
1820
+ },
1821
+ {
1822
+ state: 'NY',
1823
+ births: 23694136,
1824
+ popular_name: 'Isabella',
1825
+ prev_births_by_name: 28810563,
1826
+ },
1827
+ {
1828
+ state: 'TX',
1829
+ births: 21467359,
1830
+ popular_name: 'Isabella',
1831
+ prev_births_by_name: 23694136,
1832
+ },
1833
+ ]);
1834
+ });
1799
1835
  });
1800
1836
  });
1801
1837