@malloydata/malloy-tests 0.0.142-dev240411154213 → 0.0.142-dev240413014741

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.142-dev240411154213",
25
- "@malloydata/db-duckdb": "^0.0.142-dev240411154213",
26
- "@malloydata/db-postgres": "^0.0.142-dev240411154213",
27
- "@malloydata/db-snowflake": "^0.0.142-dev240411154213",
28
- "@malloydata/db-trino": "^0.0.142-dev240411154213",
29
- "@malloydata/malloy": "^0.0.142-dev240411154213",
30
- "@malloydata/render": "^0.0.142-dev240411154213",
24
+ "@malloydata/db-bigquery": "^0.0.142-dev240413014741",
25
+ "@malloydata/db-duckdb": "^0.0.142-dev240413014741",
26
+ "@malloydata/db-postgres": "^0.0.142-dev240413014741",
27
+ "@malloydata/db-snowflake": "^0.0.142-dev240413014741",
28
+ "@malloydata/db-trino": "^0.0.142-dev240413014741",
29
+ "@malloydata/malloy": "^0.0.142-dev240413014741",
30
+ "@malloydata/render": "^0.0.142-dev240413014741",
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.142-dev240411154213"
39
+ "version": "0.0.142-dev240413014741"
40
40
  }
@@ -34,35 +34,38 @@ afterAll(async () => {
34
34
  });
35
35
 
