Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
RusovDmitriy committed Oct 26, 2024
1 parent a621b70 commit 1dfe551
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/cubejs-backend-shared/src/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const TIME_SERIES: Record<string, (range: DateRange, timestampPrecision:
.map(d => [d.format(`YYYY-MM-DDTHH:mm:00.${'0'.repeat(digits)}`), d.format(`YYYY-MM-DDTHH:mm:59.${'9'.repeat(digits)}`)]),
second: (range: DateRange, digits) => Array.from(range.snapTo('second').by('second'))
.map(d => [d.format(`YYYY-MM-DDTHH:mm:ss.${'0'.repeat(digits)}`), d.format(`YYYY-MM-DDTHH:mm:ss.${'9'.repeat(digits)}`)]),
millisecond: (range: DateRange, digits) => Array.from(range.snapTo('millisecond').by('millisecond'))
.map(d => [d.format(`YYYY-MM-DDTHH:mm:ss.SSS${'0'.repeat(Math.max(digits - 3, 0))}`), d.format(`YYYY-MM-DDTHH:mm:ss.SSS${'9'.repeat(Math.max(digits - 3, 0))}`)]),
week: (range: DateRange, digits) => Array.from(range.snapTo(<unitOfTime.Diff>'isoWeek').by('week'))
.map(d => [d.startOf('isoWeek').format(`YYYY-MM-DDT00:00:00.${'0'.repeat(digits)}`), d.endOf('isoWeek').format(`YYYY-MM-DDT23:59:59.${'9'.repeat(digits)}`)]),
quarter: (range: DateRange, digits) => Array.from(range.snapTo('quarter').by('quarter'))
Expand Down
1 change: 1 addition & 0 deletions packages/cubejs-ksql-driver/src/KsqlQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const GRANULARITY_TO_INTERVAL = {
hour: (date: string) => `FORMAT_TIMESTAMP(${date}, 'yyyy-MM-dd''T''HH:00:00.000')`,
minute: (date: string) => `FORMAT_TIMESTAMP(${date}, 'yyyy-MM-dd''T''HH:mm:00.000')`,
second: (date: string) => `FORMAT_TIMESTAMP(${date}, 'yyyy-MM-dd''T''HH:mm:ss.000')`,
millisecond: (date: string) => `FORMAT_TIMESTAMP(${date}, 'yyyy-MM-dd''T''HH:mm:ss.SSS')`,
month: (date: string) => `FORMAT_TIMESTAMP(${date}, 'yyyy-MM-01''T''00:00:00.000')`,
quarter: (date: string) => `FORMAT_TIMESTAMP(PARSE_TIMESTAMP(FORMAT_TIMESTAMP(${date}, 'YYYY-qq'), 'YYYY-qq'), 'yyyy-MM-dd''T''00:00:00.000')`,
year: (date: string) => `FORMAT_TIMESTAMP(${date}, 'yyyy-01-01''T''00:00:00.000')`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const GRANULARITY_TO_INTERVAL = {
hour: 'hour',
minute: 'minute',
second: 'second',
millisecond: 'millisecond',
month: 'month',
quarter: 'quarter',
year: 'year'
Expand Down

0 comments on commit 1dfe551

Please sign in to comment.