diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-02-20 09:38:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-02-20 09:38:01 +0000 |
commit | ccb96d1393ae2c16620ea8e8dc749d9642b94e9b (patch) | |
tree | d21a77d0cc7da73a84cd6d6ef8212602f5d762e8 /sqlglot/dialects/starrocks.py | |
parent | Releasing debian version 21.1.1-1. (diff) | |
download | sqlglot-ccb96d1393ae2c16620ea8e8dc749d9642b94e9b.tar.xz sqlglot-ccb96d1393ae2c16620ea8e8dc749d9642b94e9b.zip |
Merging upstream version 21.1.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | sqlglot/dialects/starrocks.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/sqlglot/dialects/starrocks.py b/sqlglot/dialects/starrocks.py index 8838f34..12ac600 100644 --- a/sqlglot/dialects/starrocks.py +++ b/sqlglot/dialects/starrocks.py @@ -4,7 +4,7 @@ from sqlglot import exp from sqlglot.dialects.dialect import ( approx_count_distinct_sql, arrow_json_extract_sql, - parse_timestamp_trunc, + build_timestamp_trunc, rename_func, ) from sqlglot.dialects.mysql import MySQL @@ -15,7 +15,7 @@ class StarRocks(MySQL): class Parser(MySQL.Parser): FUNCTIONS = { **MySQL.Parser.FUNCTIONS, - "DATE_TRUNC": parse_timestamp_trunc, + "DATE_TRUNC": build_timestamp_trunc, "DATEDIFF": lambda args: exp.DateDiff( this=seq_get(args, 0), expression=seq_get(args, 1), unit=exp.Literal.string("DAY") ), @@ -44,14 +44,12 @@ class StarRocks(MySQL): exp.JSONExtractScalar: arrow_json_extract_sql, exp.JSONExtract: arrow_json_extract_sql, exp.RegexpLike: rename_func("REGEXP"), - exp.StrToUnix: lambda self, - e: f"UNIX_TIMESTAMP({self.sql(e, 'this')}, {self.format_time(e)})", + exp.StrToUnix: lambda self, e: self.func("UNIX_TIMESTAMP", e.this, self.format_time(e)), exp.TimestampTrunc: lambda self, e: self.func( "DATE_TRUNC", exp.Literal.string(e.text("unit")), e.this ), exp.TimeStrToDate: rename_func("TO_DATE"), - exp.UnixToStr: lambda self, - e: f"FROM_UNIXTIME({self.sql(e, 'this')}, {self.format_time(e)})", + exp.UnixToStr: lambda self, e: self.func("FROM_UNIXTIME", e.this, self.format_time(e)), exp.UnixToTime: rename_func("FROM_UNIXTIME"), } |