Adding upstream version 25.32.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
ec2e441f55
commit
24751d63a1
74 changed files with 2284 additions and 1814 deletions
|
@ -188,7 +188,7 @@ class Generator(metaclass=_Generator):
|
|||
exp.StrictProperty: lambda *_: "STRICT",
|
||||
exp.SwapTable: lambda self, e: f"SWAP WITH {self.sql(e, 'this')}",
|
||||
exp.TemporaryProperty: lambda *_: "TEMPORARY",
|
||||
exp.TagColumnConstraint: lambda self, e: f"TAG ({self.expressions(e, flat=True)})",
|
||||
exp.Tags: lambda self, e: f"TAG ({self.expressions(e, flat=True)})",
|
||||
exp.TitleColumnConstraint: lambda self, e: f"TITLE {self.sql(e, 'this')}",
|
||||
exp.ToMap: lambda self, e: f"MAP {self.sql(e, 'this')}",
|
||||
exp.ToTableProperty: lambda self, e: f"TO {self.sql(e.this)}",
|
||||
|
@ -496,6 +496,8 @@ class Generator(metaclass=_Generator):
|
|||
PARAMETER_TOKEN = "@"
|
||||
NAMED_PLACEHOLDER_TOKEN = ":"
|
||||
|
||||
EXPRESSION_PRECEDES_PROPERTIES_CREATABLES: t.Set[str] = set()
|
||||
|
||||
PROPERTIES_LOCATION = {
|
||||
exp.AllowedValuesProperty: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.AlgorithmProperty: exp.Properties.Location.POST_CREATE,
|
||||
|
@ -520,6 +522,7 @@ class Generator(metaclass=_Generator):
|
|||
exp.DistKeyProperty: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.DistStyleProperty: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.EmptyProperty: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.EncodeProperty: exp.Properties.Location.POST_EXPRESSION,
|
||||
exp.EngineProperty: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.ExecuteAsProperty: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.ExternalProperty: exp.Properties.Location.POST_CREATE,
|
||||
|
@ -530,6 +533,7 @@ class Generator(metaclass=_Generator):
|
|||
exp.HeapProperty: exp.Properties.Location.POST_WITH,
|
||||
exp.InheritsProperty: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.IcebergProperty: exp.Properties.Location.POST_CREATE,
|
||||
exp.IncludeProperty: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.InputModelProperty: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.IsolatedLoadingProperty: exp.Properties.Location.POST_NAME,
|
||||
exp.JournalProperty: exp.Properties.Location.POST_NAME,
|
||||
|
@ -572,6 +576,7 @@ class Generator(metaclass=_Generator):
|
|||
exp.StabilityProperty: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.StreamingTableProperty: exp.Properties.Location.POST_CREATE,
|
||||
exp.StrictProperty: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.Tags: exp.Properties.Location.POST_WITH,
|
||||
exp.TemporaryProperty: exp.Properties.Location.POST_CREATE,
|
||||
exp.ToTableProperty: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.TransientProperty: exp.Properties.Location.POST_CREATE,
|
||||
|
@ -1154,7 +1159,12 @@ class Generator(metaclass=_Generator):
|
|||
clone = self.sql(expression, "clone")
|
||||
clone = f" {clone}" if clone else ""
|
||||
|
||||
expression_sql = f"CREATE{modifiers} {kind}{concurrently}{exists_sql} {this}{properties_sql}{expression_sql}{postexpression_props_sql}{index_sql}{no_schema_binding}{clone}"
|
||||
if kind in self.EXPRESSION_PRECEDES_PROPERTIES_CREATABLES:
|
||||
properties_expression = f"{expression_sql}{properties_sql}"
|
||||
else:
|
||||
properties_expression = f"{properties_sql}{expression_sql}"
|
||||
|
||||
expression_sql = f"CREATE{modifiers} {kind}{concurrently}{exists_sql} {this}{properties_expression}{postexpression_props_sql}{index_sql}{no_schema_binding}{clone}"
|
||||
return self.prepend_ctes(expression, expression_sql)
|
||||
|
||||
def sequenceproperties_sql(self, expression: exp.SequenceProperties) -> str:
|
||||
|
@ -1193,7 +1203,10 @@ class Generator(metaclass=_Generator):
|
|||
style = f" {style}" if style else ""
|
||||
partition = self.sql(expression, "partition")
|
||||
partition = f" {partition}" if partition else ""
|
||||
return f"DESCRIBE{style} {self.sql(expression, 'this')}{partition}"
|
||||
format = self.sql(expression, "format")
|
||||
format = f" {format}" if format else ""
|
||||
|
||||
return f"DESCRIBE{style}{format} {self.sql(expression, 'this')}{partition}"
|
||||
|
||||
def heredoc_sql(self, expression: exp.Heredoc) -> str:
|
||||
tag = self.sql(expression, "tag")
|
||||
|
@ -3519,10 +3532,10 @@ class Generator(metaclass=_Generator):
|
|||
elif arg_value is not None:
|
||||
args.append(arg_value)
|
||||
|
||||
if self.normalize_functions:
|
||||
name = expression.sql_name()
|
||||
else:
|
||||
if self.dialect.PRESERVE_ORIGINAL_NAMES:
|
||||
name = (expression._meta and expression.meta.get("name")) or expression.sql_name()
|
||||
else:
|
||||
name = expression.sql_name()
|
||||
|
||||
return self.func(name, *args)
|
||||
|
||||
|
@ -4520,3 +4533,65 @@ class Generator(metaclass=_Generator):
|
|||
dim = exp.Literal.number(1)
|
||||
|
||||
return self.func(self.ARRAY_SIZE_NAME, expression.this, dim)
|
||||
|
||||
def attach_sql(self, expression: exp.Attach) -> str:
|
||||
this = self.sql(expression, "this")
|
||||
exists_sql = " IF NOT EXISTS" if expression.args.get("exists") else ""
|
||||
expressions = self.expressions(expression)
|
||||
expressions = f" ({expressions})" if expressions else ""
|
||||
|
||||
return f"ATTACH{exists_sql} {this}{expressions}"
|
||||
|
||||
def detach_sql(self, expression: exp.Detach) -> str:
|
||||
this = self.sql(expression, "this")
|
||||
exists_sql = " IF EXISTS" if expression.args.get("exists") else ""
|
||||
|
||||
return f"DETACH{exists_sql} {this}"
|
||||
|
||||
def attachoption_sql(self, expression: exp.AttachOption) -> str:
|
||||
this = self.sql(expression, "this")
|
||||
value = self.sql(expression, "expression")
|
||||
value = f" {value}" if value else ""
|
||||
return f"{this}{value}"
|
||||
|
||||
def featuresattime_sql(self, expression: exp.FeaturesAtTime) -> str:
|
||||
this_sql = self.sql(expression, "this")
|
||||
if isinstance(expression.this, exp.Table):
|
||||
this_sql = f"TABLE {this_sql}"
|
||||
|
||||
return self.func(
|
||||
"FEATURES_AT_TIME",
|
||||
this_sql,
|
||||
expression.args.get("time"),
|
||||
expression.args.get("num_rows"),
|
||||
expression.args.get("ignore_feature_nulls"),
|
||||
)
|
||||
|
||||
def watermarkcolumnconstraint_sql(self, expression: exp.WatermarkColumnConstraint) -> str:
|
||||
return (
|
||||
f"WATERMARK FOR {self.sql(expression, 'this')} AS {self.sql(expression, 'expression')}"
|
||||
)
|
||||
|
||||
def encodeproperty_sql(self, expression: exp.EncodeProperty) -> str:
|
||||
encode = "KEY ENCODE" if expression.args.get("key") else "ENCODE"
|
||||
encode = f"{encode} {self.sql(expression, 'this')}"
|
||||
|
||||
properties = expression.args.get("properties")
|
||||
if properties:
|
||||
encode = f"{encode} {self.properties(properties)}"
|
||||
|
||||
return encode
|
||||
|
||||
def includeproperty_sql(self, expression: exp.IncludeProperty) -> str:
|
||||
this = self.sql(expression, "this")
|
||||
include = f"INCLUDE {this}"
|
||||
|
||||
column_def = self.sql(expression, "column_def")
|
||||
if column_def:
|
||||
include = f"{include} {column_def}"
|
||||
|
||||
alias = self.sql(expression, "alias")
|
||||
if alias:
|
||||
include = f"{include} AS {alias}"
|
||||
|
||||
return include
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue