Skip to content

Commit 60884fb

Browse files
committed
fix templates.statements.generated_time_series_select
1 parent dd81ce7 commit 60884fb

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

packages/cubejs-databricks-jdbc-driver/src/DatabricksQuery.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,19 @@ export class DatabricksQuery extends BaseQuery {
179179
templates.quotes.identifiers = '`';
180180
templates.quotes.escape = '``';
181181
templates.statements.time_series_select = 'SELECT date_from::timestamp AS `date_from`,\n' +
182-
'date_to::timestamp AS `date_to` \n' +
183-
'FROM(\n' +
184-
' VALUES ' +
185-
'{% for time_item in seria %}' +
186-
'(\'{{ time_item | join(\'\\\', \\\'\') }}\')' +
187-
'{% if not loop.last %}, {% endif %}' +
188-
'{% endfor %}' +
189-
') AS dates (date_from, date_to)';
182+
'date_to::timestamp AS `date_to` \n' +
183+
'FROM(\n' +
184+
' VALUES ' +
185+
'{% for time_item in seria %}' +
186+
'(\'{{ time_item | join(\'\\\', \\\'\') }}\')' +
187+
'{% if not loop.last %}, {% endif %}' +
188+
'{% endfor %}' +
189+
') AS dates (date_from, date_to)';
190+
templates.statements.generated_time_series_select = 'SELECT d AS date_from,\n' +
191+
'(d + INTERVAL {{ granularity }}) - INTERVAL 1 MILLISECOND AS date_to\n' +
192+
' FROM (SELECT explode(sequence(\n' +
193+
' from_utc_timestamp({{ start }}, \'UTC\'), from_utc_timestamp({{ end }}, \'UTC\'), INTERVAL {{ granularity }}\n' +
194+
' )) AS d)';
190195

191196
// TODO: Databricks has `TIMESTAMP_NTZ` with logic similar to Pg's `TIMESTAMP`
192197
// but that requires Runtime 13.3+. Should this be enabled?

0 commit comments

Comments
 (0)