Adding upstream version 25.6.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
4e506fbac7
commit
f9dae8e951
69 changed files with 46817 additions and 45778 deletions
|
@ -375,6 +375,9 @@ class Generator(metaclass=_Generator):
|
|||
# Whether to quote the generated expression of exp.JsonPath
|
||||
QUOTE_JSON_PATH = True
|
||||
|
||||
# Whether the text pattern/fill (3rd) parameter of RPAD()/LPAD() is optional (defaults to space)
|
||||
PAD_FILL_PATTERN_IS_REQUIRED = False
|
||||
|
||||
# The name to generate for the JSONPath expression. If `None`, only `this` will be generated
|
||||
PARSE_JSON_NAME: t.Optional[str] = "PARSE_JSON"
|
||||
|
||||
|
@ -406,13 +409,13 @@ class Generator(metaclass=_Generator):
|
|||
AFTER_HAVING_MODIFIER_TRANSFORMS = {
|
||||
"cluster": lambda self, e: self.sql(e, "cluster"),
|
||||
"distribute": lambda self, e: self.sql(e, "distribute"),
|
||||
"qualify": lambda self, e: self.sql(e, "qualify"),
|
||||
"sort": lambda self, e: self.sql(e, "sort"),
|
||||
"windows": lambda self, e: (
|
||||
self.seg("WINDOW ") + self.expressions(e, key="windows", flat=True)
|
||||
if e.args.get("windows")
|
||||
else ""
|
||||
),
|
||||
"qualify": lambda self, e: self.sql(e, "qualify"),
|
||||
}
|
||||
|
||||
TOKEN_MAPPING: t.Dict[TokenType, str] = {}
|
||||
|
@ -512,6 +515,7 @@ class Generator(metaclass=_Generator):
|
|||
|
||||
# Expressions whose comments are separated from them for better formatting
|
||||
WITH_SEPARATED_COMMENTS: t.Tuple[t.Type[exp.Expression], ...] = (
|
||||
exp.Command,
|
||||
exp.Create,
|
||||
exp.Delete,
|
||||
exp.Drop,
|
||||
|
@ -957,7 +961,8 @@ class Generator(metaclass=_Generator):
|
|||
index_type = f" USING {index_type}" if index_type else ""
|
||||
on_conflict = self.sql(expression, "on_conflict")
|
||||
on_conflict = f" {on_conflict}" if on_conflict else ""
|
||||
return f"UNIQUE{this}{index_type}{on_conflict}"
|
||||
nulls_sql = " NULLS NOT DISTINCT" if expression.args.get("nulls") else ""
|
||||
return f"UNIQUE{nulls_sql}{this}{index_type}{on_conflict}"
|
||||
|
||||
def createable_sql(self, expression: exp.Create, locations: t.DefaultDict) -> str:
|
||||
return self.sql(expression, "this")
|
||||
|
@ -996,6 +1001,7 @@ class Generator(metaclass=_Generator):
|
|||
expression_sql = f"{begin}{self.sep()}{expression_sql}{end}"
|
||||
|
||||
if self.CREATE_FUNCTION_RETURN_AS or not isinstance(expression.expression, exp.Return):
|
||||
postalias_props_sql = ""
|
||||
if properties_locs.get(exp.Properties.Location.POST_ALIAS):
|
||||
postalias_props_sql = self.properties(
|
||||
exp.Properties(
|
||||
|
@ -1003,9 +1009,8 @@ class Generator(metaclass=_Generator):
|
|||
),
|
||||
wrapped=False,
|
||||
)
|
||||
expression_sql = f" AS {postalias_props_sql}{expression_sql}"
|
||||
else:
|
||||
expression_sql = f" AS{expression_sql}"
|
||||
postalias_props_sql = f" {postalias_props_sql}" if postalias_props_sql else ""
|
||||
expression_sql = f" AS{postalias_props_sql}{expression_sql}"
|
||||
|
||||
postindex_props_sql = ""
|
||||
if properties_locs.get(exp.Properties.Location.POST_INDEX):
|
||||
|
@ -1754,6 +1759,10 @@ class Generator(metaclass=_Generator):
|
|||
changes = self.sql(expression, "changes")
|
||||
changes = f" {changes}" if changes else ""
|
||||
|
||||
rows_from = self.expressions(expression, key="rows_from")
|
||||
if rows_from:
|
||||
table = f"ROWS FROM {self.wrap(rows_from)}"
|
||||
|
||||
return f"{only}{table}{changes}{partition}{version}{file_format}{alias}{hints}{pivots}{joins}{laterals}{ordinality}"
|
||||
|
||||
def tablesample_sql(
|
||||
|
@ -4043,3 +4052,12 @@ class Generator(metaclass=_Generator):
|
|||
end = f"{self.seg('')}{end}" if end else ""
|
||||
|
||||
return f"CHANGES ({information}){at_before}{end}"
|
||||
|
||||
def pad_sql(self, expression: exp.Pad) -> str:
|
||||
prefix = "L" if expression.args.get("is_left") else "R"
|
||||
|
||||
fill_pattern = self.sql(expression, "fill_pattern") or None
|
||||
if not fill_pattern and self.PAD_FILL_PATTERN_IS_REQUIRED:
|
||||
fill_pattern = "' '"
|
||||
|
||||
return self.func(f"{prefix}PAD", expression.this, expression.expression, fill_pattern)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue