Adding upstream version 25.24.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
cfe8a51f10
commit
a0663ae805
75 changed files with 43236 additions and 41203 deletions
|
@ -11,7 +11,6 @@ SQL expressions, such as `sqlglot.expressions.select`.
|
|||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
import math
|
||||
import numbers
|
||||
|
@ -36,6 +35,7 @@ from sqlglot.helper import (
|
|||
from sqlglot.tokens import Token, TokenError
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
from typing_extensions import Self
|
||||
from sqlglot._typing import E, Lit
|
||||
from sqlglot.dialects.dialect import DialectType
|
||||
|
||||
|
@ -1368,7 +1368,7 @@ class DML(Expression):
|
|||
dialect: DialectType = None,
|
||||
copy: bool = True,
|
||||
**opts,
|
||||
) -> DML:
|
||||
) -> "Self":
|
||||
"""
|
||||
Set the RETURNING expression. Not supported by all dialects.
|
||||
|
||||
|
@ -2314,6 +2314,16 @@ class Fetch(Expression):
|
|||
}
|
||||
|
||||
|
||||
class Grant(Expression):
|
||||
arg_types = {
|
||||
"privileges": True,
|
||||
"kind": False,
|
||||
"securable": True,
|
||||
"principals": True,
|
||||
"grant_option": False,
|
||||
}
|
||||
|
||||
|
||||
class Group(Expression):
|
||||
arg_types = {
|
||||
"expressions": False,
|
||||
|
@ -2570,6 +2580,14 @@ class Property(Expression):
|
|||
arg_types = {"this": True, "value": True}
|
||||
|
||||
|
||||
class GrantPrivilege(Expression):
|
||||
arg_types = {"this": True, "expressions": False}
|
||||
|
||||
|
||||
class GrantPrincipal(Expression):
|
||||
arg_types = {"this": True, "kind": False}
|
||||
|
||||
|
||||
class AllowedValuesProperty(Expression):
|
||||
arg_types = {"expressions": True}
|
||||
|
||||
|
@ -4123,6 +4141,7 @@ class DataType(Expression):
|
|||
NUMRANGE = auto()
|
||||
NVARCHAR = auto()
|
||||
OBJECT = auto()
|
||||
RANGE = auto()
|
||||
ROWVERSION = auto()
|
||||
SERIAL = auto()
|
||||
SET = auto()
|
||||
|
@ -4154,6 +4173,7 @@ class DataType(Expression):
|
|||
UINT256 = auto()
|
||||
UMEDIUMINT = auto()
|
||||
UDECIMAL = auto()
|
||||
UNION = auto()
|
||||
UNIQUEIDENTIFIER = auto()
|
||||
UNKNOWN = auto() # Sentinel value, useful for type annotation
|
||||
USERDEFINED = "USER-DEFINED"
|
||||
|
@ -4172,6 +4192,7 @@ class DataType(Expression):
|
|||
Type.NESTED,
|
||||
Type.OBJECT,
|
||||
Type.STRUCT,
|
||||
Type.UNION,
|
||||
}
|
||||
|
||||
ARRAY_TYPES = {
|
||||
|
@ -4396,6 +4417,15 @@ class Alter(Expression):
|
|||
"not_valid": False,
|
||||
}
|
||||
|
||||
@property
|
||||
def kind(self) -> t.Optional[str]:
|
||||
kind = self.args.get("kind")
|
||||
return kind and kind.upper()
|
||||
|
||||
@property
|
||||
def actions(self) -> t.List[Expression]:
|
||||
return self.args.get("actions") or []
|
||||
|
||||
|
||||
class AddConstraint(Expression):
|
||||
arg_types = {"expressions": True}
|
||||
|
@ -4911,6 +4941,10 @@ class ApproxDistinct(AggFunc):
|
|||
_sql_names = ["APPROX_DISTINCT", "APPROX_COUNT_DISTINCT"]
|
||||
|
||||
|
||||
class Apply(Func):
|
||||
arg_types = {"this": True, "expression": True}
|
||||
|
||||
|
||||
class Array(Func):
|
||||
arg_types = {"expressions": False, "bracket_notation": False}
|
||||
is_var_len_args = True
|
||||
|
@ -4950,6 +4984,10 @@ class ToNumber(Func):
|
|||
}
|
||||
|
||||
|
||||
class Columns(Func):
|
||||
arg_types = {"this": True, "unpack": False}
|
||||
|
||||
|
||||
# https://learn.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-ver16#syntax
|
||||
class Convert(Func):
|
||||
arg_types = {"this": True, "expression": True, "style": False}
|
||||
|
@ -5875,6 +5913,10 @@ class Normalize(Func):
|
|||
arg_types = {"this": True, "form": False}
|
||||
|
||||
|
||||
class Overlay(Func):
|
||||
arg_types = {"this": True, "expression": True, "from": True, "for": False}
|
||||
|
||||
|
||||
# https://cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-predict#mlpredict_function
|
||||
class Predict(Func):
|
||||
arg_types = {"this": True, "expression": True, "params_struct": False}
|
||||
|
@ -6007,6 +6049,7 @@ class Split(Func):
|
|||
# Start may be omitted in the case of postgres
|
||||
# https://www.postgresql.org/docs/9.1/functions-string.html @ Table 9-6
|
||||
class Substring(Func):
|
||||
_sql_names = ["SUBSTRING", "SUBSTR"]
|
||||
arg_types = {"this": True, "start": False, "length": False}
|
||||
|
||||
|
||||
|
@ -6209,10 +6252,6 @@ class UnixToTimeStr(Func):
|
|||
pass
|
||||
|
||||
|
||||
class UnpackColumns(Func):
|
||||
pass
|
||||
|
||||
|
||||
class Uuid(Func):
|
||||
_sql_names = ["UUID", "GEN_RANDOM_UUID", "GENERATE_UUID", "UUID_STRING"]
|
||||
|
||||
|
@ -6274,7 +6313,7 @@ class Use(Expression):
|
|||
arg_types = {"this": True, "kind": False}
|
||||
|
||||
|
||||
class Merge(Expression):
|
||||
class Merge(DML):
|
||||
arg_types = {
|
||||
"this": True,
|
||||
"using": True,
|
||||
|
@ -6838,9 +6877,7 @@ def delete(
|
|||
if where:
|
||||
delete_expr = delete_expr.where(where, dialect=dialect, copy=False, **opts)
|
||||
if returning:
|
||||
delete_expr = t.cast(
|
||||
Delete, delete_expr.returning(returning, dialect=dialect, copy=False, **opts)
|
||||
)
|
||||
delete_expr = delete_expr.returning(returning, dialect=dialect, copy=False, **opts)
|
||||
return delete_expr
|
||||
|
||||
|
||||
|
@ -6883,7 +6920,7 @@ def insert(
|
|||
insert = Insert(this=this, expression=expr, overwrite=overwrite)
|
||||
|
||||
if returning:
|
||||
insert = t.cast(Insert, insert.returning(returning, dialect=dialect, copy=False, **opts))
|
||||
insert = insert.returning(returning, dialect=dialect, copy=False, **opts)
|
||||
|
||||
return insert
|
||||
|
||||
|
@ -6893,6 +6930,7 @@ def merge(
|
|||
into: ExpOrStr,
|
||||
using: ExpOrStr,
|
||||
on: ExpOrStr,
|
||||
returning: t.Optional[ExpOrStr] = None,
|
||||
dialect: DialectType = None,
|
||||
copy: bool = True,
|
||||
**opts,
|
||||
|
@ -6913,6 +6951,7 @@ def merge(
|
|||
into: The target table to merge data into.
|
||||
using: The source table to merge data from.
|
||||
on: The join condition for the merge.
|
||||
returning: The columns to return from the merge.
|
||||
dialect: The dialect used to parse the input expressions.
|
||||
copy: Whether to copy the expression.
|
||||
**opts: Other options to use to parse the input expressions.
|
||||
|
@ -6920,7 +6959,7 @@ def merge(
|
|||
Returns:
|
||||
Merge: The syntax tree for the MERGE statement.
|
||||
"""
|
||||
return Merge(
|
||||
merge = Merge(
|
||||
this=maybe_parse(into, dialect=dialect, copy=copy, **opts),
|
||||
using=maybe_parse(using, dialect=dialect, copy=copy, **opts),
|
||||
on=maybe_parse(on, dialect=dialect, copy=copy, **opts),
|
||||
|
@ -6929,6 +6968,10 @@ def merge(
|
|||
for when_expr in when_exprs
|
||||
],
|
||||
)
|
||||
if returning:
|
||||
merge = merge.returning(returning, dialect=dialect, copy=False, **opts)
|
||||
|
||||
return merge
|
||||
|
||||
|
||||
def condition(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue