Merging upstream version 11.2.3.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
c6f7c6bbe1
commit
428b7dd76f
93 changed files with 33054 additions and 31671 deletions
|
@ -82,7 +82,7 @@ class Expression(metaclass=_Expression):
|
|||
|
||||
key = "expression"
|
||||
arg_types = {"this": True}
|
||||
__slots__ = ("args", "parent", "arg_key", "comments", "_type")
|
||||
__slots__ = ("args", "parent", "arg_key", "comments", "_type", "_meta")
|
||||
|
||||
def __init__(self, **args: t.Any):
|
||||
self.args: t.Dict[str, t.Any] = args
|
||||
|
@ -90,6 +90,7 @@ class Expression(metaclass=_Expression):
|
|||
self.arg_key: t.Optional[str] = None
|
||||
self.comments: t.Optional[t.List[str]] = None
|
||||
self._type: t.Optional[DataType] = None
|
||||
self._meta: t.Optional[t.Dict[str, t.Any]] = None
|
||||
|
||||
for arg_key, value in self.args.items():
|
||||
self._set_parent(arg_key, value)
|
||||
|
@ -219,10 +220,23 @@ class Expression(metaclass=_Expression):
|
|||
dtype = DataType.build(dtype)
|
||||
self._type = dtype # type: ignore
|
||||
|
||||
@property
|
||||
def meta(self) -> t.Dict[str, t.Any]:
|
||||
if self._meta is None:
|
||||
self._meta = {}
|
||||
return self._meta
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
copy = self.__class__(**deepcopy(self.args))
|
||||
copy.comments = self.comments
|
||||
copy.type = self.type
|
||||
if self.comments is not None:
|
||||
copy.comments = deepcopy(self.comments)
|
||||
|
||||
if self._type is not None:
|
||||
copy._type = self._type.copy()
|
||||
|
||||
if self._meta is not None:
|
||||
copy._meta = deepcopy(self._meta)
|
||||
|
||||
return copy
|
||||
|
||||
def copy(self):
|
||||
|
@ -329,6 +343,15 @@ class Expression(metaclass=_Expression):
|
|||
"""
|
||||
return self.find_ancestor(Select)
|
||||
|
||||
def root(self) -> Expression:
|
||||
"""
|
||||
Returns the root expression of this tree.
|
||||
"""
|
||||
expression = self
|
||||
while expression.parent:
|
||||
expression = expression.parent
|
||||
return expression
|
||||
|
||||
def walk(self, bfs=True, prune=None):
|
||||
"""
|
||||
Returns a generator object which visits all nodes in this tree.
|
||||
|
@ -767,21 +790,10 @@ class Create(Expression):
|
|||
"this": True,
|
||||
"kind": True,
|
||||
"expression": False,
|
||||
"set": False,
|
||||
"multiset": False,
|
||||
"global_temporary": False,
|
||||
"volatile": False,
|
||||
"exists": False,
|
||||
"properties": False,
|
||||
"temporary": False,
|
||||
"transient": False,
|
||||
"external": False,
|
||||
"replace": False,
|
||||
"unique": False,
|
||||
"materialized": False,
|
||||
"data": False,
|
||||
"statistics": False,
|
||||
"no_primary_index": False,
|
||||
"indexes": False,
|
||||
"no_schema_binding": False,
|
||||
"begin": False,
|
||||
|
@ -1336,42 +1348,92 @@ class Property(Expression):
|
|||
arg_types = {"this": True, "value": True}
|
||||
|
||||
|
||||
class AfterJournalProperty(Property):
|
||||
arg_types = {"no": True, "dual": False, "local": False}
|
||||
|
||||
|
||||
class AlgorithmProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class AutoIncrementProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class BlockCompressionProperty(Property):
|
||||
arg_types = {"autotemp": False, "always": False, "default": True, "manual": True, "never": True}
|
||||
|
||||
|
||||
class CharacterSetProperty(Property):
|
||||
arg_types = {"this": True, "default": True}
|
||||
|
||||
|
||||
class ChecksumProperty(Property):
|
||||
arg_types = {"on": False, "default": False}
|
||||
|
||||
|
||||
class CollateProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class DataBlocksizeProperty(Property):
|
||||
arg_types = {"size": False, "units": False, "min": False, "default": False}
|
||||
|
||||
|
||||
class DefinerProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class SqlSecurityProperty(Property):
|
||||
arg_types = {"definer": True}
|
||||
|
||||
|
||||
class TableFormatProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class PartitionedByProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class FileFormatProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class DistKeyProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class SortKeyProperty(Property):
|
||||
arg_types = {"this": True, "compound": False}
|
||||
|
||||
|
||||
class DistStyleProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class EngineProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class ExecuteAsProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class ExternalProperty(Property):
|
||||
arg_types = {"this": False}
|
||||
|
||||
|
||||
class FallbackProperty(Property):
|
||||
arg_types = {"no": True, "protection": False}
|
||||
|
||||
|
||||
class FileFormatProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class FreespaceProperty(Property):
|
||||
arg_types = {"this": True, "percent": False}
|
||||
|
||||
|
||||
class IsolatedLoadingProperty(Property):
|
||||
arg_types = {
|
||||
"no": True,
|
||||
"concurrent": True,
|
||||
"for_all": True,
|
||||
"for_insert": True,
|
||||
"for_none": True,
|
||||
}
|
||||
|
||||
|
||||
class JournalProperty(Property):
|
||||
arg_types = {"no": True, "dual": False, "before": False}
|
||||
|
||||
|
||||
class LanguageProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class LikeProperty(Property):
|
||||
arg_types = {"this": True, "expressions": False}
|
||||
|
||||
|
@ -1380,23 +1442,37 @@ class LocationProperty(Property):
|
|||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class EngineProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
class LockingProperty(Property):
|
||||
arg_types = {
|
||||
"this": False,
|
||||
"kind": True,
|
||||
"for_or_in": True,
|
||||
"lock_type": True,
|
||||
"override": False,
|
||||
}
|
||||
|
||||
|
||||
class AutoIncrementProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
class LogProperty(Property):
|
||||
arg_types = {"no": True}
|
||||
|
||||
|
||||
class CharacterSetProperty(Property):
|
||||
arg_types = {"this": True, "default": True}
|
||||
class MaterializedProperty(Property):
|
||||
arg_types = {"this": False}
|
||||
|
||||
|
||||
class CollateProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
class MergeBlockRatioProperty(Property):
|
||||
arg_types = {"this": False, "no": False, "default": False, "percent": False}
|
||||
|
||||
|
||||
class SchemaCommentProperty(Property):
|
||||
class NoPrimaryIndexProperty(Property):
|
||||
arg_types = {"this": False}
|
||||
|
||||
|
||||
class OnCommitProperty(Property):
|
||||
arg_type = {"this": False}
|
||||
|
||||
|
||||
class PartitionedByProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
|
@ -1404,18 +1480,6 @@ class ReturnsProperty(Property):
|
|||
arg_types = {"this": True, "is_table": False, "table": False}
|
||||
|
||||
|
||||
class LanguageProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class ExecuteAsProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class VolatilityProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class RowFormatDelimitedProperty(Property):
|
||||
# https://cwiki.apache.org/confluence/display/hive/languagemanual+dml
|
||||
arg_types = {
|
||||
|
@ -1433,70 +1497,50 @@ class RowFormatSerdeProperty(Property):
|
|||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class SchemaCommentProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class SerdeProperties(Property):
|
||||
arg_types = {"expressions": True}
|
||||
|
||||
|
||||
class FallbackProperty(Property):
|
||||
arg_types = {"no": True, "protection": False}
|
||||
class SetProperty(Property):
|
||||
arg_types = {"multi": True}
|
||||
|
||||
|
||||
class SortKeyProperty(Property):
|
||||
arg_types = {"this": True, "compound": False}
|
||||
|
||||
|
||||
class SqlSecurityProperty(Property):
|
||||
arg_types = {"definer": True}
|
||||
|
||||
|
||||
class TableFormatProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class TemporaryProperty(Property):
|
||||
arg_types = {"global_": True}
|
||||
|
||||
|
||||
class TransientProperty(Property):
|
||||
arg_types = {"this": False}
|
||||
|
||||
|
||||
class VolatilityProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class WithDataProperty(Property):
|
||||
arg_types = {"no": True, "statistics": False}
|
||||
|
||||
|
||||
class WithJournalTableProperty(Property):
|
||||
arg_types = {"this": True}
|
||||
|
||||
|
||||
class LogProperty(Property):
|
||||
arg_types = {"no": True}
|
||||
|
||||
|
||||
class JournalProperty(Property):
|
||||
arg_types = {"no": True, "dual": False, "before": False}
|
||||
|
||||
|
||||
class AfterJournalProperty(Property):
|
||||
arg_types = {"no": True, "dual": False, "local": False}
|
||||
|
||||
|
||||
class ChecksumProperty(Property):
|
||||
arg_types = {"on": False, "default": False}
|
||||
|
||||
|
||||
class FreespaceProperty(Property):
|
||||
arg_types = {"this": True, "percent": False}
|
||||
|
||||
|
||||
class MergeBlockRatioProperty(Property):
|
||||
arg_types = {"this": False, "no": False, "default": False, "percent": False}
|
||||
|
||||
|
||||
class DataBlocksizeProperty(Property):
|
||||
arg_types = {"size": False, "units": False, "min": False, "default": False}
|
||||
|
||||
|
||||
class BlockCompressionProperty(Property):
|
||||
arg_types = {"autotemp": False, "always": False, "default": True, "manual": True, "never": True}
|
||||
|
||||
|
||||
class IsolatedLoadingProperty(Property):
|
||||
arg_types = {
|
||||
"no": True,
|
||||
"concurrent": True,
|
||||
"for_all": True,
|
||||
"for_insert": True,
|
||||
"for_none": True,
|
||||
}
|
||||
|
||||
|
||||
class LockingProperty(Property):
|
||||
arg_types = {
|
||||
"this": False,
|
||||
"kind": True,
|
||||
"for_or_in": True,
|
||||
"lock_type": True,
|
||||
"override": False,
|
||||
}
|
||||
|
||||
|
||||
class Properties(Expression):
|
||||
arg_types = {"expressions": True}
|
||||
|
||||
|
@ -1533,7 +1577,7 @@ class Properties(Expression):
|
|||
# Form: alias selection
|
||||
# create [POST_CREATE]
|
||||
# table a [POST_NAME]
|
||||
# as [POST_ALIAS] (select * from b)
|
||||
# as [POST_ALIAS] (select * from b) [POST_EXPRESSION]
|
||||
# index (c) [POST_INDEX]
|
||||
class Location(AutoName):
|
||||
POST_CREATE = auto()
|
||||
|
@ -1541,6 +1585,7 @@ class Properties(Expression):
|
|||
POST_SCHEMA = auto()
|
||||
POST_WITH = auto()
|
||||
POST_ALIAS = auto()
|
||||
POST_EXPRESSION = auto()
|
||||
POST_INDEX = auto()
|
||||
UNSUPPORTED = auto()
|
||||
|
||||
|
@ -1797,6 +1842,10 @@ class Union(Subqueryable):
|
|||
def named_selects(self):
|
||||
return self.this.unnest().named_selects
|
||||
|
||||
@property
|
||||
def is_star(self) -> bool:
|
||||
return self.this.is_star or self.expression.is_star
|
||||
|
||||
@property
|
||||
def selects(self):
|
||||
return self.this.unnest().selects
|
||||
|
@ -2424,6 +2473,10 @@ class Select(Subqueryable):
|
|||
def named_selects(self) -> t.List[str]:
|
||||
return [e.output_name for e in self.expressions if e.alias_or_name]
|
||||
|
||||
@property
|
||||
def is_star(self) -> bool:
|
||||
return any(expression.is_star for expression in self.expressions)
|
||||
|
||||
@property
|
||||
def selects(self) -> t.List[Expression]:
|
||||
return self.expressions
|
||||
|
@ -2446,6 +2499,10 @@ class Subquery(DerivedTable, Unionable):
|
|||
expression = expression.this
|
||||
return expression
|
||||
|
||||
@property
|
||||
def is_star(self) -> bool:
|
||||
return self.this.is_star
|
||||
|
||||
@property
|
||||
def output_name(self):
|
||||
return self.alias
|
||||
|
@ -2478,6 +2535,7 @@ class Tag(Expression):
|
|||
class Pivot(Expression):
|
||||
arg_types = {
|
||||
"this": False,
|
||||
"alias": False,
|
||||
"expressions": True,
|
||||
"field": True,
|
||||
"unpivot": True,
|
||||
|
@ -2603,6 +2661,7 @@ class DataType(Expression):
|
|||
IMAGE = auto()
|
||||
VARIANT = auto()
|
||||
OBJECT = auto()
|
||||
INET = auto()
|
||||
NULL = auto()
|
||||
UNKNOWN = auto() # Sentinel value, useful for type annotation
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue