Skip to content

Commit 7aebc3a

Browse files
committed
fix(databricks-jdbc-driver): Fix extract epoch from timestamp SQL Generation
1 parent 92a4b8e commit 7aebc3a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export class DatabricksQuery extends BaseQuery {
197197
templates.functions.GREATEST = 'GREATEST({{ args_concat }})';
198198
templates.functions.TRUNC = 'CASE WHEN ({{ args[0] }}) >= 0 THEN FLOOR({{ args_concat }}) ELSE CEIL({{ args_concat }}) END';
199199
templates.expressions.timestamp_literal = 'from_utc_timestamp(\'{{ value }}\', \'UTC\')';
200-
templates.expressions.extract = 'EXTRACT({{ date_part }} FROM {{ expr }})';
200+
templates.expressions.extract = '{% if date_part|lower == "epoch" %}unix_timestamp({{ expr }}){% else %}EXTRACT({{ date_part }} FROM {{ expr }}){% endif %}';
201201
templates.expressions.interval_single_date_part = 'INTERVAL \'{{ num }}\' {{ date_part }}';
202202
templates.quotes.identifiers = '`';
203203
templates.quotes.escape = '``';

0 commit comments

Comments
 (0)