@malloydata/malloy-tests 0.0.322 → 0.0.323

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.322",
25
- "@malloydata/db-duckdb": "0.0.322",
26
- "@malloydata/db-postgres": "0.0.322",
27
- "@malloydata/db-snowflake": "0.0.322",
28
- "@malloydata/db-trino": "0.0.322",
29
- "@malloydata/malloy": "0.0.322",
30
- "@malloydata/malloy-tag": "0.0.322",
31
- "@malloydata/render": "0.0.322",
24
+ "@malloydata/db-bigquery": "0.0.323",
25
+ "@malloydata/db-duckdb": "0.0.323",
26
+ "@malloydata/db-postgres": "0.0.323",
27
+ "@malloydata/db-snowflake": "0.0.323",
28
+ "@malloydata/db-trino": "0.0.323",
29
+ "@malloydata/malloy": "0.0.323",
30
+ "@malloydata/malloy-tag": "0.0.323",
31
+ "@malloydata/render": "0.0.323",
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.322"
41
+ "version": "0.0.323"
42
42
  }
@@ -1091,6 +1091,25 @@ describe.each(runtimes.runtimeList)('filter expressions %s', (dbName, db) => {
1091
1091
  }
1092
1092
  `).malloyResultMatches(exactTimeModel, {n: 'exact'});
1093
1093
  });
1094
+ test.when(tzTesting)(
1095
+ 'month offsets cross DST boundary in query time zone',
1096
+ async () => {
1097
+ // November 15, 2024 - Dublin is UTC+0 (no DST)
1098
+ nowIs('2024-11-15 12:00:00', 'Europe/Dublin');
1099
+
1100
+ // 2 months ago = September 2024 - Dublin is UTC+1 (DST)
1101
+ // The month arithmetic must happen in Dublin civil time
1102
+ // September 1 00:00:00 Dublin = August 31 23:00:00 UTC (due to DST offset)
1103
+ // October 1 00:00:00 Dublin = September 30 23:00:00 UTC
1104
+ const rangeQuery = mkRangeQuery(
1105
+ "f'2 months ago'",
1106
+ '2024-09-01 00:00:00', // Interpreted as Dublin time
1107
+ '2024-10-01 00:00:00', // Interpreted as Dublin time
1108
+ 'Europe/Dublin'
1109
+ );
1110
+ await expect(rangeQuery).malloyResultMatches(db, inRange);
1111
+ }
1112
+ );
1094
1113
  });
1095
1114
  });
1096
1115
  });
@@ -814,6 +814,37 @@ describe.each(runtimes.runtimeList)('%s: query tz', (dbName, runtime) => {
814
814
  expect(yekTimezoneAnnotation?.value).toContain('Asia/Yekaterinburg');
815
815
  }
816
816
  );
817
+
818
+ test('intervals are evalutated in query timezone', async () => {
819
+ const truth = runtime.dialect.resultBoolean(true);
820
+ await expect(
821
+ `source: onerow is ${dbName}.sql("SELECT 1 as rownum") extend {
822
+ dimension:
823
+ // Dublin is UTC+1 in June and UTC in November
824
+ november is @2024-11-01 00:00:00[Europe/Dublin]
825
+ june1_correct is @2024-06-01 00:00:00[Europe/Dublin],
826
+ august1_correct is @2024-08-01 00:00:00[Europe/Dublin],
827
+ by_month is november - 5 months,
828
+ by_day is november - 153 days,
829
+ by_hour is november - 3673 hours, // 153 days * 24 hours + 1 hour fall back
830
+ by_quarter is november - 1 quarter, // 3 months back crosses DST boundary
831
+ }
832
+ run: onerow -> {
833
+ timezone: 'Europe/Dublin'
834
+ select:
835
+ june1_correct,
836
+ month_ok is by_month = june1_correct, by_month
837
+ day_ok is by_day = june1_correct, by_day
838
+ hour_ok is by_hour = june1_correct, by_hour
839
+ quarter_ok is by_quarter = august1_correct, by_quarter
840
+ }`
841
+ ).malloyResultMatches(runtime, {
842
+ month_ok: truth,
843
+ day_ok: truth,
844
+ hour_ok: truth,
845
+ quarter_ok: truth,
846
+ });
847
+ });
817
848
  });
818
849
 
819
850
  afterAll(async () => {
@@ -42,10 +42,11 @@ describe('BigQuery double truncation', () => {
42
42
  }
43
43
  `;
44
44
  const result = await runtime.loadQuery(src).run();
45
- const truncs = (result.sql.match(/TIMESTAMP_TRUNC/gi) || []).length;
46
- if (truncs !== 1) {
47
- fail(`Expected 1 TIMESTAMP_TRUNC, got ${truncs}\n${result.sql}`);
48
- }
45
+ // Check for either TIMESTAMP_TRUNC or DATETIME_TRUNC (civil time path)
46
+ const truncs = (
47
+ result.sql.match(/(TIMESTAMP_TRUNC|DATETIME_TRUNC)/gi) || []
48
+ ).length;
49
+ expect(truncs).toBe(1);
49
50
  }
50
51
  });
51
52
  });
@@ -20,7 +20,7 @@ bigquery.arrow-serialization.enabled=false
20
20
  EOF
21
21
 
22
22
  # run docker
23
- docker run -p ${TRINO_PORT:-8080}:8080 -d -v ./.tmp/bigquery-trino.properties:/etc/trino/catalog/bigquery.properties --name trino-malloy trinodb/trino
23
+ docker run -p ${TRINO_PORT:-8080}:8080 -d -e TZ=UTC -v ./.tmp/bigquery-trino.properties:/etc/trino/catalog/bigquery.properties --name trino-malloy trinodb/trino
24
24
 
25
25
  # wait for server to start
26
26
  counter=0