Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(schema-compiler): fix time dimension granularity origin formatting in local timezone #9071

Merged
merged 4 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -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
KSDaemon marked this conversation as resolved.
Show resolved Hide resolved
- [ ] 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
10 changes: 6 additions & 4 deletions packages/cubejs-testing-drivers/fixtures/_schemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Loading