From 1ae0034074391fb91b406e955516677ab663be3c Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Mon, 6 Jan 2025 18:30:27 +0200 Subject: [PATCH 1/4] fix integration custom granularities tests --- .../test/integration/clickhouse/custom-granularities.test.ts | 4 +++- .../test/integration/mssql/custom-granularities.test.ts | 4 +++- .../test/integration/mysql/custom-granularities.test.ts | 4 +++- .../test/integration/postgres/custom-granularities.test.ts | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/cubejs-schema-compiler/test/integration/clickhouse/custom-granularities.test.ts b/packages/cubejs-schema-compiler/test/integration/clickhouse/custom-granularities.test.ts index 966ba6846e6e4..2d8a1665d66b6 100644 --- a/packages/cubejs-schema-compiler/test/integration/clickhouse/custom-granularities.test.ts +++ b/packages/cubejs-schema-compiler/test/integration/clickhouse/custom-granularities.test.ts @@ -41,9 +41,11 @@ describe('Custom Granularities', () => { granularities: - name: half_year interval: 6 months + origin: '2024-01-01' # to keep tests stable across time (year change, etc) - name: half_year_by_1st_april interval: 6 months - offset: 3 months + #offset: 3 months + origin: '2024-04-01' # to keep tests stable across time (year change, etc) - name: two_weeks_by_friday interval: 2 weeks origin: '2024-08-23' diff --git a/packages/cubejs-schema-compiler/test/integration/mssql/custom-granularities.test.ts b/packages/cubejs-schema-compiler/test/integration/mssql/custom-granularities.test.ts index 762e88230af76..922b37e48b80a 100644 --- a/packages/cubejs-schema-compiler/test/integration/mssql/custom-granularities.test.ts +++ b/packages/cubejs-schema-compiler/test/integration/mssql/custom-granularities.test.ts @@ -37,9 +37,11 @@ describe('Custom Granularities', () => { granularities: - name: half_year interval: 6 months + origin: '2024-01-01' # to keep tests stable across time (year change, etc) - name: half_year_by_1st_april interval: 6 months - offset: 3 months + #offset: 3 months + origin: '2024-04-01' # to keep tests stable across time (year change, etc) - name: two_weeks_by_friday interval: 2 weeks origin: '2024-08-23' diff --git a/packages/cubejs-schema-compiler/test/integration/mysql/custom-granularities.test.ts b/packages/cubejs-schema-compiler/test/integration/mysql/custom-granularities.test.ts index a69c9a97c527e..1505442c453b0 100644 --- a/packages/cubejs-schema-compiler/test/integration/mysql/custom-granularities.test.ts +++ b/packages/cubejs-schema-compiler/test/integration/mysql/custom-granularities.test.ts @@ -37,9 +37,11 @@ describe('Custom Granularities', () => { granularities: - name: half_year interval: 6 months + origin: '2024-01-01' # to keep tests stable across time (year change, etc) - name: half_year_by_1st_april interval: 6 months - offset: 3 months + #offset: 3 months + origin: '2024-04-01' # to keep tests stable across time (year change, etc) - name: two_weeks_by_friday interval: 2 weeks origin: '2024-08-23' diff --git a/packages/cubejs-schema-compiler/test/integration/postgres/custom-granularities.test.ts b/packages/cubejs-schema-compiler/test/integration/postgres/custom-granularities.test.ts index 4d6314a9089e1..4be8f26f744b7 100644 --- a/packages/cubejs-schema-compiler/test/integration/postgres/custom-granularities.test.ts +++ b/packages/cubejs-schema-compiler/test/integration/postgres/custom-granularities.test.ts @@ -39,9 +39,11 @@ describe('Custom Granularities', () => { granularities: - name: half_year interval: 6 months + origin: '2024-01-01' # to keep tests stable across time (year change, etc) - name: half_year_by_1st_april interval: 6 months - offset: 3 months + #offset: 3 months + origin: '2024-04-01' # to keep tests stable across time (year change, etc) - name: two_weeks_by_friday interval: 2 weeks origin: '2024-08-23' From 06ac550593485b39ce5d743dffef13fcb161fdf4 Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Mon, 6 Jan 2025 21:45:20 +0200 Subject: [PATCH 2/4] =?UTF-8?q?fix=20postgres=20drivers=20tests=20related?= =?UTF-8?q?=20to=C2=A0custom=20granularities?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cubejs-testing-drivers/fixtures/_schemas.json | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/cubejs-testing-drivers/fixtures/_schemas.json b/packages/cubejs-testing-drivers/fixtures/_schemas.json index 8dd31a5d58081..5259e4e9784e4 100644 --- a/packages/cubejs-testing-drivers/fixtures/_schemas.json +++ b/packages/cubejs-testing-drivers/fixtures/_schemas.json @@ -93,12 +93,13 @@ "granularities": [ { "name": "half_year", - "interval": "6 months" + "interval": "6 months", + "origin": "2024-01-01" }, { "name": "half_year_by_1st_april", "interval": "6 months", - "offset": "3 months" + "origin": "2024-04-01" }, { "name": "two_mo_by_feb", @@ -119,12 +120,13 @@ "granularities": [ { "name": "half_year", - "interval": "6 months" + "interval": "6 months", + "origin": "2024-01-01" }, { "name": "half_year_by_1st_april", "interval": "6 months", - "offset": "3 months" + "origin": "2024-04-01" }, { "name": "two_mo_by_feb", From c928c36c0b58a0268176f34e5dfa2efd6aa95ea8 Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Mon, 6 Jan 2025 21:45:51 +0200 Subject: [PATCH 3/4] =?UTF-8?q?fix=20granularity=20origin=20formatting=20i?= =?UTF-8?q?n=C2=A0local=20timezone?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cubejs-schema-compiler/src/adapter/Granularity.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/cubejs-schema-compiler/src/adapter/Granularity.ts b/packages/cubejs-schema-compiler/src/adapter/Granularity.ts index c12028a0ea9a1..ff595a5261b3a 100644 --- a/packages/cubejs-schema-compiler/src/adapter/Granularity.ts +++ b/packages/cubejs-schema-compiler/src/adapter/Granularity.ts @@ -13,6 +13,8 @@ export class Granularity { public readonly granularityInterval: string; + public readonly queryTimezone: string; + public readonly granularityOffset: string | undefined; public readonly origin: moment.Moment; @@ -25,6 +27,7 @@ export class Granularity { ) { this.granularity = timeDimension.granularity; this.predefinedGranularity = isPredefinedGranularity(this.granularity); + this.queryTimezone = query.timezone; this.origin = moment.tz(query.timezone).startOf('year'); // Defaults to current year start if (this.predefinedGranularity) { @@ -59,7 +62,7 @@ export class Granularity { * @returns origin date string in Query timezone */ public originLocalFormatted(): string { - return this.origin.format('YYYY-MM-DDTHH:mm:ss.SSS'); + return this.origin.tz(this.queryTimezone).format('YYYY-MM-DDTHH:mm:ss.SSS'); } /** From 4462be2d1f5a8f9c1a152f4b433004e2a1b9072d Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Mon, 6 Jan 2025 21:49:03 +0200 Subject: [PATCH 4/4] fix spelling --- .github/pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index ff3368acb3db3..28310e2e146e4 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,5 +1,5 @@ **Check List** -- [ ] Tests has been run in packages where changes made if available +- [ ] Tests have been run in packages where changes made if available - [ ] Linter has been run for changed code - [ ] Tests for the changes have been added if not covered yet - [ ] Docs have been added / updated if required