Merging upstream version 18.4.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
b982664fe2
commit
d90681de49
92 changed files with 43076 additions and 40554 deletions
|
@ -20,6 +20,7 @@ import typing as t
|
|||
from collections import deque
|
||||
from copy import deepcopy
|
||||
from enum import auto
|
||||
from functools import reduce
|
||||
|
||||
from sqlglot._typing import E
|
||||
from sqlglot.errors import ParseError
|
||||
|
@ -1170,7 +1171,7 @@ class Column(Condition):
|
|||
parts.append(parent.expression)
|
||||
parent = parent.parent
|
||||
|
||||
return Dot.build(parts)
|
||||
return Dot.build(deepcopy(parts))
|
||||
|
||||
|
||||
class ColumnPosition(Expression):
|
||||
|
@ -1537,6 +1538,10 @@ class ForeignKey(Expression):
|
|||
}
|
||||
|
||||
|
||||
class ColumnPrefix(Expression):
|
||||
arg_types = {"this": True, "expression": True}
|
||||
|
||||
|
||||
class PrimaryKey(Expression):
|
||||
arg_types = {"expressions": True, "options": False}
|
||||
|
||||
|
@ -3529,6 +3534,8 @@ class DataType(Expression):
|
|||
STRUCT = auto()
|
||||
SUPER = auto()
|
||||
TEXT = auto()
|
||||
TINYBLOB = auto()
|
||||
TINYTEXT = auto()
|
||||
TIME = auto()
|
||||
TIMETZ = auto()
|
||||
TIMESTAMP = auto()
|
||||
|
@ -3793,13 +3800,7 @@ class Dot(Binary):
|
|||
if len(expressions) < 2:
|
||||
raise ValueError(f"Dot requires >= 2 expressions.")
|
||||
|
||||
a, b, *expressions = expressions
|
||||
dot = Dot(this=a, expression=b)
|
||||
|
||||
for expression in expressions:
|
||||
dot = Dot(this=dot, expression=expression)
|
||||
|
||||
return dot
|
||||
return t.cast(Dot, reduce(lambda x, y: Dot(this=x, expression=y), expressions))
|
||||
|
||||
|
||||
class DPipe(Binary):
|
||||
|
@ -3959,6 +3960,13 @@ class Between(Predicate):
|
|||
class Bracket(Condition):
|
||||
arg_types = {"this": True, "expressions": True}
|
||||
|
||||
@property
|
||||
def output_name(self) -> str:
|
||||
if len(self.expressions) == 1:
|
||||
return self.expressions[0].output_name
|
||||
|
||||
return super().output_name
|
||||
|
||||
|
||||
class SafeBracket(Bracket):
|
||||
"""Represents array lookup where OOB index yields NULL instead of causing a failure."""
|
||||
|
@ -4477,6 +4485,10 @@ class IsNan(Func):
|
|||
_sql_names = ["IS_NAN", "ISNAN"]
|
||||
|
||||
|
||||
class FormatJson(Expression):
|
||||
pass
|
||||
|
||||
|
||||
class JSONKeyValue(Expression):
|
||||
arg_types = {"this": True, "expression": True}
|
||||
|
||||
|
@ -4487,11 +4499,48 @@ class JSONObject(Func):
|
|||
"null_handling": False,
|
||||
"unique_keys": False,
|
||||
"return_type": False,
|
||||
"format_json": False,
|
||||
"encoding": False,
|
||||
}
|
||||
|
||||
|
||||
# https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/JSON_ARRAY.html
|
||||
class JSONArray(Func):
|
||||
arg_types = {
|
||||
"expressions": True,
|
||||
"null_handling": False,
|
||||
"return_type": False,
|
||||
"strict": False,
|
||||
}
|
||||
|
||||
|
||||
# https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/JSON_ARRAYAGG.html
|
||||
class JSONArrayAgg(Func):
|
||||
arg_types = {
|
||||
"this": True,
|
||||
"order": False,
|
||||
"null_handling": False,
|
||||
"return_type": False,
|
||||
"strict": False,
|
||||
}
|
||||
|
||||
|
||||
# https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/JSON_TABLE.html
|
||||
# Note: parsing of JSON column definitions is currently incomplete.
|
||||
class JSONColumnDef(Expression):
|
||||
arg_types = {"this": True, "kind": False, "path": False}
|
||||
|
||||
|
||||
# # https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/JSON_TABLE.html
|
||||
class JSONTable(Func):
|
||||
arg_types = {
|
||||
"this": True,
|
||||
"expressions": True,
|
||||
"path": False,
|
||||
"error_handling": False,
|
||||
"empty_handling": False,
|
||||
}
|
||||
|
||||
|
||||
class OpenJSONColumnDef(Expression):
|
||||
arg_types = {"this": True, "kind": True, "path": False, "as_json": False}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue