Merging upstream version 17.12.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
aa315e6009
commit
aae08e0bb3
64 changed files with 12465 additions and 11885 deletions
|
@ -39,6 +39,7 @@ class Dialects(str, Enum):
|
|||
TERADATA = "teradata"
|
||||
TRINO = "trino"
|
||||
TSQL = "tsql"
|
||||
Doris = "doris"
|
||||
|
||||
|
||||
class _Dialect(type):
|
||||
|
@ -121,7 +122,7 @@ class _Dialect(type):
|
|||
if hasattr(subclass, name):
|
||||
setattr(subclass, name, value)
|
||||
|
||||
if not klass.STRICT_STRING_CONCAT:
|
||||
if not klass.STRICT_STRING_CONCAT and klass.DPIPE_IS_STRING_CONCAT:
|
||||
klass.parser_class.BITWISE[TokenType.DPIPE] = exp.SafeDPipe
|
||||
|
||||
klass.generator_class.can_identify = klass.can_identify
|
||||
|
@ -146,6 +147,9 @@ class Dialect(metaclass=_Dialect):
|
|||
# Determines whether or not an unquoted identifier can start with a digit
|
||||
IDENTIFIERS_CAN_START_WITH_DIGIT = False
|
||||
|
||||
# Determines whether or not the DPIPE token ('||') is a string concatenation operator
|
||||
DPIPE_IS_STRING_CONCAT = True
|
||||
|
||||
# Determines whether or not CONCAT's arguments must be strings
|
||||
STRICT_STRING_CONCAT = False
|
||||
|
||||
|
@ -460,6 +464,20 @@ def format_time_lambda(
|
|||
return _format_time
|
||||
|
||||
|
||||
def time_format(
|
||||
dialect: DialectType = None,
|
||||
) -> t.Callable[[Generator, exp.UnixToStr | exp.StrToUnix], t.Optional[str]]:
|
||||
def _time_format(self: Generator, expression: exp.UnixToStr | exp.StrToUnix) -> t.Optional[str]:
|
||||
"""
|
||||
Returns the time format for a given expression, unless it's equivalent
|
||||
to the default time format of the dialect of interest.
|
||||
"""
|
||||
time_format = self.format_time(expression)
|
||||
return time_format if time_format != Dialect.get_or_raise(dialect).TIME_FORMAT else None
|
||||
|
||||
return _time_format
|
||||
|
||||
|
||||
def create_with_partitions_sql(self: Generator, expression: exp.Create) -> str:
|
||||
"""
|
||||
In Hive and Spark, the PARTITIONED BY property acts as an extension of a table's schema. When the
|
||||
|
@ -699,3 +717,8 @@ def simplify_literal(expression: E) -> E:
|
|||
|
||||
def binary_from_function(expr_type: t.Type[B]) -> t.Callable[[t.List], B]:
|
||||
return lambda args: expr_type(this=seq_get(args, 0), expression=seq_get(args, 1))
|
||||
|
||||
|
||||
# Used to represent DATE_TRUNC in Doris, Postgres and Starrocks dialects
|
||||
def parse_timestamp_trunc(args: t.List) -> exp.TimestampTrunc:
|
||||
return exp.TimestampTrunc(this=seq_get(args, 1), unit=seq_get(args, 0))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue