Skip to content

Commit

Permalink
feat(cubesql): Add CURRENT_DATE function definitions for Postgres and…
Browse files Browse the repository at this point in the history
… Snowflake so those can be pushed down
  • Loading branch information
paveltiunov committed Dec 7, 2023
1 parent 7d6c153 commit ac1ca88
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/cubejs-schema-compiler/src/adapter/PostgresQuery.ts
Expand Up @@ -50,6 +50,8 @@ export class PostgresQuery extends BaseQuery {
templates.functions.DATETRUNC = 'DATE_TRUNC({{ args_concat }})';
templates.functions.CONCAT = 'CONCAT({% for arg in args %}CAST({{arg}} AS TEXT){% if not loop.last %},{% endif %}{% endfor %})';
templates.functions.DATEPART = 'DATE_PART({{ args_concat }})';
templates.functions.CURRENTDATE = 'CURRENT_DATE';
templates.functions.NOW = 'NOW({{ args_concat }})';
// DATEADD is being rewritten to DATE_ADD
// templates.functions.DATEADD = '({{ args[2] }} + \'{{ interval }} {{ date_part }}\'::interval)';
delete templates.functions.DATEDIFF;
Expand Down
2 changes: 2 additions & 0 deletions packages/cubejs-schema-compiler/src/adapter/SnowflakeQuery.ts
Expand Up @@ -54,6 +54,8 @@ export class SnowflakeQuery extends BaseQuery {
const templates = super.sqlTemplates();
templates.functions.DATETRUNC = 'DATE_TRUNC({{ args_concat }})';
templates.functions.DATEPART = 'DATE_PART({{ args_concat }})';
templates.functions.CURRENTDATE = 'CURRENT_DATE';
templates.functions.NOW = 'CURRENT_TIMESTAMP';
templates.functions.LOG = 'LOG({% if args[1] is undefined %}10, {% endif %}{{ args_concat }})';
templates.functions.DLOG10 = 'LOG(10, {{ args_concat }})';
templates.functions.CHARACTERLENGTH = 'LENGTH({{ args[0] }})';
Expand Down

0 comments on commit ac1ca88

Please sign in to comment.