Adding upstream version 17.12.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
276276930e
commit
9de781a59b
64 changed files with 12465 additions and 11885 deletions
|
@ -89,6 +89,11 @@ def _struct_sql(self: generator.Generator, expression: exp.Struct) -> str:
|
|||
def _datatype_sql(self: generator.Generator, expression: exp.DataType) -> str:
|
||||
if expression.is_type("array"):
|
||||
return f"{self.expressions(expression, flat=True)}[]"
|
||||
|
||||
# Type TIMESTAMP / TIME WITH TIME ZONE does not support any modifiers
|
||||
if expression.is_type("timestamptz", "timetz"):
|
||||
return expression.this.value
|
||||
|
||||
return self.datatype_sql(expression)
|
||||
|
||||
|
||||
|
@ -110,14 +115,14 @@ class DuckDB(Dialect):
|
|||
"//": TokenType.DIV,
|
||||
"ATTACH": TokenType.COMMAND,
|
||||
"BINARY": TokenType.VARBINARY,
|
||||
"BPCHAR": TokenType.TEXT,
|
||||
"BITSTRING": TokenType.BIT,
|
||||
"BPCHAR": TokenType.TEXT,
|
||||
"CHAR": TokenType.TEXT,
|
||||
"CHARACTER VARYING": TokenType.TEXT,
|
||||
"EXCLUDE": TokenType.EXCEPT,
|
||||
"HUGEINT": TokenType.INT128,
|
||||
"INT1": TokenType.TINYINT,
|
||||
"LOGICAL": TokenType.BOOLEAN,
|
||||
"NUMERIC": TokenType.DOUBLE,
|
||||
"PIVOT_WIDER": TokenType.PIVOT,
|
||||
"SIGNED": TokenType.INT,
|
||||
"STRING": TokenType.VARCHAR,
|
||||
|
@ -186,6 +191,22 @@ class DuckDB(Dialect):
|
|||
TokenType.UTINYINT,
|
||||
}
|
||||
|
||||
def _parse_types(
|
||||
self, check_func: bool = False, schema: bool = False
|
||||
) -> t.Optional[exp.Expression]:
|
||||
this = super()._parse_types(check_func=check_func, schema=schema)
|
||||
|
||||
# DuckDB treats NUMERIC and DECIMAL without precision as DECIMAL(18, 3)
|
||||
# See: https://duckdb.org/docs/sql/data_types/numeric
|
||||
if (
|
||||
isinstance(this, exp.DataType)
|
||||
and this.is_type("numeric", "decimal")
|
||||
and not this.expressions
|
||||
):
|
||||
return exp.DataType.build("DECIMAL(18, 3)")
|
||||
|
||||
return this
|
||||
|
||||
def _pivot_column_names(self, aggregations: t.List[exp.Expression]) -> t.List[str]:
|
||||
if len(aggregations) == 1:
|
||||
return super()._pivot_column_names(aggregations)
|
||||
|
@ -231,6 +252,7 @@ class DuckDB(Dialect):
|
|||
exp.Encode: lambda self, e: encode_decode_sql(self, e, "ENCODE", replace=False),
|
||||
exp.Explode: rename_func("UNNEST"),
|
||||
exp.IntDiv: lambda self, e: self.binary(e, "//"),
|
||||
exp.IsNan: rename_func("ISNAN"),
|
||||
exp.JSONExtract: arrow_json_extract_sql,
|
||||
exp.JSONExtractScalar: arrow_json_extract_scalar_sql,
|
||||
exp.JSONFormat: _json_format_sql,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue