Skip to content

Commit

Permalink
feat(databricks-driver): Support for intervals and CURRENT_DATE for s…
Browse files Browse the repository at this point in the history
…ql push down (#9000)

* add single intervals transformation for databricks

* add CURRENTDATE support for Databricks SQL Push down
  • Loading branch information
KSDaemon authored Nov 27, 2024
1 parent cd7490e commit f61afc3
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 @@ -186,6 +186,7 @@ export class DatabricksQuery extends BaseQuery {

public sqlTemplates() {
const templates = super.sqlTemplates();
templates.functions.CURRENTDATE = 'CURRENT_DATE';
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] }})';
Expand All @@ -197,6 +198,7 @@ export class DatabricksQuery extends BaseQuery {
templates.functions.TRUNC = 'CASE WHEN ({{ args[0] }}) >= 0 THEN FLOOR({{ args_concat }}) ELSE CEIL({{ args_concat }}) END';
templates.expressions.timestamp_literal = 'from_utc_timestamp(\'{{ value }}\', \'UTC\')';
templates.expressions.extract = 'EXTRACT({{ date_part }} FROM {{ expr }})';
templates.expressions.interval_single_date_part = 'INTERVAL \'{{ num }}\' {{ date_part }}';
templates.quotes.identifiers = '`';
templates.quotes.escape = '``';
// TODO: Databricks has `TIMESTAMP_NTZ` with logic similar to Pg's `TIMESTAMP`
Expand Down

0 comments on commit f61afc3

Please sign in to comment.