Skip to content

Commit

Permalink
feat(cubesql): Support DATE_PART SQL push down with Databricks (#8779)
Browse files Browse the repository at this point in the history
  • Loading branch information
MazterQyou authored Oct 4, 2024
1 parent 7ac7a5b commit 8fa0d53
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/cubejs-databricks-jdbc-driver/src/DatabricksQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,15 @@ export class DatabricksQuery extends BaseQuery {
public sqlTemplates() {
const templates = super.sqlTemplates();
templates.functions.DATETRUNC = 'DATE_TRUNC({{ args_concat }})';
templates.functions.DATEPART = 'DATE_PART({{ args_concat }})';
templates.functions.BTRIM = 'TRIM({% if args[1] is defined %}{{ args[1] }} FROM {% endif %}{{ args[0] }})';
templates.functions.LTRIM = 'LTRIM({{ args|reverse|join(", ") }})';
templates.functions.RTRIM = 'RTRIM({{ args|reverse|join(", ") }})';
templates.functions.DATEDIFF = 'DATEDIFF({{ date_part }}, DATE_TRUNC(\'{{ date_part }}\', {{ args[1] }}), DATE_TRUNC(\'{{ date_part }}\', {{ args[2] }}))';
templates.functions.LEAST = 'LEAST({{ args_concat }})';
templates.functions.GREATEST = 'GREATEST({{ args_concat }})';
templates.expressions.timestamp_literal = 'from_utc_timestamp(\'{{ value }}\', \'UTC\')';
templates.expressions.extract = 'EXTRACT({{ date_part }} FROM {{ expr }})';
templates.quotes.identifiers = '`';
templates.quotes.escape = '``';
// TODO: Databricks has `TIMESTAMP_NTZ` with logic similar to Pg's `TIMESTAMP`
Expand Down

0 comments on commit 8fa0d53

Please sign in to comment.