@malloydata/malloy-tests 0.0.149-dev240704171255 → 0.0.149

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.149-dev240704171255",
25
- "@malloydata/db-duckdb": "^0.0.149-dev240704171255",
26
- "@malloydata/db-postgres": "^0.0.149-dev240704171255",
27
- "@malloydata/db-snowflake": "^0.0.149-dev240704171255",
28
- "@malloydata/db-trino": "^0.0.149-dev240704171255",
29
- "@malloydata/malloy": "^0.0.149-dev240704171255",
30
- "@malloydata/render": "^0.0.149-dev240704171255",
24
+ "@malloydata/db-bigquery": "^0.0.149",
25
+ "@malloydata/db-duckdb": "^0.0.149",
26
+ "@malloydata/db-postgres": "^0.0.149",
27
+ "@malloydata/db-snowflake": "^0.0.149",
28
+ "@malloydata/db-trino": "^0.0.149",
29
+ "@malloydata/malloy": "^0.0.149",
30
+ "@malloydata/render": "^0.0.149",
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.149-dev240704171255"
39
+ "version": "0.0.149"
40
40
  }
@@ -52,6 +52,8 @@ function getSplitFunction(db: string) {
52
52
  `split(${column}, '${splitChar}')`,
53
53
  'trino': (column: string, splitChar: string) =>
54
54
  `split(${column}, '${splitChar}')`,
55
+ 'presto': (column: string, splitChar: string) =>
56
+ `split(${column}, '${splitChar}')`,
55
57
  }[db];
56
58
  }
57
59
 
@@ -548,6 +550,17 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
548
550
  }
549
551
  );
550
552
 
553
+ it(`sql block- ${databaseName}`, async () => {
554
+ await expect(`
555
+ source: one is ${databaseName}.sql("""
556
+ SELECT 2 as ${q`a`}
557
+ """)
558
+ run: one -> {
559
+ select: a
560
+ }`).malloyResultMatches(runtime, {a: 2});
561
+ });
562
+
563
+
551
564
  // average should only include non-null values in the denominator
552
565
  it(`avg ignore null- ${databaseName}`, async () => {
553
566
  await expect(`
@@ -628,6 +641,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
628
641
  'ungrouped nested with no grouping above - ${databaseName}',
629
642
  async () => {
630
643
  await expect(`
644
+ // # test.debug
631
645
  run: ${databaseName}.table('malloytest.state_facts') extend {
632
646
  measure: total_births is births.sum()
633
647
  measure: births_per_100k is floor(total_births/ all(total_births) * 100000)
package/src/runtimes.ts CHANGED
@@ -37,6 +37,7 @@ import {SnowflakeConnection} from '@malloydata/db-snowflake';
37
37
  import {PooledPostgresConnection} from '@malloydata/db-postgres';
38
38
  import {TrinoConnection, TrinoExecutor} from '@malloydata/db-trino';
39
39
  import {SnowflakeExecutor} from '@malloydata/db-snowflake/src/snowflake_executor';
40
+ import {PrestoConnection} from '@malloydata/db-trino/src/trino_connection';
40
41
 
41
42
  export class SnowflakeTestConnection extends SnowflakeConnection {
42
43
  public async runSQL(
@@ -166,7 +167,14 @@ export function runtimeFor(dbName: string): SingleConnectionRuntime {
166
167
  connection = new TrinoConnection(
167
168
  dbName,
168
169
  {},
169
- TrinoExecutor.getConnectionOptionsFromEnv()
170
+ TrinoExecutor.getConnectionOptionsFromEnv(dbName)
171
+ );
172
+ break;
173
+ case 'presto':
174
+ connection = new PrestoConnection(
175
+ dbName,
176
+ {},
177
+ TrinoExecutor.getConnectionOptionsFromEnv(dbName) // they share configs.
170
178
  );
171
179
  break;
172
180
  default:
@@ -0,0 +1,34 @@
1
+ #! /bin/bash
2
+ rm -rf .tmp
3
+ mkdir .tmp
4
+
5
+ # generate config file
6
+ > ./.tmp/bigquery.properties
7
+ cat << EOF > ./.tmp/bigquery.properties
8
+ connector.name=bigquery
9
+ bigquery.project-id=advance-lacing-417917
10
+ bigquery.credentials-key=$BQ_CREDENTIALS_KEY
11
+ bigquery.arrow-serialization.enabled=false
12
+ EOF
13
+
14
+ # run docker
15
+ docker run -p 8080:8080 -d -v ./.tmp/bigquery.properties:/etc/trino/catalog/bigquery.properties --name trino-malloy trinodb/trino
16
+
17
+ # wait for server to start
18
+ counter=0
19
+ while ! docker logs trino-malloy 2>&1 | grep -q "SERVER STARTED"
20
+ do
21
+ sleep 1
22
+ counter=$((counter+1))
23
+ # if doesn't start after 2 minutes, output logs and kill process
24
+ if [ $counter -eq 300 ]
25
+ then
26
+ docker logs trino-malloy >& ./.tmp/trino-malloy.logs
27
+ docker rm -f trino-malloy
28
+ echo "Trino did not start successfully, check .tmp/trino-malloy.logs"
29
+ exit 1
30
+ break
31
+ fi
32
+ done
33
+
34
+ echo "Trino running on port localhost:8080"
@@ -0,0 +1,7 @@
1
+ #! /bin/bash
2
+
3
+ # clear tmp files
4
+ rm -rf .tmp
5
+
6
+ # stop container
7
+ docker rm -f trino-malloy