Skip to content

Commit 776879f

Browse files
committed
fix(cubesql): Fix TRUNC SQL push down for Databricks
1 parent c9bd438 commit 776879f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ export class DatabricksQuery extends BaseQuery {
194194
templates.functions.DATEDIFF = 'DATEDIFF({{ date_part }}, DATE_TRUNC(\'{{ date_part }}\', {{ args[1] }}), DATE_TRUNC(\'{{ date_part }}\', {{ args[2] }}))';
195195
templates.functions.LEAST = 'LEAST({{ args_concat }})';
196196
templates.functions.GREATEST = 'GREATEST({{ args_concat }})';
197+
templates.functions.TRUNC = 'CASE WHEN ({{ args[0] }}) >= 0 THEN FLOOR({{ args_concat }}) ELSE CEIL({{ args_concat }}) END';
197198
templates.expressions.timestamp_literal = 'from_utc_timestamp(\'{{ value }}\', \'UTC\')';
198199
templates.expressions.extract = 'EXTRACT({{ date_part }} FROM {{ expr }})';
199200
templates.quotes.identifiers = '`';

0 commit comments

Comments
 (0)