summaryrefslogtreecommitdiffstats
path: root/sqlglot/dialects/duckdb.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-20 09:22:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-20 09:22:25 +0000
commita45bbbb6f2fbd117d5d314e34e85afc2b48ad677 (patch)
tree35b576637338ae7cef217ddab721ad81aeb3f78c /sqlglot/dialects/duckdb.py
parentReleasing debian version 18.4.1-1. (diff)
downloadsqlglot-a45bbbb6f2fbd117d5d314e34e85afc2b48ad677.tar.xz
sqlglot-a45bbbb6f2fbd117d5d314e34e85afc2b48ad677.zip
Merging upstream version 18.5.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/dialects/duckdb.py')
-rw-r--r--sqlglot/dialects/duckdb.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/sqlglot/dialects/duckdb.py b/sqlglot/dialects/duckdb.py
index bf657ed..ab7a26a 100644
--- a/sqlglot/dialects/duckdb.py
+++ b/sqlglot/dialects/duckdb.py
@@ -105,6 +105,7 @@ def _json_format_sql(self: DuckDB.Generator, expression: exp.JSONFormat) -> str:
class DuckDB(Dialect):
NULL_ORDERING = "nulls_are_last"
+ SUPPORTS_USER_DEFINED_TYPES = False
# https://duckdb.org/docs/sql/introduction.html#creating-a-new-table
RESOLVES_IDENTIFIERS_AS_UPPERCASE = None
@@ -135,7 +136,6 @@ class DuckDB(Dialect):
class Parser(parser.Parser):
CONCAT_NULL_OUTPUTS_STRING = True
- SUPPORTS_USER_DEFINED_TYPES = False
BITWISE = {
**parser.Parser.BITWISE,
@@ -158,6 +158,11 @@ class DuckDB(Dialect):
"LIST_REVERSE_SORT": _sort_array_reverse,
"LIST_SORT": exp.SortArray.from_arg_list,
"LIST_VALUE": exp.Array.from_arg_list,
+ "MEDIAN": lambda args: exp.PercentileCont(
+ this=seq_get(args, 0), expression=exp.Literal.number(0.5)
+ ),
+ "QUANTILE_CONT": exp.PercentileCont.from_arg_list,
+ "QUANTILE_DISC": exp.PercentileDisc.from_arg_list,
"REGEXP_EXTRACT": lambda args: exp.RegexpExtract(
this=seq_get(args, 0), expression=seq_get(args, 1), group=seq_get(args, 2)
),
@@ -266,6 +271,9 @@ class DuckDB(Dialect):
exp.cast(e.expression, "timestamp", copy=True),
exp.cast(e.this, "timestamp", copy=True),
),
+ exp.ParseJSON: rename_func("JSON"),
+ exp.PercentileCont: rename_func("QUANTILE_CONT"),
+ exp.PercentileDisc: rename_func("QUANTILE_DISC"),
exp.Properties: no_properties_sql,
exp.RegexpExtract: regexp_extract_sql,
exp.RegexpReplace: regexp_replace_sql,