36
36
  runtimes.runtimeMap.forEach((runtime, databaseName) => {
37
- it(`basic index - ${databaseName}`, async () => {
38
- const model = await runtime.loadModel(
39
- `
37
+ test.when(runtime.dialect.supportsTempTables)(
38
+ `basic index - ${databaseName}`,
39
+ async () => {
40
+ const model = await runtime.loadModel(
41
+ `
40
42
  source: airports is ${databaseName}.table('malloytest.airports') extend {
41
43
  }
42
44
  `
43
- );
44
- let result = await model.search('airports', 'SANTA', 10);
45
+ );
46
+ let result = await model.search('airports', 'SANTA', 10);
45
47
 
46
- // if (result !== undefined) {
47
- // console.log(result);
48
- // } else {
49
- // console.log("no result");
50
- // }
51
- expect(result).toBeDefined();
52
- if (result !== undefined) {
53
- expect(result[0].fieldName).toBe('county');
54
- expect(result[0].fieldValue).toBe('SANTA ROSA');
55
- expect(result[0].weight).toBe(26);
56
- expect(result.length).toBe(10);
57
- }
48
+ // if (result !== undefined) {
49
+ // console.log(result);
50
+ // } else {
51
+ // console.log("no result");
52
+ // }
53
+ expect(result).toBeDefined();
54
+ if (result !== undefined) {
55
+ expect(result[0].fieldName).toBe('county');
56
+ expect(result[0].fieldValue).toBe('SANTA ROSA');
57
+ expect(result[0].weight).toBe(26);
58
+ expect(result.length).toBe(10);
59
+ }
58
60
 
59
- result = await model.search('airports', 'SANTA A', 100, 'city');
60
- if (result !== undefined) {
61
- // console.log(result);
62
- expect(result[0].fieldName).toBe('city');
63
- expect(result[0].fieldValue).toBe('SANTA ANA');
61
+ result = await model.search('airports', 'SANTA A', 100, 'city');
62
+ if (result !== undefined) {
63
+ // console.log(result);
64
+ expect(result[0].fieldName).toBe('city');
65
+ expect(result[0].fieldValue).toBe('SANTA ANA');
66
+ }
64
67
  }
65
- });
68
+ );
66
69
 
67
70
  it(`index value map - ${databaseName}`, async () => {
68
71
  const model = await runtime.loadModel(
@@ -94,7 +97,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
94
97
  });
95
98
 
96
99
  // bigquery doesn't support row count based sampling.
97
- test.when(databaseName !== 'bigquery')(
100
+ test.when(databaseName !== 'bigquery' && databaseName !== 'trino')(
98
101
  `index rows count - ${databaseName}`,
99
102
  async () => {
100
103
  await expect(`
@@ -661,8 +661,10 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
661
661
  });
662
662
  });
663
663
 
664
- it('joined filtered explores with dependencies', async () => {
665
- await expect(`
664
+ test.when(runtime.dialect.supportsComplexFilteredSources)(
665
+ 'joined filtered explores with dependencies',
666
+ async () => {
667
+ await expect(`
666
668
  source: bo_models is
667
669
  ${databaseName}.table('malloytest.aircraft_models') extend { where: manufacturer ? ~ 'BO%' }
668
670
  -> { select: aircraft_model_code, manufacturer, seats }
@@ -691,7 +693,8 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
691
693
  -- aggregate: b_models.bo_models.bo_count
692
694
  }
693
695
  `).malloyResultMatches(runtime, {model_count: 60461, b_count: 355});
694
- });
696
+ }
697
+ );
695
698
  });
696
699
 
697
700
  describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
@@ -756,9 +756,12 @@ expressionModels.forEach((expressionModel, databaseName) => {
756
756
  });
757
757
  });
758
758
  describe('is_inf', () => {
759
+ const inf = ['trino'].includes(databaseName)
760
+ ? 'infinity!()'
761
+ : "'+inf'::number";
759
762
  it(`works - ${databaseName}`, async () => {
760
763
  await funcTestMultiple(
761
- ["is_inf('+inf'::number)", true],
764
+ [`is_inf(${inf})`, true],
762
765
  ['is_inf(100)', false],
763
766
  ['is_inf(null)', false]
764
767
  );
@@ -952,7 +955,7 @@ expressionModels.forEach((expressionModel, databaseName) => {
952
955
  await funcTestMultiple(
953
956
  ["ascii('A')", 65],
954
957
  ["ascii('ABC')", 65],
955
- ["ascii('')", 0],
958
+ //["ascii('')", 0], // I don't think we can guarentee this Trino returns null
956
959
  ['ascii(null)', null]
957
960
  );
958
961
  });
@@ -963,7 +966,7 @@ expressionModels.forEach((expressionModel, databaseName) => {
963
966
  ["unicode('A')", 65],
964
967
  ["unicode('â')", 226],
965
968
  ["unicode('âBC')", 226],
966
- ["unicode('')", 0],
969
+ //["unicode('')", 0], // I don't think we can guarentee this Trino returns null
967
970
  ['unicode(null)', null]
968
971
  );
969
972
  });
@@ -1294,7 +1297,7 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
1294
1297
 
1295
1298
  it(`works with fanout and order_by - ${databaseName}`, async () => {
1296
1299
  // TODO bigquery cannot handle both fanout and order_by today
1297
- if (['bigquery', 'snowflake'].includes(databaseName)) return;
1300
+ if (['bigquery', 'snowflake', 'trino'].includes(databaseName)) return;
1298
1301
  await expect(`##! experimental.aggregate_order_by
1299
1302
  run: state_facts extend { join_many:
1300
1303
  state_facts2 is ${databaseName}.table('malloytest.state_facts')
@@ -905,8 +905,14 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
905
905
  `).malloyResultMatches(runtime, {a: 1});
906
906
  });
907
907
 
908
+ // have to add an order_by: otherwise it isn't deterministic.
908
909
  it(`sql directly - ${databaseName}`, async () => {
909
- await expect(`run: ${sql1234}`).malloyResultMatches(runtime, {a: 1});
910
+ await expect(
911
+ `run: ${sql1234}->{
912
+ select: *
913
+ order_by: a asc
914
+ }`
915
+ ).malloyResultMatches(runtime, {a: 1});
910
916
  });
911
917
 
912
918
  it(`sql with turducken- ${databaseName}`, async () => {
@@ -988,6 +994,7 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
988
994
  """) -> {
989
995
  extend: {dimension: c is b + 4}
990
996
  select: x is a * c
997
+ order_by: x desc
991
998
  }
992
999
  `).malloyResultMatches(runtime, {x: 30});
993
1000
  });
@@ -1053,6 +1060,20 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
1053
1060
  }
1054
1061
  );
1055
1062
 
1063
+ test.when(runtime.supportsNesting && runtime.dialect.readsNestedData)(
1064
+ `can double unnest - ${databaseName}`,
1065
+ async () => {
1066
+ await expect(`
1067
+ source: ga_sample is ${databaseName}.table('malloytest.ga_sample')
1068
+
1069
+ run: ga_sample -> {
1070
+ aggregate:
1071
+ p is floor(hits.product.productPrice.avg())
1072
+ }
1073
+ `).malloyResultMatches(runtime, {p: 23001594});
1074
+ }
1075
+ );
1076
+
1056
1077
  test.when(runtime.supportsNesting)(
1057
1078
  'nest null - ${databaseName}',
1058
1079
  async () => {