diff options
Diffstat (limited to 'sqlglot/dialects/duckdb.py')
-rw-r--r-- | sqlglot/dialects/duckdb.py | 10 |
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, |