@malloydata/malloy-tests 0.0.311 → 0.0.312

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.311",
25
- "@malloydata/db-duckdb": "0.0.311",
26
- "@malloydata/db-postgres": "0.0.311",
27
- "@malloydata/db-snowflake": "0.0.311",
28
- "@malloydata/db-trino": "0.0.311",
29
- "@malloydata/malloy": "0.0.311",
30
- "@malloydata/malloy-tag": "0.0.311",
31
- "@malloydata/render": "0.0.311",
24
+ "@malloydata/db-bigquery": "0.0.312",
25
+ "@malloydata/db-duckdb": "0.0.312",
26
+ "@malloydata/db-postgres": "0.0.312",
27
+ "@malloydata/db-snowflake": "0.0.312",
28
+ "@malloydata/db-trino": "0.0.312",
29
+ "@malloydata/malloy": "0.0.312",
30
+ "@malloydata/malloy-tag": "0.0.312",
31
+ "@malloydata/render": "0.0.312",
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.311"
41
+ "version": "0.0.312"
42
42
  }
@@ -18,4 +18,36 @@ describe('misc tests for regressions that have no better home', () => {
18
18
  } -> { group_by: carriers.airline; limit: 1 }
19
19
  `).malloyResultMatches(runtime, [{}]);
20
20
  });
21
+
22
+ test('result data structure contains time zones for nested queries', async () => {
23
+ const query = runtime.loadQuery(`
24
+ run: duckdb.table('malloytest.flights') -> {
25
+ nest: arrive_yekaterinburg is {
26
+ timezone: 'Asia/Yekaterinburg'
27
+ group_by: utc_time is arr_time::string, civil_time is arr_time
28
+ limit: 5
29
+ }
30
+ }
31
+ `);
32
+ const result = await query.run();
33
+
34
+ // Inspect the result schema to find timezone metadata
35
+ const schema = result.resultExplore;
36
+
37
+ // Find the nested field
38
+ const nestedField = schema.getFieldByName('arrive_yekaterinburg');
39
+ expect(nestedField).toBeDefined();
40
+
41
+ if (nestedField?.isExploreField()) {
42
+ // Check if timezone information is present in the result data structure
43
+ const queryTimezone = nestedField.queryTimezone;
44
+
45
+ // Verify timezone is accessible in the result structure
46
+ expect(queryTimezone).toBe('Asia/Yekaterinburg');
47
+
48
+ // The timezone info should be available for later serialization
49
+ // (this is what gets turned into annotations during the to-stable process)
50
+ expect(nestedField.queryTimezone).toBeDefined();
51
+ }
52
+ });
21
53
  });
@@ -31,6 +31,7 @@ import {
31
31
  runQuery,
32
32
  } from '../../util';
33
33
  import {DateTime as LuxonDateTime} from 'luxon';
34
+ import {API} from '@malloydata/malloy';
34
35
 
35
36
  const runtimes = new RuntimeList(databasesFromEnvironmentOr(allDatabases));
36
37
 
@@ -736,6 +737,67 @@ describe.each(runtimes.runtimeList)('%s: query tz', (dbName, runtime) => {
736
737
  }`
737
738
  ).malloyResultMatches(runtime, {mex_ts: zone_2020.toJSDate()});
738
739
  });
740
+
741
+ // Test for timezone rendering issue with nested queries
742
+ test.when(runtime.supportsNesting)(
743
+ 'nested queries preserve timezone in rendering',
744
+ async () => {
745
+ const result = await runQuery(
746
+ runtime,
747
+ `run: ${dbName}.table('malloytest.flights') extend {
748
+ view: arrivals is {
749
+ group_by: arr_time.hour
750
+ order_by: arr_time desc
751
+ limit: 1
752
+ }
753
+ } -> {
754
+ nest: arrive_utc is arrivals
755
+ nest: arrive_yekaterinburg is arrivals + { timezone: 'Asia/Yekaterinburg' }
756
+ }`
757
+ );
758
+
759
+ // First, check that the raw result has the correct timezone metadata
760
+ const rawFields = result.resultExplore.structDef.fields;
761
+ const rawArriveUtc = rawFields.find(f => f.name === 'arrive_utc');
762
+ const rawArriveYek = rawFields.find(
763
+ f => f.name === 'arrive_yekaterinburg'
764
+ );
765
+
766
+ expect(rawArriveUtc).toBeDefined();
767
+ expect(rawArriveYek).toBeDefined();
768
+
769
+ // Check timezone properties on raw array/record fields
770
+ expect(rawArriveUtc!['queryTimezone']).toBeUndefined(); // Should be undefined for UTC
771
+ expect(rawArriveYek!['queryTimezone']).toBe('Asia/Yekaterinburg');
772
+
773
+ // Now check that the wrapped result also preserves timezone metadata
774
+ const wrappedResult = API.util.wrapResult(result);
775
+ const wrappedFields = wrappedResult.schema.fields;
776
+ const wrappedArriveUtc = wrappedFields.find(f => f.name === 'arrive_utc');
777
+ const wrappedArriveYek = wrappedFields.find(
778
+ f => f.name === 'arrive_yekaterinburg'
779
+ );
780
+
781
+ expect(wrappedArriveUtc).toBeDefined();
782
+ expect(wrappedArriveYek).toBeDefined();
783
+
784
+ // Check timezone properties in the wrapped result
785
+ // For nested views, the timezone should be in the annotations
786
+ const arriveUtcAnnotations = wrappedArriveUtc?.annotations;
787
+ const arriveYekAnnotations = wrappedArriveYek?.annotations;
788
+
789
+ // Check if timezone info is present in annotations
790
+ const utcTimezoneAnnotation = arriveUtcAnnotations?.find(ann =>
791
+ ann.value.includes('query_timezone')
792
+ );
793
+ const yekTimezoneAnnotation = arriveYekAnnotations?.find(ann =>
794
+ ann.value.includes('query_timezone')
795
+ );
796
+
797
+ expect(utcTimezoneAnnotation).toBeUndefined(); // UTC should have no timezone annotation
798
+ expect(yekTimezoneAnnotation?.value).toContain('Asia/Yekaterinburg');
799
+ }
800
+ );
739
801
  });
740
802
 
741
803
  afterAll(async () => {