summaryrefslogtreecommitdiffstats
path: root/sqlglot/dialects/starrocks.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-10 09:23:46 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-10 09:23:46 +0000
commit5dde903f4f6659e384287a3e508b9f369c5a2ba3 (patch)
tree05cd2920d82f0023f6ac695dbb6eaeef64608401 /sqlglot/dialects/starrocks.py
parentAdding upstream version 17.9.1. (diff)
downloadsqlglot-5dde903f4f6659e384287a3e508b9f369c5a2ba3.tar.xz
sqlglot-5dde903f4f6659e384287a3e508b9f369c5a2ba3.zip
Adding upstream version 17.11.0.upstream/17.11.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/dialects/starrocks.py')
-rw-r--r--sqlglot/dialects/starrocks.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/sqlglot/dialects/starrocks.py b/sqlglot/dialects/starrocks.py
index baa62e8..4f6183c 100644
--- a/sqlglot/dialects/starrocks.py
+++ b/sqlglot/dialects/starrocks.py
@@ -17,6 +17,13 @@ class StarRocks(MySQL):
"DATE_TRUNC": lambda args: exp.TimestampTrunc(
this=seq_get(args, 1), unit=seq_get(args, 0)
),
+ "DATEDIFF": lambda args: exp.DateDiff(
+ this=seq_get(args, 0), expression=seq_get(args, 1), unit=exp.Literal.string("DAY")
+ ),
+ "DATE_DIFF": lambda args: exp.DateDiff(
+ this=seq_get(args, 1), expression=seq_get(args, 2), unit=seq_get(args, 0)
+ ),
+ "REGEXP": exp.RegexpLike.from_arg_list,
}
class Generator(MySQL.Generator):
@@ -32,9 +39,11 @@ class StarRocks(MySQL):
TRANSFORMS = {
**MySQL.Generator.TRANSFORMS,
exp.ApproxDistinct: approx_count_distinct_sql,
+ exp.DateDiff: lambda self, e: self.func(
+ "DATE_DIFF", exp.Literal.string(e.text("unit") or "DAY"), e.this, e.expression
+ ),
exp.JSONExtractScalar: arrow_json_extract_sql,
exp.JSONExtract: arrow_json_extract_sql,
- exp.DateDiff: rename_func("DATEDIFF"),
exp.RegexpLike: rename_func("REGEXP"),
exp.StrToUnix: lambda self, e: f"UNIX_TIMESTAMP({self.sql(e, 'this')}, {self.format_time(e)})",
exp.TimestampTrunc: lambda self, e: self.func(