Skip to content

Commit 8fa0d53

Browse files
authored
feat(cubesql): Support DATE_PART SQL push down with Databricks (#8779)
1 parent 7ac7a5b commit 8fa0d53

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,15 @@ export class DatabricksQuery extends BaseQuery {
187187
public sqlTemplates() {
188188
const templates = super.sqlTemplates();
189189
templates.functions.DATETRUNC = 'DATE_TRUNC({{ args_concat }})';
190+
templates.functions.DATEPART = 'DATE_PART({{ args_concat }})';
190191
templates.functions.BTRIM = 'TRIM({% if args[1] is defined %}{{ args[1] }} FROM {% endif %}{{ args[0] }})';
191192
templates.functions.LTRIM = 'LTRIM({{ args|reverse|join(", ") }})';
192193
templates.functions.RTRIM = 'RTRIM({{ args|reverse|join(", ") }})';
193194
templates.functions.DATEDIFF = 'DATEDIFF({{ date_part }}, DATE_TRUNC(\'{{ date_part }}\', {{ args[1] }}), DATE_TRUNC(\'{{ date_part }}\', {{ args[2] }}))';
194195
templates.functions.LEAST = 'LEAST({{ args_concat }})';
195196
templates.functions.GREATEST = 'GREATEST({{ args_concat }})';
196197
templates.expressions.timestamp_literal = 'from_utc_timestamp(\'{{ value }}\', \'UTC\')';
198+
templates.expressions.extract = 'EXTRACT({{ date_part }} FROM {{ expr }})';
197199
templates.quotes.identifiers = '`';
198200
templates.quotes.escape = '``';
199201
// TODO: Databricks has `TIMESTAMP_NTZ` with logic similar to Pg's `TIMESTAMP`

0 commit comments

Comments
 (0)