summaryrefslogtreecommitdiffstats
path: root/sqlglot/dialects/snowflake.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 02:50:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 02:50:25 +0000
commitcf49728f719975144a958f23ba5f3336fb81ae55 (patch)
tree78aa5446e86cc5623808508ee167c9a476754939 /sqlglot/dialects/snowflake.py
parentReleasing debian version 23.10.0-1. (diff)
downloadsqlglot-cf49728f719975144a958f23ba5f3336fb81ae55.tar.xz
sqlglot-cf49728f719975144a958f23ba5f3336fb81ae55.zip
Merging upstream version 23.12.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/dialects/snowflake.py')
-rw-r--r--sqlglot/dialects/snowflake.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/sqlglot/dialects/snowflake.py b/sqlglot/dialects/snowflake.py
index 41d5b65..dba56c4 100644
--- a/sqlglot/dialects/snowflake.py
+++ b/sqlglot/dialects/snowflake.py
@@ -33,10 +33,9 @@ def _build_datetime(
) -> t.Callable[[t.List], exp.Func]:
def _builder(args: t.List) -> exp.Func:
value = seq_get(args, 0)
+ int_value = value is not None and is_int(value.name)
if isinstance(value, exp.Literal):
- int_value = is_int(value.this)
-
# Converts calls like `TO_TIME('01:02:03')` into casts
if len(args) == 1 and value.is_string and not int_value:
return exp.cast(value, kind)
@@ -49,7 +48,7 @@ def _build_datetime(
if not is_float(value.this):
return build_formatted_time(exp.StrToTime, "snowflake")(args)
- if len(args) == 2 and kind == exp.DataType.Type.DATE:
+ if kind == exp.DataType.Type.DATE and not int_value:
formatted_exp = build_formatted_time(exp.TsOrDsToDate, "snowflake")(args)
formatted_exp.set("safe", safe)
return formatted_exp
@@ -749,6 +748,7 @@ class Snowflake(Dialect):
TRANSFORMS = {
**generator.Generator.TRANSFORMS,
+ exp.ApproxDistinct: rename_func("APPROX_COUNT_DISTINCT"),
exp.ArgMax: rename_func("MAX_BY"),
exp.ArgMin: rename_func("MIN_BY"),
exp.Array: inline_array_sql,