From d2e9401b18925b5702c5c758af7d4f5b61deb493 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 May 2023 08:44:54 +0200 Subject: Adding upstream version 12.2.0. Signed-off-by: Daniel Baumann --- docs/sqlglot/expressions.html | 19809 ++++++++++++++++++++++------------------ 1 file changed, 11068 insertions(+), 8741 deletions(-) (limited to 'docs/sqlglot/expressions.html') diff --git a/docs/sqlglot/expressions.html b/docs/sqlglot/expressions.html index a4b82fc..e4c3a7b 100644 --- a/docs/sqlglot/expressions.html +++ b/docs/sqlglot/expressions.html @@ -164,6 +164,27 @@
  • not_
  • +
  • + isin +
  • +
  • + between +
  • +
  • + like +
  • +
  • + ilike +
  • +
  • + eq +
  • +
  • + neq +
  • +
  • + rlike +
  • @@ -2075,6 +2096,12 @@
  • Case
  • @@ -2947,6 +2974,12 @@ + +
  • + NextValueFor +
      +
    +
  • maybe_parse @@ -3739,7 +3772,7 @@ SQL expressions, such as sqlglot.expressions.select< 650 651 652class Condition(Expression): - 653 def and_(self, *expressions, dialect=None, **opts): + 653 def and_(self, *expressions, dialect=None, copy=True, **opts): 654 """ 655 AND this condition with one or multiple expressions. 656 @@ -3751,4567 +3784,4713 @@ SQL expressions, such as sqlglot.expressions.select< 662 *expressions (str | Expression): the SQL code strings to parse. 663 If an `Expression` instance is passed, it will be used as-is. 664 dialect (str): the dialect used to parse the input expression. - 665 opts (kwargs): other options to use to parse the input expressions. - 666 - 667 Returns: - 668 And: the new condition. - 669 """ - 670 return and_(self, *expressions, dialect=dialect, **opts) - 671 - 672 def or_(self, *expressions, dialect=None, **opts): - 673 """ - 674 OR this condition with one or multiple expressions. - 675 - 676 Example: - 677 >>> condition("x=1").or_("y=1").sql() - 678 'x = 1 OR y = 1' - 679 - 680 Args: - 681 *expressions (str | Expression): the SQL code strings to parse. - 682 If an `Expression` instance is passed, it will be used as-is. - 683 dialect (str): the dialect used to parse the input expression. - 684 opts (kwargs): other options to use to parse the input expressions. - 685 - 686 Returns: - 687 Or: the new condition. - 688 """ - 689 return or_(self, *expressions, dialect=dialect, **opts) - 690 - 691 def not_(self): - 692 """ - 693 Wrap this condition with NOT. - 694 - 695 Example: - 696 >>> condition("x=1").not_().sql() - 697 'NOT x = 1' - 698 - 699 Returns: - 700 Not: the new condition. - 701 """ - 702 return not_(self) + 665 copy (bool): whether or not to copy the involved expressions (only applies to Expressions). + 666 opts (kwargs): other options to use to parse the input expressions. + 667 + 668 Returns: + 669 And: the new condition. + 670 """ + 671 return and_(self, *expressions, dialect=dialect, copy=copy, **opts) + 672 + 673 def or_(self, *expressions, dialect=None, copy=True, **opts): + 674 """ + 675 OR this condition with one or multiple expressions. + 676 + 677 Example: + 678 >>> condition("x=1").or_("y=1").sql() + 679 'x = 1 OR y = 1' + 680 + 681 Args: + 682 *expressions (str | Expression): the SQL code strings to parse. + 683 If an `Expression` instance is passed, it will be used as-is. + 684 dialect (str): the dialect used to parse the input expression. + 685 copy (bool): whether or not to copy the involved expressions (only applies to Expressions). + 686 opts (kwargs): other options to use to parse the input expressions. + 687 + 688 Returns: + 689 Or: the new condition. + 690 """ + 691 return or_(self, *expressions, dialect=dialect, copy=copy, **opts) + 692 + 693 def not_(self, copy=True): + 694 """ + 695 Wrap this condition with NOT. + 696 + 697 Example: + 698 >>> condition("x=1").not_().sql() + 699 'NOT x = 1' + 700 + 701 Args: + 702 copy (bool): whether or not to copy this object. 703 - 704 - 705class Predicate(Condition): - 706 """Relationships like x = y, x > 1, x >= y.""" - 707 + 704 Returns: + 705 Not: the new condition. + 706 """ + 707 return not_(self, copy=copy) 708 - 709class DerivedTable(Expression): - 710 @property - 711 def alias_column_names(self): - 712 table_alias = self.args.get("alias") - 713 if not table_alias: - 714 return [] - 715 column_list = table_alias.assert_is(TableAlias).args.get("columns") or [] - 716 return [c.name for c in column_list] - 717 - 718 @property - 719 def selects(self): - 720 alias = self.args.get("alias") - 721 - 722 if alias: - 723 return alias.columns - 724 return [] - 725 - 726 @property - 727 def named_selects(self): - 728 return [select.output_name for select in self.selects] - 729 - 730 - 731class Unionable(Expression): - 732 def union(self, expression, distinct=True, dialect=None, **opts): - 733 """ - 734 Builds a UNION expression. - 735 - 736 Example: - 737 >>> import sqlglot - 738 >>> sqlglot.parse_one("SELECT * FROM foo").union("SELECT * FROM bla").sql() - 739 'SELECT * FROM foo UNION SELECT * FROM bla' - 740 - 741 Args: - 742 expression (str | Expression): the SQL code string. - 743 If an `Expression` instance is passed, it will be used as-is. - 744 distinct (bool): set the DISTINCT flag if and only if this is true. - 745 dialect (str): the dialect used to parse the input expression. - 746 opts (kwargs): other options to use to parse the input expressions. - 747 Returns: - 748 Union: the Union expression. - 749 """ - 750 return union(left=self, right=expression, distinct=distinct, dialect=dialect, **opts) + 709 def _binop(self, klass: t.Type[E], other: ExpOrStr, reverse=False) -> E: + 710 this = self.copy() + 711 other = convert(other, copy=True) + 712 if not isinstance(this, klass) and not isinstance(other, klass): + 713 this = _wrap(this, Binary) + 714 other = _wrap(other, Binary) + 715 if reverse: + 716 return klass(this=other, expression=this) + 717 return klass(this=this, expression=other) + 718 + 719 def __getitem__(self, other: ExpOrStr | t.Tuple[ExpOrStr]): + 720 return Bracket( + 721 this=self.copy(), expressions=[convert(e, copy=True) for e in ensure_list(other)] + 722 ) + 723 + 724 def isin( + 725 self, *expressions: t.Any, query: t.Optional[ExpOrStr] = None, copy=True, **opts + 726 ) -> In: + 727 return In( + 728 this=_maybe_copy(self, copy), + 729 expressions=[convert(e, copy=copy) for e in expressions], + 730 query=maybe_parse(query, copy=copy, **opts) if query else None, + 731 ) + 732 + 733 def between(self, low: t.Any, high: t.Any, copy=True, **opts) -> Between: + 734 return Between( + 735 this=_maybe_copy(self, copy), + 736 low=convert(low, copy=copy, **opts), + 737 high=convert(high, copy=copy, **opts), + 738 ) + 739 + 740 def like(self, other: ExpOrStr) -> Like: + 741 return self._binop(Like, other) + 742 + 743 def ilike(self, other: ExpOrStr) -> ILike: + 744 return self._binop(ILike, other) + 745 + 746 def eq(self, other: ExpOrStr) -> EQ: + 747 return self._binop(EQ, other) + 748 + 749 def neq(self, other: ExpOrStr) -> NEQ: + 750 return self._binop(NEQ, other) 751 - 752 def intersect(self, expression, distinct=True, dialect=None, **opts): - 753 """ - 754 Builds an INTERSECT expression. - 755 - 756 Example: - 757 >>> import sqlglot - 758 >>> sqlglot.parse_one("SELECT * FROM foo").intersect("SELECT * FROM bla").sql() - 759 'SELECT * FROM foo INTERSECT SELECT * FROM bla' + 752 def rlike(self, other: ExpOrStr) -> RegexpLike: + 753 return self._binop(RegexpLike, other) + 754 + 755 def __lt__(self, other: ExpOrStr) -> LT: + 756 return self._binop(LT, other) + 757 + 758 def __le__(self, other: ExpOrStr) -> LTE: + 759 return self._binop(LTE, other) 760 - 761 Args: - 762 expression (str | Expression): the SQL code string. - 763 If an `Expression` instance is passed, it will be used as-is. - 764 distinct (bool): set the DISTINCT flag if and only if this is true. - 765 dialect (str): the dialect used to parse the input expression. - 766 opts (kwargs): other options to use to parse the input expressions. - 767 Returns: - 768 Intersect: the Intersect expression - 769 """ - 770 return intersect(left=self, right=expression, distinct=distinct, dialect=dialect, **opts) - 771 - 772 def except_(self, expression, distinct=True, dialect=None, **opts): - 773 """ - 774 Builds an EXCEPT expression. + 761 def __gt__(self, other: ExpOrStr) -> GT: + 762 return self._binop(GT, other) + 763 + 764 def __ge__(self, other: ExpOrStr) -> GTE: + 765 return self._binop(GTE, other) + 766 + 767 def __add__(self, other: ExpOrStr) -> Add: + 768 return self._binop(Add, other) + 769 + 770 def __radd__(self, other: ExpOrStr) -> Add: + 771 return self._binop(Add, other, reverse=True) + 772 + 773 def __sub__(self, other: ExpOrStr) -> Sub: + 774 return self._binop(Sub, other) 775 - 776 Example: - 777 >>> import sqlglot - 778 >>> sqlglot.parse_one("SELECT * FROM foo").except_("SELECT * FROM bla").sql() - 779 'SELECT * FROM foo EXCEPT SELECT * FROM bla' - 780 - 781 Args: - 782 expression (str | Expression): the SQL code string. - 783 If an `Expression` instance is passed, it will be used as-is. - 784 distinct (bool): set the DISTINCT flag if and only if this is true. - 785 dialect (str): the dialect used to parse the input expression. - 786 opts (kwargs): other options to use to parse the input expressions. - 787 Returns: - 788 Except: the Except expression - 789 """ - 790 return except_(left=self, right=expression, distinct=distinct, dialect=dialect, **opts) - 791 - 792 - 793class UDTF(DerivedTable, Unionable): - 794 pass - 795 + 776 def __rsub__(self, other: ExpOrStr) -> Sub: + 777 return self._binop(Sub, other, reverse=True) + 778 + 779 def __mul__(self, other: ExpOrStr) -> Mul: + 780 return self._binop(Mul, other) + 781 + 782 def __rmul__(self, other: ExpOrStr) -> Mul: + 783 return self._binop(Mul, other, reverse=True) + 784 + 785 def __truediv__(self, other: ExpOrStr) -> Div: + 786 return self._binop(Div, other) + 787 + 788 def __rtruediv__(self, other: ExpOrStr) -> Div: + 789 return self._binop(Div, other, reverse=True) + 790 + 791 def __floordiv__(self, other: ExpOrStr) -> IntDiv: + 792 return self._binop(IntDiv, other) + 793 + 794 def __rfloordiv__(self, other: ExpOrStr) -> IntDiv: + 795 return self._binop(IntDiv, other, reverse=True) 796 - 797class Cache(Expression): - 798 arg_types = { - 799 "with": False, - 800 "this": True, - 801 "lazy": False, - 802 "options": False, - 803 "expression": False, - 804 } + 797 def __mod__(self, other: ExpOrStr) -> Mod: + 798 return self._binop(Mod, other) + 799 + 800 def __rmod__(self, other: ExpOrStr) -> Mod: + 801 return self._binop(Mod, other, reverse=True) + 802 + 803 def __pow__(self, other: ExpOrStr) -> Pow: + 804 return self._binop(Pow, other) 805 - 806 - 807class Uncache(Expression): - 808 arg_types = {"this": True, "exists": False} - 809 - 810 - 811class Create(Expression): - 812 arg_types = { - 813 "with": False, - 814 "this": True, - 815 "kind": True, - 816 "expression": False, - 817 "exists": False, - 818 "properties": False, - 819 "replace": False, - 820 "unique": False, - 821 "indexes": False, - 822 "no_schema_binding": False, - 823 "begin": False, - 824 } - 825 + 806 def __rpow__(self, other: ExpOrStr) -> Pow: + 807 return self._binop(Pow, other, reverse=True) + 808 + 809 def __and__(self, other: ExpOrStr) -> And: + 810 return self._binop(And, other) + 811 + 812 def __rand__(self, other: ExpOrStr) -> And: + 813 return self._binop(And, other, reverse=True) + 814 + 815 def __or__(self, other: ExpOrStr) -> Or: + 816 return self._binop(Or, other) + 817 + 818 def __ror__(self, other: ExpOrStr) -> Or: + 819 return self._binop(Or, other, reverse=True) + 820 + 821 def __neg__(self) -> Neg: + 822 return Neg(this=_wrap(self.copy(), Binary)) + 823 + 824 def __invert__(self) -> Not: + 825 return not_(self.copy()) 826 - 827class Describe(Expression): - 828 arg_types = {"this": True, "kind": False} - 829 + 827 + 828class Predicate(Condition): + 829 """Relationships like x = y, x > 1, x >= y.""" 830 - 831class Pragma(Expression): - 832 pass - 833 - 834 - 835class Set(Expression): - 836 arg_types = {"expressions": False} - 837 - 838 - 839class SetItem(Expression): - 840 arg_types = { - 841 "this": False, - 842 "expressions": False, - 843 "kind": False, - 844 "collate": False, # MySQL SET NAMES statement - 845 "global": False, - 846 } - 847 + 831 + 832class DerivedTable(Expression): + 833 @property + 834 def alias_column_names(self): + 835 table_alias = self.args.get("alias") + 836 if not table_alias: + 837 return [] + 838 column_list = table_alias.assert_is(TableAlias).args.get("columns") or [] + 839 return [c.name for c in column_list] + 840 + 841 @property + 842 def selects(self): + 843 alias = self.args.get("alias") + 844 + 845 if alias: + 846 return alias.columns + 847 return [] 848 - 849class Show(Expression): - 850 arg_types = { - 851 "this": True, - 852 "target": False, - 853 "offset": False, - 854 "limit": False, - 855 "like": False, - 856 "where": False, - 857 "db": False, - 858 "full": False, - 859 "mutex": False, - 860 "query": False, - 861 "channel": False, - 862 "global": False, - 863 "log": False, - 864 "position": False, - 865 "types": False, - 866 } - 867 - 868 - 869class UserDefinedFunction(Expression): - 870 arg_types = {"this": True, "expressions": False, "wrapped": False} - 871 - 872 - 873class CharacterSet(Expression): - 874 arg_types = {"this": True, "default": False} - 875 - 876 - 877class With(Expression): - 878 arg_types = {"expressions": True, "recursive": False} - 879 - 880 @property - 881 def recursive(self) -> bool: - 882 return bool(self.args.get("recursive")) + 849 @property + 850 def named_selects(self): + 851 return [select.output_name for select in self.selects] + 852 + 853 + 854class Unionable(Expression): + 855 def union(self, expression, distinct=True, dialect=None, **opts): + 856 """ + 857 Builds a UNION expression. + 858 + 859 Example: + 860 >>> import sqlglot + 861 >>> sqlglot.parse_one("SELECT * FROM foo").union("SELECT * FROM bla").sql() + 862 'SELECT * FROM foo UNION SELECT * FROM bla' + 863 + 864 Args: + 865 expression (str | Expression): the SQL code string. + 866 If an `Expression` instance is passed, it will be used as-is. + 867 distinct (bool): set the DISTINCT flag if and only if this is true. + 868 dialect (str): the dialect used to parse the input expression. + 869 opts (kwargs): other options to use to parse the input expressions. + 870 Returns: + 871 Union: the Union expression. + 872 """ + 873 return union(left=self, right=expression, distinct=distinct, dialect=dialect, **opts) + 874 + 875 def intersect(self, expression, distinct=True, dialect=None, **opts): + 876 """ + 877 Builds an INTERSECT expression. + 878 + 879 Example: + 880 >>> import sqlglot + 881 >>> sqlglot.parse_one("SELECT * FROM foo").intersect("SELECT * FROM bla").sql() + 882 'SELECT * FROM foo INTERSECT SELECT * FROM bla' 883 - 884 - 885class WithinGroup(Expression): - 886 arg_types = {"this": True, "expression": False} - 887 - 888 - 889class CTE(DerivedTable): - 890 arg_types = {"this": True, "alias": True} - 891 - 892 - 893class TableAlias(Expression): - 894 arg_types = {"this": False, "columns": False} - 895 - 896 @property - 897 def columns(self): - 898 return self.args.get("columns") or [] - 899 - 900 - 901class BitString(Condition): - 902 pass + 884 Args: + 885 expression (str | Expression): the SQL code string. + 886 If an `Expression` instance is passed, it will be used as-is. + 887 distinct (bool): set the DISTINCT flag if and only if this is true. + 888 dialect (str): the dialect used to parse the input expression. + 889 opts (kwargs): other options to use to parse the input expressions. + 890 Returns: + 891 Intersect: the Intersect expression + 892 """ + 893 return intersect(left=self, right=expression, distinct=distinct, dialect=dialect, **opts) + 894 + 895 def except_(self, expression, distinct=True, dialect=None, **opts): + 896 """ + 897 Builds an EXCEPT expression. + 898 + 899 Example: + 900 >>> import sqlglot + 901 >>> sqlglot.parse_one("SELECT * FROM foo").except_("SELECT * FROM bla").sql() + 902 'SELECT * FROM foo EXCEPT SELECT * FROM bla' 903 - 904 - 905class HexString(Condition): - 906 pass - 907 - 908 - 909class ByteString(Condition): - 910 pass - 911 - 912 - 913class Column(Condition): - 914 arg_types = {"this": True, "table": False, "db": False, "catalog": False, "join_mark": False} + 904 Args: + 905 expression (str | Expression): the SQL code string. + 906 If an `Expression` instance is passed, it will be used as-is. + 907 distinct (bool): set the DISTINCT flag if and only if this is true. + 908 dialect (str): the dialect used to parse the input expression. + 909 opts (kwargs): other options to use to parse the input expressions. + 910 Returns: + 911 Except: the Except expression + 912 """ + 913 return except_(left=self, right=expression, distinct=distinct, dialect=dialect, **opts) + 914 915 - 916 @property - 917 def table(self) -> str: - 918 return self.text("table") + 916class UDTF(DerivedTable, Unionable): + 917 pass + 918 919 - 920 @property - 921 def db(self) -> str: - 922 return self.text("db") - 923 - 924 @property - 925 def catalog(self) -> str: - 926 return self.text("catalog") - 927 - 928 @property - 929 def output_name(self) -> str: - 930 return self.name - 931 - 932 @property - 933 def parts(self) -> t.List[Identifier]: - 934 """Return the parts of a column in order catalog, db, table, name.""" - 935 return [part for part in reversed(list(self.args.values())) if part] - 936 - 937 def to_dot(self) -> Dot: - 938 """Converts the column into a dot expression.""" - 939 parts = self.parts - 940 parent = self.parent - 941 - 942 while parent: - 943 if isinstance(parent, Dot): - 944 parts.append(parent.expression) - 945 parent = parent.parent - 946 - 947 return Dot.build(parts) + 920class Cache(Expression): + 921 arg_types = { + 922 "with": False, + 923 "this": True, + 924 "lazy": False, + 925 "options": False, + 926 "expression": False, + 927 } + 928 + 929 + 930class Uncache(Expression): + 931 arg_types = {"this": True, "exists": False} + 932 + 933 + 934class Create(Expression): + 935 arg_types = { + 936 "with": False, + 937 "this": True, + 938 "kind": True, + 939 "expression": False, + 940 "exists": False, + 941 "properties": False, + 942 "replace": False, + 943 "unique": False, + 944 "indexes": False, + 945 "no_schema_binding": False, + 946 "begin": False, + 947 } 948 949 - 950class ColumnPosition(Expression): - 951 arg_types = {"this": False, "position": True} + 950class Describe(Expression): + 951 arg_types = {"this": True, "kind": False} 952 953 - 954class ColumnDef(Expression): - 955 arg_types = { - 956 "this": True, - 957 "kind": False, - 958 "constraints": False, - 959 "exists": False, - 960 "position": False, - 961 } - 962 - 963 - 964class AlterColumn(Expression): - 965 arg_types = { - 966 "this": True, - 967 "dtype": False, - 968 "collate": False, - 969 "using": False, - 970 "default": False, - 971 "drop": False, - 972 } - 973 - 974 - 975class RenameTable(Expression): - 976 pass - 977 - 978 - 979class SetTag(Expression): - 980 arg_types = {"expressions": True, "unset": False} - 981 - 982 - 983class Comment(Expression): - 984 arg_types = {"this": True, "kind": True, "expression": True, "exists": False} - 985 - 986 - 987class ColumnConstraint(Expression): - 988 arg_types = {"this": False, "kind": True} - 989 + 954class Pragma(Expression): + 955 pass + 956 + 957 + 958class Set(Expression): + 959 arg_types = {"expressions": False} + 960 + 961 + 962class SetItem(Expression): + 963 arg_types = { + 964 "this": False, + 965 "expressions": False, + 966 "kind": False, + 967 "collate": False, # MySQL SET NAMES statement + 968 "global": False, + 969 } + 970 + 971 + 972class Show(Expression): + 973 arg_types = { + 974 "this": True, + 975 "target": False, + 976 "offset": False, + 977 "limit": False, + 978 "like": False, + 979 "where": False, + 980 "db": False, + 981 "full": False, + 982 "mutex": False, + 983 "query": False, + 984 "channel": False, + 985 "global": False, + 986 "log": False, + 987 "position": False, + 988 "types": False, + 989 } 990 - 991class ColumnConstraintKind(Expression): - 992 pass - 993 + 991 + 992class UserDefinedFunction(Expression): + 993 arg_types = {"this": True, "expressions": False, "wrapped": False} 994 - 995class AutoIncrementColumnConstraint(ColumnConstraintKind): - 996 pass - 997 + 995 + 996class CharacterSet(Expression): + 997 arg_types = {"this": True, "default": False} 998 - 999class CaseSpecificColumnConstraint(ColumnConstraintKind): -1000 arg_types = {"not_": True} -1001 + 999 +1000class With(Expression): +1001 arg_types = {"expressions": True, "recursive": False} 1002 -1003class CharacterSetColumnConstraint(ColumnConstraintKind): -1004 arg_types = {"this": True} -1005 +1003 @property +1004 def recursive(self) -> bool: +1005 return bool(self.args.get("recursive")) 1006 -1007class CheckColumnConstraint(ColumnConstraintKind): -1008 pass -1009 +1007 +1008class WithinGroup(Expression): +1009 arg_types = {"this": True, "expression": False} 1010 -1011class CollateColumnConstraint(ColumnConstraintKind): -1012 pass -1013 +1011 +1012class CTE(DerivedTable): +1013 arg_types = {"this": True, "alias": True} 1014 -1015class CommentColumnConstraint(ColumnConstraintKind): -1016 pass -1017 +1015 +1016class TableAlias(Expression): +1017 arg_types = {"this": False, "columns": False} 1018 -1019class CompressColumnConstraint(ColumnConstraintKind): -1020 pass -1021 +1019 @property +1020 def columns(self): +1021 return self.args.get("columns") or [] 1022 -1023class DateFormatColumnConstraint(ColumnConstraintKind): -1024 arg_types = {"this": True} -1025 +1023 +1024class BitString(Condition): +1025 pass 1026 -1027class DefaultColumnConstraint(ColumnConstraintKind): -1028 pass -1029 +1027 +1028class HexString(Condition): +1029 pass 1030 -1031class EncodeColumnConstraint(ColumnConstraintKind): -1032 pass -1033 +1031 +1032class ByteString(Condition): +1033 pass 1034 -1035class GeneratedAsIdentityColumnConstraint(ColumnConstraintKind): -1036 # this: True -> ALWAYS, this: False -> BY DEFAULT -1037 arg_types = { -1038 "this": False, -1039 "start": False, -1040 "increment": False, -1041 "minvalue": False, -1042 "maxvalue": False, -1043 "cycle": False, -1044 } -1045 +1035 +1036class Column(Condition): +1037 arg_types = {"this": True, "table": False, "db": False, "catalog": False, "join_mark": False} +1038 +1039 @property +1040 def table(self) -> str: +1041 return self.text("table") +1042 +1043 @property +1044 def db(self) -> str: +1045 return self.text("db") 1046 -1047class InlineLengthColumnConstraint(ColumnConstraintKind): -1048 pass -1049 +1047 @property +1048 def catalog(self) -> str: +1049 return self.text("catalog") 1050 -1051class NotNullColumnConstraint(ColumnConstraintKind): -1052 arg_types = {"allow_null": False} -1053 +1051 @property +1052 def output_name(self) -> str: +1053 return self.name 1054 -1055# https://dev.mysql.com/doc/refman/5.7/en/timestamp-initialization.html -1056class OnUpdateColumnConstraint(ColumnConstraintKind): -1057 pass -1058 +1055 @property +1056 def parts(self) -> t.List[Identifier]: +1057 """Return the parts of a column in order catalog, db, table, name.""" +1058 return [part for part in reversed(list(self.args.values())) if part] 1059 -1060class PrimaryKeyColumnConstraint(ColumnConstraintKind): -1061 arg_types = {"desc": False} -1062 -1063 -1064class TitleColumnConstraint(ColumnConstraintKind): -1065 pass -1066 -1067 -1068class UniqueColumnConstraint(ColumnConstraintKind): -1069 arg_types: t.Dict[str, t.Any] = {} -1070 +1060 def to_dot(self) -> Dot: +1061 """Converts the column into a dot expression.""" +1062 parts = self.parts +1063 parent = self.parent +1064 +1065 while parent: +1066 if isinstance(parent, Dot): +1067 parts.append(parent.expression) +1068 parent = parent.parent +1069 +1070 return Dot.build(parts) 1071 -1072class UppercaseColumnConstraint(ColumnConstraintKind): -1073 arg_types: t.Dict[str, t.Any] = {} -1074 +1072 +1073class ColumnPosition(Expression): +1074 arg_types = {"this": False, "position": True} 1075 -1076class PathColumnConstraint(ColumnConstraintKind): -1077 pass -1078 -1079 -1080class Constraint(Expression): -1081 arg_types = {"this": True, "expressions": True} -1082 -1083 -1084class Delete(Expression): -1085 arg_types = {"with": False, "this": False, "using": False, "where": False, "returning": False} +1076 +1077class ColumnDef(Expression): +1078 arg_types = { +1079 "this": True, +1080 "kind": False, +1081 "constraints": False, +1082 "exists": False, +1083 "position": False, +1084 } +1085 1086 -1087 def delete( -1088 self, -1089 table: ExpOrStr, -1090 dialect: DialectType = None, -1091 copy: bool = True, -1092 **opts, -1093 ) -> Delete: -1094 """ -1095 Create a DELETE expression or replace the table on an existing DELETE expression. +1087class AlterColumn(Expression): +1088 arg_types = { +1089 "this": True, +1090 "dtype": False, +1091 "collate": False, +1092 "using": False, +1093 "default": False, +1094 "drop": False, +1095 } 1096 -1097 Example: -1098 >>> delete("tbl").sql() -1099 'DELETE FROM tbl' +1097 +1098class RenameTable(Expression): +1099 pass 1100 -1101 Args: -1102 table: the table from which to delete. -1103 dialect: the dialect used to parse the input expression. -1104 copy: if `False`, modify this expression instance in-place. -1105 opts: other options to use to parse the input expressions. -1106 -1107 Returns: -1108 Delete: the modified expression. -1109 """ -1110 return _apply_builder( -1111 expression=table, -1112 instance=self, -1113 arg="this", -1114 dialect=dialect, -1115 into=Table, -1116 copy=copy, -1117 **opts, -1118 ) -1119 -1120 def where( -1121 self, -1122 *expressions: ExpOrStr, -1123 append: bool = True, -1124 dialect: DialectType = None, -1125 copy: bool = True, -1126 **opts, -1127 ) -> Delete: -1128 """ -1129 Append to or set the WHERE expressions. -1130 -1131 Example: -1132 >>> delete("tbl").where("x = 'a' OR x < 'b'").sql() -1133 "DELETE FROM tbl WHERE x = 'a' OR x < 'b'" -1134 -1135 Args: -1136 *expressions: the SQL code strings to parse. -1137 If an `Expression` instance is passed, it will be used as-is. -1138 Multiple expressions are combined with an AND operator. -1139 append: if `True`, AND the new expressions to any existing expression. -1140 Otherwise, this resets the expression. -1141 dialect: the dialect used to parse the input expressions. -1142 copy: if `False`, modify this expression instance in-place. -1143 opts: other options to use to parse the input expressions. +1101 +1102class SetTag(Expression): +1103 arg_types = {"expressions": True, "unset": False} +1104 +1105 +1106class Comment(Expression): +1107 arg_types = {"this": True, "kind": True, "expression": True, "exists": False} +1108 +1109 +1110class ColumnConstraint(Expression): +1111 arg_types = {"this": False, "kind": True} +1112 +1113 +1114class ColumnConstraintKind(Expression): +1115 pass +1116 +1117 +1118class AutoIncrementColumnConstraint(ColumnConstraintKind): +1119 pass +1120 +1121 +1122class CaseSpecificColumnConstraint(ColumnConstraintKind): +1123 arg_types = {"not_": True} +1124 +1125 +1126class CharacterSetColumnConstraint(ColumnConstraintKind): +1127 arg_types = {"this": True} +1128 +1129 +1130class CheckColumnConstraint(ColumnConstraintKind): +1131 pass +1132 +1133 +1134class CollateColumnConstraint(ColumnConstraintKind): +1135 pass +1136 +1137 +1138class CommentColumnConstraint(ColumnConstraintKind): +1139 pass +1140 +1141 +1142class CompressColumnConstraint(ColumnConstraintKind): +1143 pass 1144 -1145 Returns: -1146 Delete: the modified expression. -1147 """ -1148 return _apply_conjunction_builder( -1149 *expressions, -1150 instance=self, -1151 arg="where", -1152 append=append, -1153 into=Where, -1154 dialect=dialect, -1155 copy=copy, -1156 **opts, -1157 ) -1158 -1159 def returning( -1160 self, -1161 expression: ExpOrStr, -1162 dialect: DialectType = None, -1163 copy: bool = True, -1164 **opts, -1165 ) -> Delete: -1166 """ -1167 Set the RETURNING expression. Not supported by all dialects. +1145 +1146class DateFormatColumnConstraint(ColumnConstraintKind): +1147 arg_types = {"this": True} +1148 +1149 +1150class DefaultColumnConstraint(ColumnConstraintKind): +1151 pass +1152 +1153 +1154class EncodeColumnConstraint(ColumnConstraintKind): +1155 pass +1156 +1157 +1158class GeneratedAsIdentityColumnConstraint(ColumnConstraintKind): +1159 # this: True -> ALWAYS, this: False -> BY DEFAULT +1160 arg_types = { +1161 "this": False, +1162 "start": False, +1163 "increment": False, +1164 "minvalue": False, +1165 "maxvalue": False, +1166 "cycle": False, +1167 } 1168 -1169 Example: -1170 >>> delete("tbl").returning("*", dialect="postgres").sql() -1171 'DELETE FROM tbl RETURNING *' +1169 +1170class InlineLengthColumnConstraint(ColumnConstraintKind): +1171 pass 1172 -1173 Args: -1174 expression: the SQL code strings to parse. -1175 If an `Expression` instance is passed, it will be used as-is. -1176 dialect: the dialect used to parse the input expressions. -1177 copy: if `False`, modify this expression instance in-place. -1178 opts: other options to use to parse the input expressions. -1179 -1180 Returns: -1181 Delete: the modified expression. -1182 """ -1183 return _apply_builder( -1184 expression=expression, -1185 instance=self, -1186 arg="returning", -1187 prefix="RETURNING", -1188 dialect=dialect, -1189 copy=copy, -1190 into=Returning, -1191 **opts, -1192 ) +1173 +1174class NotNullColumnConstraint(ColumnConstraintKind): +1175 arg_types = {"allow_null": False} +1176 +1177 +1178# https://dev.mysql.com/doc/refman/5.7/en/timestamp-initialization.html +1179class OnUpdateColumnConstraint(ColumnConstraintKind): +1180 pass +1181 +1182 +1183class PrimaryKeyColumnConstraint(ColumnConstraintKind): +1184 arg_types = {"desc": False} +1185 +1186 +1187class TitleColumnConstraint(ColumnConstraintKind): +1188 pass +1189 +1190 +1191class UniqueColumnConstraint(ColumnConstraintKind): +1192 arg_types: t.Dict[str, t.Any] = {} 1193 1194 -1195class Drop(Expression): -1196 arg_types = { -1197 "this": False, -1198 "kind": False, -1199 "exists": False, -1200 "temporary": False, -1201 "materialized": False, -1202 "cascade": False, -1203 "constraints": False, -1204 "purge": False, -1205 } +1195class UppercaseColumnConstraint(ColumnConstraintKind): +1196 arg_types: t.Dict[str, t.Any] = {} +1197 +1198 +1199class PathColumnConstraint(ColumnConstraintKind): +1200 pass +1201 +1202 +1203class Constraint(Expression): +1204 arg_types = {"this": True, "expressions": True} +1205 1206 -1207 -1208class Filter(Expression): -1209 arg_types = {"this": True, "expression": True} -1210 -1211 -1212class Check(Expression): -1213 pass -1214 -1215 -1216class Directory(Expression): -1217 # https://spark.apache.org/docs/3.0.0-preview/sql-ref-syntax-dml-insert-overwrite-directory-hive.html -1218 arg_types = {"this": True, "local": False, "row_format": False} +1207class Delete(Expression): +1208 arg_types = {"with": False, "this": False, "using": False, "where": False, "returning": False} +1209 +1210 def delete( +1211 self, +1212 table: ExpOrStr, +1213 dialect: DialectType = None, +1214 copy: bool = True, +1215 **opts, +1216 ) -> Delete: +1217 """ +1218 Create a DELETE expression or replace the table on an existing DELETE expression. 1219 -1220 -1221class ForeignKey(Expression): -1222 arg_types = { -1223 "expressions": True, -1224 "reference": False, -1225 "delete": False, -1226 "update": False, -1227 } -1228 +1220 Example: +1221 >>> delete("tbl").sql() +1222 'DELETE FROM tbl' +1223 +1224 Args: +1225 table: the table from which to delete. +1226 dialect: the dialect used to parse the input expression. +1227 copy: if `False`, modify this expression instance in-place. +1228 opts: other options to use to parse the input expressions. 1229 -1230class PrimaryKey(Expression): -1231 arg_types = {"expressions": True, "options": False} -1232 -1233 -1234class Unique(Expression): -1235 arg_types = {"expressions": True} -1236 -1237 -1238# https://www.postgresql.org/docs/9.1/sql-selectinto.html -1239# https://docs.aws.amazon.com/redshift/latest/dg/r_SELECT_INTO.html#r_SELECT_INTO-examples -1240class Into(Expression): -1241 arg_types = {"this": True, "temporary": False, "unlogged": False} +1230 Returns: +1231 Delete: the modified expression. +1232 """ +1233 return _apply_builder( +1234 expression=table, +1235 instance=self, +1236 arg="this", +1237 dialect=dialect, +1238 into=Table, +1239 copy=copy, +1240 **opts, +1241 ) 1242 -1243 -1244class From(Expression): -1245 arg_types = {"expressions": True} -1246 -1247 -1248class Having(Expression): -1249 pass -1250 -1251 -1252class Hint(Expression): -1253 arg_types = {"expressions": True} -1254 -1255 -1256class JoinHint(Expression): -1257 arg_types = {"this": True, "expressions": True} -1258 -1259 -1260class Identifier(Expression): -1261 arg_types = {"this": True, "quoted": False} -1262 -1263 @property -1264 def quoted(self): -1265 return bool(self.args.get("quoted")) -1266 -1267 @property -1268 def hashable_args(self) -> t.Any: -1269 if self.quoted and any(char.isupper() for char in self.this): -1270 return (self.this, self.quoted) -1271 return self.this.lower() -1272 -1273 @property -1274 def output_name(self): -1275 return self.name -1276 -1277 -1278class Index(Expression): -1279 arg_types = { -1280 "this": False, -1281 "table": False, -1282 "where": False, -1283 "columns": False, -1284 "unique": False, -1285 "primary": False, -1286 "amp": False, # teradata -1287 } -1288 -1289 -1290class Insert(Expression): -1291 arg_types = { -1292 "with": False, -1293 "this": True, -1294 "expression": False, -1295 "conflict": False, -1296 "returning": False, -1297 "overwrite": False, -1298 "exists": False, -1299 "partition": False, -1300 "alternative": False, -1301 } +1243 def where( +1244 self, +1245 *expressions: ExpOrStr, +1246 append: bool = True, +1247 dialect: DialectType = None, +1248 copy: bool = True, +1249 **opts, +1250 ) -> Delete: +1251 """ +1252 Append to or set the WHERE expressions. +1253 +1254 Example: +1255 >>> delete("tbl").where("x = 'a' OR x < 'b'").sql() +1256 "DELETE FROM tbl WHERE x = 'a' OR x < 'b'" +1257 +1258 Args: +1259 *expressions: the SQL code strings to parse. +1260 If an `Expression` instance is passed, it will be used as-is. +1261 Multiple expressions are combined with an AND operator. +1262 append: if `True`, AND the new expressions to any existing expression. +1263 Otherwise, this resets the expression. +1264 dialect: the dialect used to parse the input expressions. +1265 copy: if `False`, modify this expression instance in-place. +1266 opts: other options to use to parse the input expressions. +1267 +1268 Returns: +1269 Delete: the modified expression. +1270 """ +1271 return _apply_conjunction_builder( +1272 *expressions, +1273 instance=self, +1274 arg="where", +1275 append=append, +1276 into=Where, +1277 dialect=dialect, +1278 copy=copy, +1279 **opts, +1280 ) +1281 +1282 def returning( +1283 self, +1284 expression: ExpOrStr, +1285 dialect: DialectType = None, +1286 copy: bool = True, +1287 **opts, +1288 ) -> Delete: +1289 """ +1290 Set the RETURNING expression. Not supported by all dialects. +1291 +1292 Example: +1293 >>> delete("tbl").returning("*", dialect="postgres").sql() +1294 'DELETE FROM tbl RETURNING *' +1295 +1296 Args: +1297 expression: the SQL code strings to parse. +1298 If an `Expression` instance is passed, it will be used as-is. +1299 dialect: the dialect used to parse the input expressions. +1300 copy: if `False`, modify this expression instance in-place. +1301 opts: other options to use to parse the input expressions. 1302 -1303 -1304class OnConflict(Expression): -1305 arg_types = { -1306 "duplicate": False, -1307 "expressions": False, -1308 "nothing": False, -1309 "key": False, -1310 "constraint": False, -1311 } -1312 -1313 -1314class Returning(Expression): -1315 arg_types = {"expressions": True} +1303 Returns: +1304 Delete: the modified expression. +1305 """ +1306 return _apply_builder( +1307 expression=expression, +1308 instance=self, +1309 arg="returning", +1310 prefix="RETURNING", +1311 dialect=dialect, +1312 copy=copy, +1313 into=Returning, +1314 **opts, +1315 ) 1316 1317 -1318# https://dev.mysql.com/doc/refman/8.0/en/charset-introducer.html -1319class Introducer(Expression): -1320 arg_types = {"this": True, "expression": True} -1321 -1322 -1323# national char, like n'utf8' -1324class National(Expression): -1325 pass -1326 -1327 -1328class LoadData(Expression): -1329 arg_types = { -1330 "this": True, -1331 "local": False, -1332 "overwrite": False, -1333 "inpath": True, -1334 "partition": False, -1335 "input_format": False, -1336 "serde": False, -1337 } +1318class Drop(Expression): +1319 arg_types = { +1320 "this": False, +1321 "kind": False, +1322 "exists": False, +1323 "temporary": False, +1324 "materialized": False, +1325 "cascade": False, +1326 "constraints": False, +1327 "purge": False, +1328 } +1329 +1330 +1331class Filter(Expression): +1332 arg_types = {"this": True, "expression": True} +1333 +1334 +1335class Check(Expression): +1336 pass +1337 1338 -1339 -1340class Partition(Expression): -1341 arg_types = {"expressions": True} +1339class Directory(Expression): +1340 # https://spark.apache.org/docs/3.0.0-preview/sql-ref-syntax-dml-insert-overwrite-directory-hive.html +1341 arg_types = {"this": True, "local": False, "row_format": False} 1342 1343 -1344class Fetch(Expression): +1344class ForeignKey(Expression): 1345 arg_types = { -1346 "direction": False, -1347 "count": False, -1348 "percent": False, -1349 "with_ties": False, +1346 "expressions": True, +1347 "reference": False, +1348 "delete": False, +1349 "update": False, 1350 } 1351 1352 -1353class Group(Expression): -1354 arg_types = { -1355 "expressions": False, -1356 "grouping_sets": False, -1357 "cube": False, -1358 "rollup": False, -1359 } +1353class PrimaryKey(Expression): +1354 arg_types = {"expressions": True, "options": False} +1355 +1356 +1357class Unique(Expression): +1358 arg_types = {"expressions": True} +1359 1360 -1361 -1362class Lambda(Expression): -1363 arg_types = {"this": True, "expressions": True} -1364 +1361# https://www.postgresql.org/docs/9.1/sql-selectinto.html +1362# https://docs.aws.amazon.com/redshift/latest/dg/r_SELECT_INTO.html#r_SELECT_INTO-examples +1363class Into(Expression): +1364 arg_types = {"this": True, "temporary": False, "unlogged": False} 1365 -1366class Limit(Expression): -1367 arg_types = {"this": False, "expression": True} -1368 +1366 +1367class From(Expression): +1368 arg_types = {"expressions": True} 1369 -1370class Literal(Condition): -1371 arg_types = {"this": True, "is_string": True} -1372 -1373 @property -1374 def hashable_args(self) -> t.Any: -1375 return (self.this, self.args.get("is_string")) -1376 -1377 @classmethod -1378 def number(cls, number) -> Literal: -1379 return cls(this=str(number), is_string=False) -1380 -1381 @classmethod -1382 def string(cls, string) -> Literal: -1383 return cls(this=str(string), is_string=True) -1384 -1385 @property -1386 def output_name(self): -1387 return self.name -1388 +1370 +1371class Having(Expression): +1372 pass +1373 +1374 +1375class Hint(Expression): +1376 arg_types = {"expressions": True} +1377 +1378 +1379class JoinHint(Expression): +1380 arg_types = {"this": True, "expressions": True} +1381 +1382 +1383class Identifier(Expression): +1384 arg_types = {"this": True, "quoted": False} +1385 +1386 @property +1387 def quoted(self): +1388 return bool(self.args.get("quoted")) 1389 -1390class Join(Expression): -1391 arg_types = { -1392 "this": True, -1393 "on": False, -1394 "side": False, -1395 "kind": False, -1396 "using": False, -1397 "natural": False, -1398 "hint": False, -1399 } +1390 @property +1391 def hashable_args(self) -> t.Any: +1392 if self.quoted and any(char.isupper() for char in self.this): +1393 return (self.this, self.quoted) +1394 return self.this.lower() +1395 +1396 @property +1397 def output_name(self): +1398 return self.name +1399 1400 -1401 @property -1402 def kind(self): -1403 return self.text("kind").upper() -1404 -1405 @property -1406 def side(self): -1407 return self.text("side").upper() -1408 -1409 @property -1410 def hint(self): -1411 return self.text("hint").upper() +1401class Index(Expression): +1402 arg_types = { +1403 "this": False, +1404 "table": False, +1405 "where": False, +1406 "columns": False, +1407 "unique": False, +1408 "primary": False, +1409 "amp": False, # teradata +1410 } +1411 1412 -1413 @property -1414 def alias_or_name(self): -1415 return self.this.alias_or_name -1416 -1417 def on(self, *expressions, append=True, dialect=None, copy=True, **opts): -1418 """ -1419 Append to or set the ON expressions. -1420 -1421 Example: -1422 >>> import sqlglot -1423 >>> sqlglot.parse_one("JOIN x", into=Join).on("y = 1").sql() -1424 'JOIN x ON y = 1' +1413class Insert(Expression): +1414 arg_types = { +1415 "with": False, +1416 "this": True, +1417 "expression": False, +1418 "conflict": False, +1419 "returning": False, +1420 "overwrite": False, +1421 "exists": False, +1422 "partition": False, +1423 "alternative": False, +1424 } 1425 -1426 Args: -1427 *expressions (str | Expression): the SQL code strings to parse. -1428 If an `Expression` instance is passed, it will be used as-is. -1429 Multiple expressions are combined with an AND operator. -1430 append (bool): if `True`, AND the new expressions to any existing expression. -1431 Otherwise, this resets the expression. -1432 dialect (str): the dialect used to parse the input expressions. -1433 copy (bool): if `False`, modify this expression instance in-place. -1434 opts (kwargs): other options to use to parse the input expressions. +1426 +1427class OnConflict(Expression): +1428 arg_types = { +1429 "duplicate": False, +1430 "expressions": False, +1431 "nothing": False, +1432 "key": False, +1433 "constraint": False, +1434 } 1435 -1436 Returns: -1437 Join: the modified join expression. -1438 """ -1439 join = _apply_conjunction_builder( -1440 *expressions, -1441 instance=self, -1442 arg="on", -1443 append=append, -1444 dialect=dialect, -1445 copy=copy, -1446 **opts, -1447 ) -1448 -1449 if join.kind == "CROSS": -1450 join.set("kind", None) -1451 -1452 return join -1453 -1454 def using(self, *expressions, append=True, dialect=None, copy=True, **opts): -1455 """ -1456 Append to or set the USING expressions. -1457 -1458 Example: -1459 >>> import sqlglot -1460 >>> sqlglot.parse_one("JOIN x", into=Join).using("foo", "bla").sql() -1461 'JOIN x USING (foo, bla)' +1436 +1437class Returning(Expression): +1438 arg_types = {"expressions": True} +1439 +1440 +1441# https://dev.mysql.com/doc/refman/8.0/en/charset-introducer.html +1442class Introducer(Expression): +1443 arg_types = {"this": True, "expression": True} +1444 +1445 +1446# national char, like n'utf8' +1447class National(Expression): +1448 pass +1449 +1450 +1451class LoadData(Expression): +1452 arg_types = { +1453 "this": True, +1454 "local": False, +1455 "overwrite": False, +1456 "inpath": True, +1457 "partition": False, +1458 "input_format": False, +1459 "serde": False, +1460 } +1461 1462 -1463 Args: -1464 *expressions (str | Expression): the SQL code strings to parse. -1465 If an `Expression` instance is passed, it will be used as-is. -1466 append (bool): if `True`, concatenate the new expressions to the existing "using" list. -1467 Otherwise, this resets the expression. -1468 dialect (str): the dialect used to parse the input expressions. -1469 copy (bool): if `False`, modify this expression instance in-place. -1470 opts (kwargs): other options to use to parse the input expressions. -1471 -1472 Returns: -1473 Join: the modified join expression. -1474 """ -1475 join = _apply_list_builder( -1476 *expressions, -1477 instance=self, -1478 arg="using", -1479 append=append, -1480 dialect=dialect, -1481 copy=copy, -1482 **opts, -1483 ) +1463class Partition(Expression): +1464 arg_types = {"expressions": True} +1465 +1466 +1467class Fetch(Expression): +1468 arg_types = { +1469 "direction": False, +1470 "count": False, +1471 "percent": False, +1472 "with_ties": False, +1473 } +1474 +1475 +1476class Group(Expression): +1477 arg_types = { +1478 "expressions": False, +1479 "grouping_sets": False, +1480 "cube": False, +1481 "rollup": False, +1482 } +1483 1484 -1485 if join.kind == "CROSS": -1486 join.set("kind", None) +1485class Lambda(Expression): +1486 arg_types = {"this": True, "expressions": True} 1487 -1488 return join -1489 -1490 -1491class Lateral(UDTF): -1492 arg_types = {"this": True, "view": False, "outer": False, "alias": False} -1493 -1494 -1495class MatchRecognize(Expression): -1496 arg_types = { -1497 "partition_by": False, -1498 "order": False, -1499 "measures": False, -1500 "rows": False, -1501 "after": False, -1502 "pattern": False, -1503 "define": False, -1504 "alias": False, -1505 } -1506 +1488 +1489class Limit(Expression): +1490 arg_types = {"this": False, "expression": True} +1491 +1492 +1493class Literal(Condition): +1494 arg_types = {"this": True, "is_string": True} +1495 +1496 @property +1497 def hashable_args(self) -> t.Any: +1498 return (self.this, self.args.get("is_string")) +1499 +1500 @classmethod +1501 def number(cls, number) -> Literal: +1502 return cls(this=str(number), is_string=False) +1503 +1504 @classmethod +1505 def string(cls, string) -> Literal: +1506 return cls(this=str(string), is_string=True) 1507 -1508# Clickhouse FROM FINAL modifier -1509# https://clickhouse.com/docs/en/sql-reference/statements/select/from/#final-modifier -1510class Final(Expression): -1511 pass +1508 @property +1509 def output_name(self): +1510 return self.name +1511 1512 -1513 -1514class Offset(Expression): -1515 arg_types = {"this": False, "expression": True} -1516 -1517 -1518class Order(Expression): -1519 arg_types = {"this": False, "expressions": True} -1520 -1521 -1522# hive specific sorts -1523# https://cwiki.apache.org/confluence/display/Hive/LanguageManual+SortBy -1524class Cluster(Order): -1525 pass -1526 +1513class Join(Expression): +1514 arg_types = { +1515 "this": True, +1516 "on": False, +1517 "side": False, +1518 "kind": False, +1519 "using": False, +1520 "natural": False, +1521 "hint": False, +1522 } +1523 +1524 @property +1525 def kind(self): +1526 return self.text("kind").upper() 1527 -1528class Distribute(Order): -1529 pass -1530 +1528 @property +1529 def side(self): +1530 return self.text("side").upper() 1531 -1532class Sort(Order): -1533 pass -1534 +1532 @property +1533 def hint(self): +1534 return self.text("hint").upper() 1535 -1536class Ordered(Expression): -1537 arg_types = {"this": True, "desc": True, "nulls_first": True} -1538 +1536 @property +1537 def alias_or_name(self): +1538 return self.this.alias_or_name 1539 -1540class Property(Expression): -1541 arg_types = {"this": True, "value": True} -1542 +1540 def on(self, *expressions, append=True, dialect=None, copy=True, **opts): +1541 """ +1542 Append to or set the ON expressions. 1543 -1544class AfterJournalProperty(Property): -1545 arg_types = {"no": True, "dual": False, "local": False} -1546 -1547 -1548class AlgorithmProperty(Property): -1549 arg_types = {"this": True} -1550 -1551 -1552class AutoIncrementProperty(Property): -1553 arg_types = {"this": True} -1554 -1555 -1556class BlockCompressionProperty(Property): -1557 arg_types = {"autotemp": False, "always": False, "default": True, "manual": True, "never": True} +1544 Example: +1545 >>> import sqlglot +1546 >>> sqlglot.parse_one("JOIN x", into=Join).on("y = 1").sql() +1547 'JOIN x ON y = 1' +1548 +1549 Args: +1550 *expressions (str | Expression): the SQL code strings to parse. +1551 If an `Expression` instance is passed, it will be used as-is. +1552 Multiple expressions are combined with an AND operator. +1553 append (bool): if `True`, AND the new expressions to any existing expression. +1554 Otherwise, this resets the expression. +1555 dialect (str): the dialect used to parse the input expressions. +1556 copy (bool): if `False`, modify this expression instance in-place. +1557 opts (kwargs): other options to use to parse the input expressions. 1558 -1559 -1560class CharacterSetProperty(Property): -1561 arg_types = {"this": True, "default": True} -1562 -1563 -1564class ChecksumProperty(Property): -1565 arg_types = {"on": False, "default": False} -1566 -1567 -1568class CollateProperty(Property): -1569 arg_types = {"this": True} -1570 +1559 Returns: +1560 Join: the modified join expression. +1561 """ +1562 join = _apply_conjunction_builder( +1563 *expressions, +1564 instance=self, +1565 arg="on", +1566 append=append, +1567 dialect=dialect, +1568 copy=copy, +1569 **opts, +1570 ) 1571 -1572class DataBlocksizeProperty(Property): -1573 arg_types = {"size": False, "units": False, "min": False, "default": False} +1572 if join.kind == "CROSS": +1573 join.set("kind", None) 1574 -1575 -1576class DefinerProperty(Property): -1577 arg_types = {"this": True} -1578 -1579 -1580class DistKeyProperty(Property): -1581 arg_types = {"this": True} -1582 -1583 -1584class DistStyleProperty(Property): -1585 arg_types = {"this": True} -1586 -1587 -1588class EngineProperty(Property): -1589 arg_types = {"this": True} -1590 -1591 -1592class ExecuteAsProperty(Property): -1593 arg_types = {"this": True} +1575 return join +1576 +1577 def using(self, *expressions, append=True, dialect=None, copy=True, **opts): +1578 """ +1579 Append to or set the USING expressions. +1580 +1581 Example: +1582 >>> import sqlglot +1583 >>> sqlglot.parse_one("JOIN x", into=Join).using("foo", "bla").sql() +1584 'JOIN x USING (foo, bla)' +1585 +1586 Args: +1587 *expressions (str | Expression): the SQL code strings to parse. +1588 If an `Expression` instance is passed, it will be used as-is. +1589 append (bool): if `True`, concatenate the new expressions to the existing "using" list. +1590 Otherwise, this resets the expression. +1591 dialect (str): the dialect used to parse the input expressions. +1592 copy (bool): if `False`, modify this expression instance in-place. +1593 opts (kwargs): other options to use to parse the input expressions. 1594 -1595 -1596class ExternalProperty(Property): -1597 arg_types = {"this": False} -1598 -1599 -1600class FallbackProperty(Property): -1601 arg_types = {"no": True, "protection": False} -1602 -1603 -1604class FileFormatProperty(Property): -1605 arg_types = {"this": True} -1606 +1595 Returns: +1596 Join: the modified join expression. +1597 """ +1598 join = _apply_list_builder( +1599 *expressions, +1600 instance=self, +1601 arg="using", +1602 append=append, +1603 dialect=dialect, +1604 copy=copy, +1605 **opts, +1606 ) 1607 -1608class FreespaceProperty(Property): -1609 arg_types = {"this": True, "percent": False} +1608 if join.kind == "CROSS": +1609 join.set("kind", None) 1610 -1611 -1612class InputOutputFormat(Expression): -1613 arg_types = {"input_format": False, "output_format": False} -1614 -1615 -1616class IsolatedLoadingProperty(Property): -1617 arg_types = { -1618 "no": True, -1619 "concurrent": True, -1620 "for_all": True, -1621 "for_insert": True, -1622 "for_none": True, -1623 } -1624 -1625 -1626class JournalProperty(Property): -1627 arg_types = {"no": True, "dual": False, "before": False} -1628 +1611 return join +1612 +1613 +1614class Lateral(UDTF): +1615 arg_types = {"this": True, "view": False, "outer": False, "alias": False} +1616 +1617 +1618class MatchRecognize(Expression): +1619 arg_types = { +1620 "partition_by": False, +1621 "order": False, +1622 "measures": False, +1623 "rows": False, +1624 "after": False, +1625 "pattern": False, +1626 "define": False, +1627 "alias": False, +1628 } 1629 -1630class LanguageProperty(Property): -1631 arg_types = {"this": True} -1632 -1633 -1634class LikeProperty(Property): -1635 arg_types = {"this": True, "expressions": False} +1630 +1631# Clickhouse FROM FINAL modifier +1632# https://clickhouse.com/docs/en/sql-reference/statements/select/from/#final-modifier +1633class Final(Expression): +1634 pass +1635 1636 -1637 -1638class LocationProperty(Property): -1639 arg_types = {"this": True} +1637class Offset(Expression): +1638 arg_types = {"this": False, "expression": True} +1639 1640 -1641 -1642class LockingProperty(Property): -1643 arg_types = { -1644 "this": False, -1645 "kind": True, -1646 "for_or_in": True, -1647 "lock_type": True, -1648 "override": False, -1649 } +1641class Order(Expression): +1642 arg_types = {"this": False, "expressions": True} +1643 +1644 +1645# hive specific sorts +1646# https://cwiki.apache.org/confluence/display/Hive/LanguageManual+SortBy +1647class Cluster(Order): +1648 pass +1649 1650 -1651 -1652class LogProperty(Property): -1653 arg_types = {"no": True} +1651class Distribute(Order): +1652 pass +1653 1654 -1655 -1656class MaterializedProperty(Property): -1657 arg_types = {"this": False} +1655class Sort(Order): +1656 pass +1657 1658 -1659 -1660class MergeBlockRatioProperty(Property): -1661 arg_types = {"this": False, "no": False, "default": False, "percent": False} +1659class Ordered(Expression): +1660 arg_types = {"this": True, "desc": True, "nulls_first": True} +1661 1662 -1663 -1664class NoPrimaryIndexProperty(Property): -1665 arg_types = {"this": False} +1663class Property(Expression): +1664 arg_types = {"this": True, "value": True} +1665 1666 -1667 -1668class OnCommitProperty(Property): -1669 arg_type = {"this": False} +1667class AfterJournalProperty(Property): +1668 arg_types = {"no": True, "dual": False, "local": False} +1669 1670 -1671 -1672class PartitionedByProperty(Property): -1673 arg_types = {"this": True} +1671class AlgorithmProperty(Property): +1672 arg_types = {"this": True} +1673 1674 -1675 -1676class ReturnsProperty(Property): -1677 arg_types = {"this": True, "is_table": False, "table": False} +1675class AutoIncrementProperty(Property): +1676 arg_types = {"this": True} +1677 1678 -1679 -1680class RowFormatProperty(Property): -1681 arg_types = {"this": True} +1679class BlockCompressionProperty(Property): +1680 arg_types = {"autotemp": False, "always": False, "default": True, "manual": True, "never": True} +1681 1682 -1683 -1684class RowFormatDelimitedProperty(Property): -1685 # https://cwiki.apache.org/confluence/display/hive/languagemanual+dml -1686 arg_types = { -1687 "fields": False, -1688 "escaped": False, -1689 "collection_items": False, -1690 "map_keys": False, -1691 "lines": False, -1692 "null": False, -1693 "serde": False, -1694 } -1695 -1696 -1697class RowFormatSerdeProperty(Property): -1698 arg_types = {"this": True} -1699 -1700 -1701class SchemaCommentProperty(Property): -1702 arg_types = {"this": True} -1703 -1704 -1705class SerdeProperties(Property): -1706 arg_types = {"expressions": True} -1707 -1708 -1709class SetProperty(Property): -1710 arg_types = {"multi": True} -1711 -1712 -1713class SortKeyProperty(Property): -1714 arg_types = {"this": True, "compound": False} -1715 -1716 -1717class SqlSecurityProperty(Property): -1718 arg_types = {"definer": True} -1719 -1720 -1721class StabilityProperty(Property): -1722 arg_types = {"this": True} -1723 -1724 -1725class TableFormatProperty(Property): -1726 arg_types = {"this": True} -1727 -1728 -1729class TemporaryProperty(Property): -1730 arg_types = {"global_": True} -1731 -1732 -1733class TransientProperty(Property): -1734 arg_types = {"this": False} -1735 -1736 -1737class VolatileProperty(Property): -1738 arg_types = {"this": False} -1739 -1740 -1741class WithDataProperty(Property): -1742 arg_types = {"no": True, "statistics": False} -1743 -1744 -1745class WithJournalTableProperty(Property): -1746 arg_types = {"this": True} +1683class CharacterSetProperty(Property): +1684 arg_types = {"this": True, "default": True} +1685 +1686 +1687class ChecksumProperty(Property): +1688 arg_types = {"on": False, "default": False} +1689 +1690 +1691class CollateProperty(Property): +1692 arg_types = {"this": True} +1693 +1694 +1695class DataBlocksizeProperty(Property): +1696 arg_types = {"size": False, "units": False, "min": False, "default": False} +1697 +1698 +1699class DefinerProperty(Property): +1700 arg_types = {"this": True} +1701 +1702 +1703class DistKeyProperty(Property): +1704 arg_types = {"this": True} +1705 +1706 +1707class DistStyleProperty(Property): +1708 arg_types = {"this": True} +1709 +1710 +1711class EngineProperty(Property): +1712 arg_types = {"this": True} +1713 +1714 +1715class ExecuteAsProperty(Property): +1716 arg_types = {"this": True} +1717 +1718 +1719class ExternalProperty(Property): +1720 arg_types = {"this": False} +1721 +1722 +1723class FallbackProperty(Property): +1724 arg_types = {"no": True, "protection": False} +1725 +1726 +1727class FileFormatProperty(Property): +1728 arg_types = {"this": True} +1729 +1730 +1731class FreespaceProperty(Property): +1732 arg_types = {"this": True, "percent": False} +1733 +1734 +1735class InputOutputFormat(Expression): +1736 arg_types = {"input_format": False, "output_format": False} +1737 +1738 +1739class IsolatedLoadingProperty(Property): +1740 arg_types = { +1741 "no": True, +1742 "concurrent": True, +1743 "for_all": True, +1744 "for_insert": True, +1745 "for_none": True, +1746 } 1747 1748 -1749class Properties(Expression): -1750 arg_types = {"expressions": True} +1749class JournalProperty(Property): +1750 arg_types = {"no": True, "dual": False, "before": False} 1751 -1752 NAME_TO_PROPERTY = { -1753 "ALGORITHM": AlgorithmProperty, -1754 "AUTO_INCREMENT": AutoIncrementProperty, -1755 "CHARACTER SET": CharacterSetProperty, -1756 "COLLATE": CollateProperty, -1757 "COMMENT": SchemaCommentProperty, -1758 "DEFINER": DefinerProperty, -1759 "DISTKEY": DistKeyProperty, -1760 "DISTSTYLE": DistStyleProperty, -1761 "ENGINE": EngineProperty, -1762 "EXECUTE AS": ExecuteAsProperty, -1763 "FORMAT": FileFormatProperty, -1764 "LANGUAGE": LanguageProperty, -1765 "LOCATION": LocationProperty, -1766 "PARTITIONED_BY": PartitionedByProperty, -1767 "RETURNS": ReturnsProperty, -1768 "ROW_FORMAT": RowFormatProperty, -1769 "SORTKEY": SortKeyProperty, -1770 "TABLE_FORMAT": TableFormatProperty, -1771 } -1772 -1773 PROPERTY_TO_NAME = {v: k for k, v in NAME_TO_PROPERTY.items()} +1752 +1753class LanguageProperty(Property): +1754 arg_types = {"this": True} +1755 +1756 +1757class LikeProperty(Property): +1758 arg_types = {"this": True, "expressions": False} +1759 +1760 +1761class LocationProperty(Property): +1762 arg_types = {"this": True} +1763 +1764 +1765class LockingProperty(Property): +1766 arg_types = { +1767 "this": False, +1768 "kind": True, +1769 "for_or_in": True, +1770 "lock_type": True, +1771 "override": False, +1772 } +1773 1774 -1775 # CREATE property locations -1776 # Form: schema specified -1777 # create [POST_CREATE] -1778 # table a [POST_NAME] -1779 # (b int) [POST_SCHEMA] -1780 # with ([POST_WITH]) -1781 # index (b) [POST_INDEX] -1782 # -1783 # Form: alias selection -1784 # create [POST_CREATE] -1785 # table a [POST_NAME] -1786 # as [POST_ALIAS] (select * from b) [POST_EXPRESSION] -1787 # index (c) [POST_INDEX] -1788 class Location(AutoName): -1789 POST_CREATE = auto() -1790 POST_NAME = auto() -1791 POST_SCHEMA = auto() -1792 POST_WITH = auto() -1793 POST_ALIAS = auto() -1794 POST_EXPRESSION = auto() -1795 POST_INDEX = auto() -1796 UNSUPPORTED = auto() +1775class LogProperty(Property): +1776 arg_types = {"no": True} +1777 +1778 +1779class MaterializedProperty(Property): +1780 arg_types = {"this": False} +1781 +1782 +1783class MergeBlockRatioProperty(Property): +1784 arg_types = {"this": False, "no": False, "default": False, "percent": False} +1785 +1786 +1787class NoPrimaryIndexProperty(Property): +1788 arg_types = {"this": False} +1789 +1790 +1791class OnCommitProperty(Property): +1792 arg_type = {"this": False} +1793 +1794 +1795class PartitionedByProperty(Property): +1796 arg_types = {"this": True} 1797 -1798 @classmethod -1799 def from_dict(cls, properties_dict) -> Properties: -1800 expressions = [] -1801 for key, value in properties_dict.items(): -1802 property_cls = cls.NAME_TO_PROPERTY.get(key.upper()) -1803 if property_cls: -1804 expressions.append(property_cls(this=convert(value))) -1805 else: -1806 expressions.append(Property(this=Literal.string(key), value=convert(value))) -1807 -1808 return cls(expressions=expressions) -1809 -1810 -1811class Qualify(Expression): -1812 pass -1813 -1814 -1815# https://www.ibm.com/docs/en/ias?topic=procedures-return-statement-in-sql -1816class Return(Expression): -1817 pass +1798 +1799class ReturnsProperty(Property): +1800 arg_types = {"this": True, "is_table": False, "table": False} +1801 +1802 +1803class RowFormatProperty(Property): +1804 arg_types = {"this": True} +1805 +1806 +1807class RowFormatDelimitedProperty(Property): +1808 # https://cwiki.apache.org/confluence/display/hive/languagemanual+dml +1809 arg_types = { +1810 "fields": False, +1811 "escaped": False, +1812 "collection_items": False, +1813 "map_keys": False, +1814 "lines": False, +1815 "null": False, +1816 "serde": False, +1817 } 1818 1819 -1820class Reference(Expression): -1821 arg_types = {"this": True, "expressions": False, "options": False} +1820class RowFormatSerdeProperty(Property): +1821 arg_types = {"this": True} 1822 1823 -1824class Tuple(Expression): -1825 arg_types = {"expressions": False} +1824class SchemaCommentProperty(Property): +1825 arg_types = {"this": True} 1826 1827 -1828class Subqueryable(Unionable): -1829 def subquery(self, alias=None, copy=True) -> Subquery: -1830 """ -1831 Convert this expression to an aliased expression that can be used as a Subquery. -1832 -1833 Example: -1834 >>> subquery = Select().select("x").from_("tbl").subquery() -1835 >>> Select().select("x").from_(subquery).sql() -1836 'SELECT x FROM (SELECT x FROM tbl)' -1837 -1838 Args: -1839 alias (str | Identifier): an optional alias for the subquery -1840 copy (bool): if `False`, modify this expression instance in-place. -1841 -1842 Returns: -1843 Alias: the subquery -1844 """ -1845 instance = _maybe_copy(self, copy) -1846 return Subquery( -1847 this=instance, -1848 alias=TableAlias(this=to_identifier(alias)) if alias else None, -1849 ) +1828class SerdeProperties(Property): +1829 arg_types = {"expressions": True} +1830 +1831 +1832class SetProperty(Property): +1833 arg_types = {"multi": True} +1834 +1835 +1836class SortKeyProperty(Property): +1837 arg_types = {"this": True, "compound": False} +1838 +1839 +1840class SqlSecurityProperty(Property): +1841 arg_types = {"definer": True} +1842 +1843 +1844class StabilityProperty(Property): +1845 arg_types = {"this": True} +1846 +1847 +1848class TableFormatProperty(Property): +1849 arg_types = {"this": True} 1850 -1851 def limit(self, expression, dialect=None, copy=True, **opts) -> Select: -1852 raise NotImplementedError -1853 -1854 @property -1855 def ctes(self): -1856 with_ = self.args.get("with") -1857 if not with_: -1858 return [] -1859 return with_.expressions -1860 -1861 @property -1862 def selects(self): -1863 raise NotImplementedError("Subqueryable objects must implement `selects`") -1864 -1865 @property -1866 def named_selects(self): -1867 raise NotImplementedError("Subqueryable objects must implement `named_selects`") -1868 -1869 def with_( -1870 self, -1871 alias, -1872 as_, -1873 recursive=None, -1874 append=True, -1875 dialect=None, -1876 copy=True, -1877 **opts, -1878 ): -1879 """ -1880 Append to or set the common table expressions. -1881 -1882 Example: -1883 >>> Select().with_("tbl2", as_="SELECT * FROM tbl").select("x").from_("tbl2").sql() -1884 'WITH tbl2 AS (SELECT * FROM tbl) SELECT x FROM tbl2' -1885 -1886 Args: -1887 alias (str | Expression): the SQL code string to parse as the table name. -1888 If an `Expression` instance is passed, this is used as-is. -1889 as_ (str | Expression): the SQL code string to parse as the table expression. -1890 If an `Expression` instance is passed, it will be used as-is. -1891 recursive (bool): set the RECURSIVE part of the expression. Defaults to `False`. -1892 append (bool): if `True`, add to any existing expressions. -1893 Otherwise, this resets the expressions. -1894 dialect (str): the dialect used to parse the input expression. -1895 copy (bool): if `False`, modify this expression instance in-place. -1896 opts (kwargs): other options to use to parse the input expressions. +1851 +1852class TemporaryProperty(Property): +1853 arg_types = {"global_": True} +1854 +1855 +1856class TransientProperty(Property): +1857 arg_types = {"this": False} +1858 +1859 +1860class VolatileProperty(Property): +1861 arg_types = {"this": False} +1862 +1863 +1864class WithDataProperty(Property): +1865 arg_types = {"no": True, "statistics": False} +1866 +1867 +1868class WithJournalTableProperty(Property): +1869 arg_types = {"this": True} +1870 +1871 +1872class Properties(Expression): +1873 arg_types = {"expressions": True} +1874 +1875 NAME_TO_PROPERTY = { +1876 "ALGORITHM": AlgorithmProperty, +1877 "AUTO_INCREMENT": AutoIncrementProperty, +1878 "CHARACTER SET": CharacterSetProperty, +1879 "COLLATE": CollateProperty, +1880 "COMMENT": SchemaCommentProperty, +1881 "DEFINER": DefinerProperty, +1882 "DISTKEY": DistKeyProperty, +1883 "DISTSTYLE": DistStyleProperty, +1884 "ENGINE": EngineProperty, +1885 "EXECUTE AS": ExecuteAsProperty, +1886 "FORMAT": FileFormatProperty, +1887 "LANGUAGE": LanguageProperty, +1888 "LOCATION": LocationProperty, +1889 "PARTITIONED_BY": PartitionedByProperty, +1890 "RETURNS": ReturnsProperty, +1891 "ROW_FORMAT": RowFormatProperty, +1892 "SORTKEY": SortKeyProperty, +1893 "TABLE_FORMAT": TableFormatProperty, +1894 } +1895 +1896 PROPERTY_TO_NAME = {v: k for k, v in NAME_TO_PROPERTY.items()} 1897 -1898 Returns: -1899 Select: the modified expression. -1900 """ -1901 alias_expression = maybe_parse( -1902 alias, -1903 dialect=dialect, -1904 into=TableAlias, -1905 **opts, -1906 ) -1907 as_expression = maybe_parse( -1908 as_, -1909 dialect=dialect, -1910 **opts, -1911 ) -1912 cte = CTE( -1913 this=as_expression, -1914 alias=alias_expression, -1915 ) -1916 return _apply_child_list_builder( -1917 cte, -1918 instance=self, -1919 arg="with", -1920 append=append, -1921 copy=copy, -1922 into=With, -1923 properties={"recursive": recursive or False}, -1924 ) -1925 -1926 -1927QUERY_MODIFIERS = { -1928 "match": False, -1929 "laterals": False, -1930 "joins": False, -1931 "pivots": False, -1932 "where": False, -1933 "group": False, -1934 "having": False, -1935 "qualify": False, -1936 "windows": False, -1937 "distribute": False, -1938 "sort": False, -1939 "cluster": False, -1940 "order": False, -1941 "limit": False, -1942 "offset": False, -1943 "lock": False, -1944 "sample": False, -1945} +1898 # CREATE property locations +1899 # Form: schema specified +1900 # create [POST_CREATE] +1901 # table a [POST_NAME] +1902 # (b int) [POST_SCHEMA] +1903 # with ([POST_WITH]) +1904 # index (b) [POST_INDEX] +1905 # +1906 # Form: alias selection +1907 # create [POST_CREATE] +1908 # table a [POST_NAME] +1909 # as [POST_ALIAS] (select * from b) [POST_EXPRESSION] +1910 # index (c) [POST_INDEX] +1911 class Location(AutoName): +1912 POST_CREATE = auto() +1913 POST_NAME = auto() +1914 POST_SCHEMA = auto() +1915 POST_WITH = auto() +1916 POST_ALIAS = auto() +1917 POST_EXPRESSION = auto() +1918 POST_INDEX = auto() +1919 UNSUPPORTED = auto() +1920 +1921 @classmethod +1922 def from_dict(cls, properties_dict) -> Properties: +1923 expressions = [] +1924 for key, value in properties_dict.items(): +1925 property_cls = cls.NAME_TO_PROPERTY.get(key.upper()) +1926 if property_cls: +1927 expressions.append(property_cls(this=convert(value))) +1928 else: +1929 expressions.append(Property(this=Literal.string(key), value=convert(value))) +1930 +1931 return cls(expressions=expressions) +1932 +1933 +1934class Qualify(Expression): +1935 pass +1936 +1937 +1938# https://www.ibm.com/docs/en/ias?topic=procedures-return-statement-in-sql +1939class Return(Expression): +1940 pass +1941 +1942 +1943class Reference(Expression): +1944 arg_types = {"this": True, "expressions": False, "options": False} +1945 1946 -1947 -1948class Table(Expression): -1949 arg_types = { -1950 "this": True, -1951 "alias": False, -1952 "db": False, -1953 "catalog": False, -1954 "laterals": False, -1955 "joins": False, -1956 "pivots": False, -1957 "hints": False, -1958 "system_time": False, -1959 } +1947class Tuple(Expression): +1948 arg_types = {"expressions": False} +1949 +1950 +1951class Subqueryable(Unionable): +1952 def subquery(self, alias=None, copy=True) -> Subquery: +1953 """ +1954 Convert this expression to an aliased expression that can be used as a Subquery. +1955 +1956 Example: +1957 >>> subquery = Select().select("x").from_("tbl").subquery() +1958 >>> Select().select("x").from_(subquery).sql() +1959 'SELECT x FROM (SELECT x FROM tbl)' 1960 -1961 @property -1962 def db(self) -> str: -1963 return self.text("db") +1961 Args: +1962 alias (str | Identifier): an optional alias for the subquery +1963 copy (bool): if `False`, modify this expression instance in-place. 1964 -1965 @property -1966 def catalog(self) -> str: -1967 return self.text("catalog") -1968 -1969 -1970# See the TSQL "Querying data in a system-versioned temporal table" page -1971class SystemTime(Expression): -1972 arg_types = { -1973 "this": False, -1974 "expression": False, -1975 "kind": True, -1976 } -1977 -1978 -1979class Union(Subqueryable): -1980 arg_types = { -1981 "with": False, -1982 "this": True, -1983 "expression": True, -1984 "distinct": False, -1985 **QUERY_MODIFIERS, -1986 } +1965 Returns: +1966 Alias: the subquery +1967 """ +1968 instance = _maybe_copy(self, copy) +1969 return Subquery( +1970 this=instance, +1971 alias=TableAlias(this=to_identifier(alias)) if alias else None, +1972 ) +1973 +1974 def limit(self, expression, dialect=None, copy=True, **opts) -> Select: +1975 raise NotImplementedError +1976 +1977 @property +1978 def ctes(self): +1979 with_ = self.args.get("with") +1980 if not with_: +1981 return [] +1982 return with_.expressions +1983 +1984 @property +1985 def selects(self): +1986 raise NotImplementedError("Subqueryable objects must implement `selects`") 1987 -1988 def limit(self, expression, dialect=None, copy=True, **opts) -> Select: -1989 """ -1990 Set the LIMIT expression. +1988 @property +1989 def named_selects(self): +1990 raise NotImplementedError("Subqueryable objects must implement `named_selects`") 1991 -1992 Example: -1993 >>> select("1").union(select("1")).limit(1).sql() -1994 'SELECT * FROM (SELECT 1 UNION SELECT 1) AS _l_0 LIMIT 1' -1995 -1996 Args: -1997 expression (str | int | Expression): the SQL code string to parse. -1998 This can also be an integer. -1999 If a `Limit` instance is passed, this is used as-is. -2000 If another `Expression` instance is passed, it will be wrapped in a `Limit`. -2001 dialect (str): the dialect used to parse the input expression. -2002 copy (bool): if `False`, modify this expression instance in-place. -2003 opts (kwargs): other options to use to parse the input expressions. +1992 def with_( +1993 self, +1994 alias, +1995 as_, +1996 recursive=None, +1997 append=True, +1998 dialect=None, +1999 copy=True, +2000 **opts, +2001 ): +2002 """ +2003 Append to or set the common table expressions. 2004 -2005 Returns: -2006 Select: The limited subqueryable. -2007 """ -2008 return ( -2009 select("*") -2010 .from_(self.subquery(alias="_l_0", copy=copy)) -2011 .limit(expression, dialect=dialect, copy=False, **opts) -2012 ) -2013 -2014 def select( -2015 self, -2016 *expressions: ExpOrStr, -2017 append: bool = True, -2018 dialect: DialectType = None, -2019 copy: bool = True, -2020 **opts, -2021 ) -> Union: -2022 """Append to or set the SELECT of the union recursively. -2023 -2024 Example: -2025 >>> from sqlglot import parse_one -2026 >>> parse_one("select a from x union select a from y union select a from z").select("b").sql() -2027 'SELECT a, b FROM x UNION SELECT a, b FROM y UNION SELECT a, b FROM z' -2028 -2029 Args: -2030 *expressions: the SQL code strings to parse. -2031 If an `Expression` instance is passed, it will be used as-is. -2032 append: if `True`, add to any existing expressions. -2033 Otherwise, this resets the expressions. -2034 dialect: the dialect used to parse the input expressions. -2035 copy: if `False`, modify this expression instance in-place. -2036 opts: other options to use to parse the input expressions. -2037 -2038 Returns: -2039 Union: the modified expression. -2040 """ -2041 this = self.copy() if copy else self -2042 this.this.unnest().select(*expressions, append=append, dialect=dialect, copy=False, **opts) -2043 this.expression.unnest().select( -2044 *expressions, append=append, dialect=dialect, copy=False, **opts -2045 ) -2046 return this -2047 -2048 @property -2049 def named_selects(self): -2050 return self.this.unnest().named_selects -2051 -2052 @property -2053 def is_star(self) -> bool: -2054 return self.this.is_star or self.expression.is_star -2055 -2056 @property -2057 def selects(self): -2058 return self.this.unnest().selects -2059 -2060 @property -2061 def left(self): -2062 return self.this -2063 -2064 @property -2065 def right(self): -2066 return self.expression -2067 -2068 -2069class Except(Union): -2070 pass -2071 -2072 -2073class Intersect(Union): -2074 pass -2075 -2076 -2077class Unnest(UDTF): -2078 arg_types = { -2079 "expressions": True, -2080 "ordinality": False, -2081 "alias": False, -2082 "offset": False, -2083 } -2084 -2085 -2086class Update(Expression): -2087 arg_types = { -2088 "with": False, -2089 "this": False, -2090 "expressions": True, -2091 "from": False, -2092 "where": False, -2093 "returning": False, -2094 } -2095 -2096 -2097class Values(UDTF): -2098 arg_types = { -2099 "expressions": True, -2100 "ordinality": False, -2101 "alias": False, -2102 } -2103 -2104 -2105class Var(Expression): -2106 pass -2107 -2108 -2109class Schema(Expression): -2110 arg_types = {"this": False, "expressions": False} -2111 -2112 -2113# Used to represent the FOR UPDATE and FOR SHARE locking read types. -2114# https://dev.mysql.com/doc/refman/8.0/en/innodb-locking-reads.html -2115class Lock(Expression): -2116 arg_types = {"update": True} -2117 +2005 Example: +2006 >>> Select().with_("tbl2", as_="SELECT * FROM tbl").select("x").from_("tbl2").sql() +2007 'WITH tbl2 AS (SELECT * FROM tbl) SELECT x FROM tbl2' +2008 +2009 Args: +2010 alias (str | Expression): the SQL code string to parse as the table name. +2011 If an `Expression` instance is passed, this is used as-is. +2012 as_ (str | Expression): the SQL code string to parse as the table expression. +2013 If an `Expression` instance is passed, it will be used as-is. +2014 recursive (bool): set the RECURSIVE part of the expression. Defaults to `False`. +2015 append (bool): if `True`, add to any existing expressions. +2016 Otherwise, this resets the expressions. +2017 dialect (str): the dialect used to parse the input expression. +2018 copy (bool): if `False`, modify this expression instance in-place. +2019 opts (kwargs): other options to use to parse the input expressions. +2020 +2021 Returns: +2022 Select: the modified expression. +2023 """ +2024 alias_expression = maybe_parse( +2025 alias, +2026 dialect=dialect, +2027 into=TableAlias, +2028 **opts, +2029 ) +2030 as_expression = maybe_parse( +2031 as_, +2032 dialect=dialect, +2033 **opts, +2034 ) +2035 cte = CTE( +2036 this=as_expression, +2037 alias=alias_expression, +2038 ) +2039 return _apply_child_list_builder( +2040 cte, +2041 instance=self, +2042 arg="with", +2043 append=append, +2044 copy=copy, +2045 into=With, +2046 properties={"recursive": recursive or False}, +2047 ) +2048 +2049 +2050QUERY_MODIFIERS = { +2051 "match": False, +2052 "laterals": False, +2053 "joins": False, +2054 "pivots": False, +2055 "where": False, +2056 "group": False, +2057 "having": False, +2058 "qualify": False, +2059 "windows": False, +2060 "distribute": False, +2061 "sort": False, +2062 "cluster": False, +2063 "order": False, +2064 "limit": False, +2065 "offset": False, +2066 "lock": False, +2067 "sample": False, +2068} +2069 +2070 +2071class Table(Expression): +2072 arg_types = { +2073 "this": True, +2074 "alias": False, +2075 "db": False, +2076 "catalog": False, +2077 "laterals": False, +2078 "joins": False, +2079 "pivots": False, +2080 "hints": False, +2081 "system_time": False, +2082 } +2083 +2084 @property +2085 def db(self) -> str: +2086 return self.text("db") +2087 +2088 @property +2089 def catalog(self) -> str: +2090 return self.text("catalog") +2091 +2092 +2093# See the TSQL "Querying data in a system-versioned temporal table" page +2094class SystemTime(Expression): +2095 arg_types = { +2096 "this": False, +2097 "expression": False, +2098 "kind": True, +2099 } +2100 +2101 +2102class Union(Subqueryable): +2103 arg_types = { +2104 "with": False, +2105 "this": True, +2106 "expression": True, +2107 "distinct": False, +2108 **QUERY_MODIFIERS, +2109 } +2110 +2111 def limit(self, expression, dialect=None, copy=True, **opts) -> Select: +2112 """ +2113 Set the LIMIT expression. +2114 +2115 Example: +2116 >>> select("1").union(select("1")).limit(1).sql() +2117 'SELECT * FROM (SELECT 1 UNION SELECT 1) AS _l_0 LIMIT 1' 2118 -2119class Select(Subqueryable): -2120 arg_types = { -2121 "with": False, -2122 "kind": False, -2123 "expressions": False, -2124 "hint": False, -2125 "distinct": False, -2126 "into": False, -2127 "from": False, -2128 **QUERY_MODIFIERS, -2129 } -2130 -2131 def from_(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: -2132 """ -2133 Set the FROM expression. -2134 -2135 Example: -2136 >>> Select().from_("tbl").select("x").sql() -2137 'SELECT x FROM tbl' -2138 -2139 Args: -2140 *expressions (str | Expression): the SQL code strings to parse. -2141 If a `From` instance is passed, this is used as-is. -2142 If another `Expression` instance is passed, it will be wrapped in a `From`. -2143 append (bool): if `True`, add to any existing expressions. -2144 Otherwise, this flattens all the `From` expression into a single expression. -2145 dialect (str): the dialect used to parse the input expression. -2146 copy (bool): if `False`, modify this expression instance in-place. -2147 opts (kwargs): other options to use to parse the input expressions. -2148 -2149 Returns: -2150 Select: the modified expression. -2151 """ -2152 return _apply_child_list_builder( -2153 *expressions, -2154 instance=self, -2155 arg="from", -2156 append=append, -2157 copy=copy, -2158 prefix="FROM", -2159 into=From, -2160 dialect=dialect, -2161 **opts, -2162 ) -2163 -2164 def group_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: -2165 """ -2166 Set the GROUP BY expression. -2167 -2168 Example: -2169 >>> Select().from_("tbl").select("x", "COUNT(1)").group_by("x").sql() -2170 'SELECT x, COUNT(1) FROM tbl GROUP BY x' -2171 -2172 Args: -2173 *expressions (str | Expression): the SQL code strings to parse. -2174 If a `Group` instance is passed, this is used as-is. -2175 If another `Expression` instance is passed, it will be wrapped in a `Group`. -2176 If nothing is passed in then a group by is not applied to the expression -2177 append (bool): if `True`, add to any existing expressions. -2178 Otherwise, this flattens all the `Group` expression into a single expression. -2179 dialect (str): the dialect used to parse the input expression. -2180 copy (bool): if `False`, modify this expression instance in-place. -2181 opts (kwargs): other options to use to parse the input expressions. +2119 Args: +2120 expression (str | int | Expression): the SQL code string to parse. +2121 This can also be an integer. +2122 If a `Limit` instance is passed, this is used as-is. +2123 If another `Expression` instance is passed, it will be wrapped in a `Limit`. +2124 dialect (str): the dialect used to parse the input expression. +2125 copy (bool): if `False`, modify this expression instance in-place. +2126 opts (kwargs): other options to use to parse the input expressions. +2127 +2128 Returns: +2129 Select: The limited subqueryable. +2130 """ +2131 return ( +2132 select("*") +2133 .from_(self.subquery(alias="_l_0", copy=copy)) +2134 .limit(expression, dialect=dialect, copy=False, **opts) +2135 ) +2136 +2137 def select( +2138 self, +2139 *expressions: ExpOrStr, +2140 append: bool = True, +2141 dialect: DialectType = None, +2142 copy: bool = True, +2143 **opts, +2144 ) -> Union: +2145 """Append to or set the SELECT of the union recursively. +2146 +2147 Example: +2148 >>> from sqlglot import parse_one +2149 >>> parse_one("select a from x union select a from y union select a from z").select("b").sql() +2150 'SELECT a, b FROM x UNION SELECT a, b FROM y UNION SELECT a, b FROM z' +2151 +2152 Args: +2153 *expressions: the SQL code strings to parse. +2154 If an `Expression` instance is passed, it will be used as-is. +2155 append: if `True`, add to any existing expressions. +2156 Otherwise, this resets the expressions. +2157 dialect: the dialect used to parse the input expressions. +2158 copy: if `False`, modify this expression instance in-place. +2159 opts: other options to use to parse the input expressions. +2160 +2161 Returns: +2162 Union: the modified expression. +2163 """ +2164 this = self.copy() if copy else self +2165 this.this.unnest().select(*expressions, append=append, dialect=dialect, copy=False, **opts) +2166 this.expression.unnest().select( +2167 *expressions, append=append, dialect=dialect, copy=False, **opts +2168 ) +2169 return this +2170 +2171 @property +2172 def named_selects(self): +2173 return self.this.unnest().named_selects +2174 +2175 @property +2176 def is_star(self) -> bool: +2177 return self.this.is_star or self.expression.is_star +2178 +2179 @property +2180 def selects(self): +2181 return self.this.unnest().selects 2182 -2183 Returns: -2184 Select: the modified expression. -2185 """ -2186 if not expressions: -2187 return self if not copy else self.copy() -2188 return _apply_child_list_builder( -2189 *expressions, -2190 instance=self, -2191 arg="group", -2192 append=append, -2193 copy=copy, -2194 prefix="GROUP BY", -2195 into=Group, -2196 dialect=dialect, -2197 **opts, -2198 ) +2183 @property +2184 def left(self): +2185 return self.this +2186 +2187 @property +2188 def right(self): +2189 return self.expression +2190 +2191 +2192class Except(Union): +2193 pass +2194 +2195 +2196class Intersect(Union): +2197 pass +2198 2199 -2200 def order_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: -2201 """ -2202 Set the ORDER BY expression. -2203 -2204 Example: -2205 >>> Select().from_("tbl").select("x").order_by("x DESC").sql() -2206 'SELECT x FROM tbl ORDER BY x DESC' +2200class Unnest(UDTF): +2201 arg_types = { +2202 "expressions": True, +2203 "ordinality": False, +2204 "alias": False, +2205 "offset": False, +2206 } 2207 -2208 Args: -2209 *expressions (str | Expression): the SQL code strings to parse. -2210 If a `Group` instance is passed, this is used as-is. -2211 If another `Expression` instance is passed, it will be wrapped in a `Order`. -2212 append (bool): if `True`, add to any existing expressions. -2213 Otherwise, this flattens all the `Order` expression into a single expression. -2214 dialect (str): the dialect used to parse the input expression. -2215 copy (bool): if `False`, modify this expression instance in-place. -2216 opts (kwargs): other options to use to parse the input expressions. -2217 -2218 Returns: -2219 Select: the modified expression. -2220 """ -2221 return _apply_child_list_builder( -2222 *expressions, -2223 instance=self, -2224 arg="order", -2225 append=append, -2226 copy=copy, -2227 prefix="ORDER BY", -2228 into=Order, -2229 dialect=dialect, -2230 **opts, -2231 ) -2232 -2233 def sort_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: -2234 """ -2235 Set the SORT BY expression. -2236 -2237 Example: -2238 >>> Select().from_("tbl").select("x").sort_by("x DESC").sql() -2239 'SELECT x FROM tbl SORT BY x DESC' +2208 +2209class Update(Expression): +2210 arg_types = { +2211 "with": False, +2212 "this": False, +2213 "expressions": True, +2214 "from": False, +2215 "where": False, +2216 "returning": False, +2217 } +2218 +2219 +2220class Values(UDTF): +2221 arg_types = { +2222 "expressions": True, +2223 "ordinality": False, +2224 "alias": False, +2225 } +2226 +2227 +2228class Var(Expression): +2229 pass +2230 +2231 +2232class Schema(Expression): +2233 arg_types = {"this": False, "expressions": False} +2234 +2235 +2236# Used to represent the FOR UPDATE and FOR SHARE locking read types. +2237# https://dev.mysql.com/doc/refman/8.0/en/innodb-locking-reads.html +2238class Lock(Expression): +2239 arg_types = {"update": True} 2240 -2241 Args: -2242 *expressions (str | Expression): the SQL code strings to parse. -2243 If a `Group` instance is passed, this is used as-is. -2244 If another `Expression` instance is passed, it will be wrapped in a `SORT`. -2245 append (bool): if `True`, add to any existing expressions. -2246 Otherwise, this flattens all the `Order` expression into a single expression. -2247 dialect (str): the dialect used to parse the input expression. -2248 copy (bool): if `False`, modify this expression instance in-place. -2249 opts (kwargs): other options to use to parse the input expressions. -2250 -2251 Returns: -2252 Select: the modified expression. -2253 """ -2254 return _apply_child_list_builder( -2255 *expressions, -2256 instance=self, -2257 arg="sort", -2258 append=append, -2259 copy=copy, -2260 prefix="SORT BY", -2261 into=Sort, -2262 dialect=dialect, -2263 **opts, -2264 ) -2265 -2266 def cluster_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: -2267 """ -2268 Set the CLUSTER BY expression. -2269 -2270 Example: -2271 >>> Select().from_("tbl").select("x").cluster_by("x DESC").sql() -2272 'SELECT x FROM tbl CLUSTER BY x DESC' -2273 -2274 Args: -2275 *expressions (str | Expression): the SQL code strings to parse. -2276 If a `Group` instance is passed, this is used as-is. -2277 If another `Expression` instance is passed, it will be wrapped in a `Cluster`. -2278 append (bool): if `True`, add to any existing expressions. -2279 Otherwise, this flattens all the `Order` expression into a single expression. -2280 dialect (str): the dialect used to parse the input expression. -2281 copy (bool): if `False`, modify this expression instance in-place. -2282 opts (kwargs): other options to use to parse the input expressions. -2283 -2284 Returns: -2285 Select: the modified expression. -2286 """ -2287 return _apply_child_list_builder( -2288 *expressions, -2289 instance=self, -2290 arg="cluster", -2291 append=append, -2292 copy=copy, -2293 prefix="CLUSTER BY", -2294 into=Cluster, -2295 dialect=dialect, -2296 **opts, -2297 ) -2298 -2299 def limit(self, expression, dialect=None, copy=True, **opts) -> Select: -2300 """ -2301 Set the LIMIT expression. -2302 -2303 Example: -2304 >>> Select().from_("tbl").select("x").limit(10).sql() -2305 'SELECT x FROM tbl LIMIT 10' -2306 -2307 Args: -2308 expression (str | int | Expression): the SQL code string to parse. -2309 This can also be an integer. -2310 If a `Limit` instance is passed, this is used as-is. -2311 If another `Expression` instance is passed, it will be wrapped in a `Limit`. -2312 dialect (str): the dialect used to parse the input expression. -2313 copy (bool): if `False`, modify this expression instance in-place. -2314 opts (kwargs): other options to use to parse the input expressions. -2315 -2316 Returns: -2317 Select: the modified expression. -2318 """ -2319 return _apply_builder( -2320 expression=expression, -2321 instance=self, -2322 arg="limit", -2323 into=Limit, -2324 prefix="LIMIT", -2325 dialect=dialect, -2326 copy=copy, -2327 **opts, -2328 ) -2329 -2330 def offset(self, expression, dialect=None, copy=True, **opts) -> Select: -2331 """ -2332 Set the OFFSET expression. -2333 -2334 Example: -2335 >>> Select().from_("tbl").select("x").offset(10).sql() -2336 'SELECT x FROM tbl OFFSET 10' -2337 -2338 Args: -2339 expression (str | int | Expression): the SQL code string to parse. -2340 This can also be an integer. -2341 If a `Offset` instance is passed, this is used as-is. -2342 If another `Expression` instance is passed, it will be wrapped in a `Offset`. -2343 dialect (str): the dialect used to parse the input expression. -2344 copy (bool): if `False`, modify this expression instance in-place. -2345 opts (kwargs): other options to use to parse the input expressions. -2346 -2347 Returns: -2348 Select: the modified expression. -2349 """ -2350 return _apply_builder( -2351 expression=expression, -2352 instance=self, -2353 arg="offset", -2354 into=Offset, -2355 prefix="OFFSET", -2356 dialect=dialect, -2357 copy=copy, -2358 **opts, -2359 ) -2360 -2361 def select( -2362 self, -2363 *expressions: ExpOrStr, -2364 append: bool = True, -2365 dialect: DialectType = None, -2366 copy: bool = True, -2367 **opts, -2368 ) -> Select: -2369 """ -2370 Append to or set the SELECT expressions. -2371 -2372 Example: -2373 >>> Select().select("x", "y").sql() -2374 'SELECT x, y' -2375 -2376 Args: -2377 *expressions: the SQL code strings to parse. -2378 If an `Expression` instance is passed, it will be used as-is. -2379 append: if `True`, add to any existing expressions. -2380 Otherwise, this resets the expressions. -2381 dialect: the dialect used to parse the input expressions. -2382 copy: if `False`, modify this expression instance in-place. -2383 opts: other options to use to parse the input expressions. -2384 -2385 Returns: -2386 Select: the modified expression. -2387 """ -2388 return _apply_list_builder( -2389 *expressions, -2390 instance=self, -2391 arg="expressions", -2392 append=append, -2393 dialect=dialect, -2394 copy=copy, -2395 **opts, -2396 ) -2397 -2398 def lateral(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: -2399 """ -2400 Append to or set the LATERAL expressions. -2401 -2402 Example: -2403 >>> Select().select("x").lateral("OUTER explode(y) tbl2 AS z").from_("tbl").sql() -2404 'SELECT x FROM tbl LATERAL VIEW OUTER EXPLODE(y) tbl2 AS z' -2405 -2406 Args: -2407 *expressions (str | Expression): the SQL code strings to parse. -2408 If an `Expression` instance is passed, it will be used as-is. -2409 append (bool): if `True`, add to any existing expressions. -2410 Otherwise, this resets the expressions. -2411 dialect (str): the dialect used to parse the input expressions. -2412 copy (bool): if `False`, modify this expression instance in-place. -2413 opts (kwargs): other options to use to parse the input expressions. -2414 -2415 Returns: -2416 Select: the modified expression. -2417 """ -2418 return _apply_list_builder( -2419 *expressions, -2420 instance=self, -2421 arg="laterals", -2422 append=append, -2423 into=Lateral, -2424 prefix="LATERAL VIEW", -2425 dialect=dialect, -2426 copy=copy, -2427 **opts, -2428 ) +2241 +2242class Select(Subqueryable): +2243 arg_types = { +2244 "with": False, +2245 "kind": False, +2246 "expressions": False, +2247 "hint": False, +2248 "distinct": False, +2249 "into": False, +2250 "from": False, +2251 **QUERY_MODIFIERS, +2252 } +2253 +2254 def from_(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: +2255 """ +2256 Set the FROM expression. +2257 +2258 Example: +2259 >>> Select().from_("tbl").select("x").sql() +2260 'SELECT x FROM tbl' +2261 +2262 Args: +2263 *expressions (str | Expression): the SQL code strings to parse. +2264 If a `From` instance is passed, this is used as-is. +2265 If another `Expression` instance is passed, it will be wrapped in a `From`. +2266 append (bool): if `True`, add to any existing expressions. +2267 Otherwise, this flattens all the `From` expression into a single expression. +2268 dialect (str): the dialect used to parse the input expression. +2269 copy (bool): if `False`, modify this expression instance in-place. +2270 opts (kwargs): other options to use to parse the input expressions. +2271 +2272 Returns: +2273 Select: the modified expression. +2274 """ +2275 return _apply_child_list_builder( +2276 *expressions, +2277 instance=self, +2278 arg="from", +2279 append=append, +2280 copy=copy, +2281 prefix="FROM", +2282 into=From, +2283 dialect=dialect, +2284 **opts, +2285 ) +2286 +2287 def group_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: +2288 """ +2289 Set the GROUP BY expression. +2290 +2291 Example: +2292 >>> Select().from_("tbl").select("x", "COUNT(1)").group_by("x").sql() +2293 'SELECT x, COUNT(1) FROM tbl GROUP BY x' +2294 +2295 Args: +2296 *expressions (str | Expression): the SQL code strings to parse. +2297 If a `Group` instance is passed, this is used as-is. +2298 If another `Expression` instance is passed, it will be wrapped in a `Group`. +2299 If nothing is passed in then a group by is not applied to the expression +2300 append (bool): if `True`, add to any existing expressions. +2301 Otherwise, this flattens all the `Group` expression into a single expression. +2302 dialect (str): the dialect used to parse the input expression. +2303 copy (bool): if `False`, modify this expression instance in-place. +2304 opts (kwargs): other options to use to parse the input expressions. +2305 +2306 Returns: +2307 Select: the modified expression. +2308 """ +2309 if not expressions: +2310 return self if not copy else self.copy() +2311 return _apply_child_list_builder( +2312 *expressions, +2313 instance=self, +2314 arg="group", +2315 append=append, +2316 copy=copy, +2317 prefix="GROUP BY", +2318 into=Group, +2319 dialect=dialect, +2320 **opts, +2321 ) +2322 +2323 def order_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: +2324 """ +2325 Set the ORDER BY expression. +2326 +2327 Example: +2328 >>> Select().from_("tbl").select("x").order_by("x DESC").sql() +2329 'SELECT x FROM tbl ORDER BY x DESC' +2330 +2331 Args: +2332 *expressions (str | Expression): the SQL code strings to parse. +2333 If a `Group` instance is passed, this is used as-is. +2334 If another `Expression` instance is passed, it will be wrapped in a `Order`. +2335 append (bool): if `True`, add to any existing expressions. +2336 Otherwise, this flattens all the `Order` expression into a single expression. +2337 dialect (str): the dialect used to parse the input expression. +2338 copy (bool): if `False`, modify this expression instance in-place. +2339 opts (kwargs): other options to use to parse the input expressions. +2340 +2341 Returns: +2342 Select: the modified expression. +2343 """ +2344 return _apply_child_list_builder( +2345 *expressions, +2346 instance=self, +2347 arg="order", +2348 append=append, +2349 copy=copy, +2350 prefix="ORDER BY", +2351 into=Order, +2352 dialect=dialect, +2353 **opts, +2354 ) +2355 +2356 def sort_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: +2357 """ +2358 Set the SORT BY expression. +2359 +2360 Example: +2361 >>> Select().from_("tbl").select("x").sort_by("x DESC").sql() +2362 'SELECT x FROM tbl SORT BY x DESC' +2363 +2364 Args: +2365 *expressions (str | Expression): the SQL code strings to parse. +2366 If a `Group` instance is passed, this is used as-is. +2367 If another `Expression` instance is passed, it will be wrapped in a `SORT`. +2368 append (bool): if `True`, add to any existing expressions. +2369 Otherwise, this flattens all the `Order` expression into a single expression. +2370 dialect (str): the dialect used to parse the input expression. +2371 copy (bool): if `False`, modify this expression instance in-place. +2372 opts (kwargs): other options to use to parse the input expressions. +2373 +2374 Returns: +2375 Select: the modified expression. +2376 """ +2377 return _apply_child_list_builder( +2378 *expressions, +2379 instance=self, +2380 arg="sort", +2381 append=append, +2382 copy=copy, +2383 prefix="SORT BY", +2384 into=Sort, +2385 dialect=dialect, +2386 **opts, +2387 ) +2388 +2389 def cluster_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: +2390 """ +2391 Set the CLUSTER BY expression. +2392 +2393 Example: +2394 >>> Select().from_("tbl").select("x").cluster_by("x DESC").sql() +2395 'SELECT x FROM tbl CLUSTER BY x DESC' +2396 +2397 Args: +2398 *expressions (str | Expression): the SQL code strings to parse. +2399 If a `Group` instance is passed, this is used as-is. +2400 If another `Expression` instance is passed, it will be wrapped in a `Cluster`. +2401 append (bool): if `True`, add to any existing expressions. +2402 Otherwise, this flattens all the `Order` expression into a single expression. +2403 dialect (str): the dialect used to parse the input expression. +2404 copy (bool): if `False`, modify this expression instance in-place. +2405 opts (kwargs): other options to use to parse the input expressions. +2406 +2407 Returns: +2408 Select: the modified expression. +2409 """ +2410 return _apply_child_list_builder( +2411 *expressions, +2412 instance=self, +2413 arg="cluster", +2414 append=append, +2415 copy=copy, +2416 prefix="CLUSTER BY", +2417 into=Cluster, +2418 dialect=dialect, +2419 **opts, +2420 ) +2421 +2422 def limit(self, expression, dialect=None, copy=True, **opts) -> Select: +2423 """ +2424 Set the LIMIT expression. +2425 +2426 Example: +2427 >>> Select().from_("tbl").select("x").limit(10).sql() +2428 'SELECT x FROM tbl LIMIT 10' 2429 -2430 def join( -2431 self, -2432 expression, -2433 on=None, -2434 using=None, -2435 append=True, -2436 join_type=None, -2437 join_alias=None, -2438 dialect=None, -2439 copy=True, -2440 **opts, -2441 ) -> Select: -2442 """ -2443 Append to or set the JOIN expressions. -2444 -2445 Example: -2446 >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y").sql() -2447 'SELECT * FROM tbl JOIN tbl2 ON tbl1.y = tbl2.y' -2448 -2449 >>> Select().select("1").from_("a").join("b", using=["x", "y", "z"]).sql() -2450 'SELECT 1 FROM a JOIN b USING (x, y, z)' -2451 -2452 Use `join_type` to change the type of join: -2453 -2454 >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y", join_type="left outer").sql() -2455 'SELECT * FROM tbl LEFT OUTER JOIN tbl2 ON tbl1.y = tbl2.y' +2430 Args: +2431 expression (str | int | Expression): the SQL code string to parse. +2432 This can also be an integer. +2433 If a `Limit` instance is passed, this is used as-is. +2434 If another `Expression` instance is passed, it will be wrapped in a `Limit`. +2435 dialect (str): the dialect used to parse the input expression. +2436 copy (bool): if `False`, modify this expression instance in-place. +2437 opts (kwargs): other options to use to parse the input expressions. +2438 +2439 Returns: +2440 Select: the modified expression. +2441 """ +2442 return _apply_builder( +2443 expression=expression, +2444 instance=self, +2445 arg="limit", +2446 into=Limit, +2447 prefix="LIMIT", +2448 dialect=dialect, +2449 copy=copy, +2450 **opts, +2451 ) +2452 +2453 def offset(self, expression, dialect=None, copy=True, **opts) -> Select: +2454 """ +2455 Set the OFFSET expression. 2456 -2457 Args: -2458 expression (str | Expression): the SQL code string to parse. -2459 If an `Expression` instance is passed, it will be used as-is. -2460 on (str | Expression): optionally specify the join "on" criteria as a SQL string. -2461 If an `Expression` instance is passed, it will be used as-is. -2462 using (str | Expression): optionally specify the join "using" criteria as a SQL string. -2463 If an `Expression` instance is passed, it will be used as-is. -2464 append (bool): if `True`, add to any existing expressions. -2465 Otherwise, this resets the expressions. -2466 join_type (str): If set, alter the parsed join type -2467 dialect (str): the dialect used to parse the input expressions. -2468 copy (bool): if `False`, modify this expression instance in-place. -2469 opts (kwargs): other options to use to parse the input expressions. -2470 -2471 Returns: -2472 Select: the modified expression. -2473 """ -2474 parse_args = {"dialect": dialect, **opts} -2475 -2476 try: -2477 expression = maybe_parse(expression, into=Join, prefix="JOIN", **parse_args) -2478 except ParseError: -2479 expression = maybe_parse(expression, into=(Join, Expression), **parse_args) -2480 -2481 join = expression if isinstance(expression, Join) else Join(this=expression) -2482 -2483 if isinstance(join.this, Select): -2484 join.this.replace(join.this.subquery()) -2485 -2486 if join_type: -2487 natural: t.Optional[Token] -2488 side: t.Optional[Token] -2489 kind: t.Optional[Token] -2490 -2491 natural, side, kind = maybe_parse(join_type, into="JOIN_TYPE", **parse_args) # type: ignore -2492 -2493 if natural: -2494 join.set("natural", True) -2495 if side: -2496 join.set("side", side.text) -2497 if kind: -2498 join.set("kind", kind.text) -2499 -2500 if on: -2501 on = and_(*ensure_collection(on), dialect=dialect, **opts) -2502 join.set("on", on) -2503 -2504 if using: -2505 join = _apply_list_builder( -2506 *ensure_collection(using), -2507 instance=join, -2508 arg="using", -2509 append=append, -2510 copy=copy, -2511 **opts, -2512 ) -2513 -2514 if join_alias: -2515 join.set("this", alias_(join.this, join_alias, table=True)) -2516 return _apply_list_builder( -2517 join, -2518 instance=self, -2519 arg="joins", -2520 append=append, -2521 copy=copy, -2522 **opts, -2523 ) +2457 Example: +2458 >>> Select().from_("tbl").select("x").offset(10).sql() +2459 'SELECT x FROM tbl OFFSET 10' +2460 +2461 Args: +2462 expression (str | int | Expression): the SQL code string to parse. +2463 This can also be an integer. +2464 If a `Offset` instance is passed, this is used as-is. +2465 If another `Expression` instance is passed, it will be wrapped in a `Offset`. +2466 dialect (str): the dialect used to parse the input expression. +2467 copy (bool): if `False`, modify this expression instance in-place. +2468 opts (kwargs): other options to use to parse the input expressions. +2469 +2470 Returns: +2471 Select: the modified expression. +2472 """ +2473 return _apply_builder( +2474 expression=expression, +2475 instance=self, +2476 arg="offset", +2477 into=Offset, +2478 prefix="OFFSET", +2479 dialect=dialect, +2480 copy=copy, +2481 **opts, +2482 ) +2483 +2484 def select( +2485 self, +2486 *expressions: ExpOrStr, +2487 append: bool = True, +2488 dialect: DialectType = None, +2489 copy: bool = True, +2490 **opts, +2491 ) -> Select: +2492 """ +2493 Append to or set the SELECT expressions. +2494 +2495 Example: +2496 >>> Select().select("x", "y").sql() +2497 'SELECT x, y' +2498 +2499 Args: +2500 *expressions: the SQL code strings to parse. +2501 If an `Expression` instance is passed, it will be used as-is. +2502 append: if `True`, add to any existing expressions. +2503 Otherwise, this resets the expressions. +2504 dialect: the dialect used to parse the input expressions. +2505 copy: if `False`, modify this expression instance in-place. +2506 opts: other options to use to parse the input expressions. +2507 +2508 Returns: +2509 Select: the modified expression. +2510 """ +2511 return _apply_list_builder( +2512 *expressions, +2513 instance=self, +2514 arg="expressions", +2515 append=append, +2516 dialect=dialect, +2517 copy=copy, +2518 **opts, +2519 ) +2520 +2521 def lateral(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: +2522 """ +2523 Append to or set the LATERAL expressions. 2524 -2525 def where(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: -2526 """ -2527 Append to or set the WHERE expressions. +2525 Example: +2526 >>> Select().select("x").lateral("OUTER explode(y) tbl2 AS z").from_("tbl").sql() +2527 'SELECT x FROM tbl LATERAL VIEW OUTER EXPLODE(y) tbl2 AS z' 2528 -2529 Example: -2530 >>> Select().select("x").from_("tbl").where("x = 'a' OR x < 'b'").sql() -2531 "SELECT x FROM tbl WHERE x = 'a' OR x < 'b'" -2532 -2533 Args: -2534 *expressions (str | Expression): the SQL code strings to parse. -2535 If an `Expression` instance is passed, it will be used as-is. -2536 Multiple expressions are combined with an AND operator. -2537 append (bool): if `True`, AND the new expressions to any existing expression. -2538 Otherwise, this resets the expression. -2539 dialect (str): the dialect used to parse the input expressions. -2540 copy (bool): if `False`, modify this expression instance in-place. -2541 opts (kwargs): other options to use to parse the input expressions. -2542 -2543 Returns: -2544 Select: the modified expression. -2545 """ -2546 return _apply_conjunction_builder( -2547 *expressions, -2548 instance=self, -2549 arg="where", -2550 append=append, -2551 into=Where, -2552 dialect=dialect, -2553 copy=copy, -2554 **opts, -2555 ) -2556 -2557 def having(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: -2558 """ -2559 Append to or set the HAVING expressions. -2560 -2561 Example: -2562 >>> Select().select("x", "COUNT(y)").from_("tbl").group_by("x").having("COUNT(y) > 3").sql() -2563 'SELECT x, COUNT(y) FROM tbl GROUP BY x HAVING COUNT(y) > 3' -2564 -2565 Args: -2566 *expressions (str | Expression): the SQL code strings to parse. -2567 If an `Expression` instance is passed, it will be used as-is. -2568 Multiple expressions are combined with an AND operator. -2569 append (bool): if `True`, AND the new expressions to any existing expression. -2570 Otherwise, this resets the expression. -2571 dialect (str): the dialect used to parse the input expressions. -2572 copy (bool): if `False`, modify this expression instance in-place. -2573 opts (kwargs): other options to use to parse the input expressions. +2529 Args: +2530 *expressions (str | Expression): the SQL code strings to parse. +2531 If an `Expression` instance is passed, it will be used as-is. +2532 append (bool): if `True`, add to any existing expressions. +2533 Otherwise, this resets the expressions. +2534 dialect (str): the dialect used to parse the input expressions. +2535 copy (bool): if `False`, modify this expression instance in-place. +2536 opts (kwargs): other options to use to parse the input expressions. +2537 +2538 Returns: +2539 Select: the modified expression. +2540 """ +2541 return _apply_list_builder( +2542 *expressions, +2543 instance=self, +2544 arg="laterals", +2545 append=append, +2546 into=Lateral, +2547 prefix="LATERAL VIEW", +2548 dialect=dialect, +2549 copy=copy, +2550 **opts, +2551 ) +2552 +2553 def join( +2554 self, +2555 expression, +2556 on=None, +2557 using=None, +2558 append=True, +2559 join_type=None, +2560 join_alias=None, +2561 dialect=None, +2562 copy=True, +2563 **opts, +2564 ) -> Select: +2565 """ +2566 Append to or set the JOIN expressions. +2567 +2568 Example: +2569 >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y").sql() +2570 'SELECT * FROM tbl JOIN tbl2 ON tbl1.y = tbl2.y' +2571 +2572 >>> Select().select("1").from_("a").join("b", using=["x", "y", "z"]).sql() +2573 'SELECT 1 FROM a JOIN b USING (x, y, z)' 2574 -2575 Returns: -2576 Select: the modified expression. -2577 """ -2578 return _apply_conjunction_builder( -2579 *expressions, -2580 instance=self, -2581 arg="having", -2582 append=append, -2583 into=Having, -2584 dialect=dialect, -2585 copy=copy, -2586 **opts, -2587 ) -2588 -2589 def window(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: -2590 return _apply_list_builder( -2591 *expressions, -2592 instance=self, -2593 arg="windows", -2594 append=append, -2595 into=Window, -2596 dialect=dialect, -2597 copy=copy, -2598 **opts, -2599 ) -2600 -2601 def qualify(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: -2602 return _apply_conjunction_builder( -2603 *expressions, -2604 instance=self, -2605 arg="qualify", -2606 append=append, -2607 into=Qualify, -2608 dialect=dialect, -2609 copy=copy, -2610 **opts, -2611 ) -2612 -2613 def distinct(self, distinct=True, copy=True) -> Select: -2614 """ -2615 Set the OFFSET expression. -2616 -2617 Example: -2618 >>> Select().from_("tbl").select("x").distinct().sql() -2619 'SELECT DISTINCT x FROM tbl' -2620 -2621 Args: -2622 distinct (bool): whether the Select should be distinct -2623 copy (bool): if `False`, modify this expression instance in-place. -2624 -2625 Returns: -2626 Select: the modified expression. -2627 """ -2628 instance = _maybe_copy(self, copy) -2629 instance.set("distinct", Distinct() if distinct else None) -2630 return instance -2631 -2632 def ctas(self, table, properties=None, dialect=None, copy=True, **opts) -> Create: -2633 """ -2634 Convert this expression to a CREATE TABLE AS statement. -2635 -2636 Example: -2637 >>> Select().select("*").from_("tbl").ctas("x").sql() -2638 'CREATE TABLE x AS SELECT * FROM tbl' -2639 -2640 Args: -2641 table (str | Expression): the SQL code string to parse as the table name. -2642 If another `Expression` instance is passed, it will be used as-is. -2643 properties (dict): an optional mapping of table properties -2644 dialect (str): the dialect used to parse the input table. -2645 copy (bool): if `False`, modify this expression instance in-place. -2646 opts (kwargs): other options to use to parse the input table. +2575 Use `join_type` to change the type of join: +2576 +2577 >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y", join_type="left outer").sql() +2578 'SELECT * FROM tbl LEFT OUTER JOIN tbl2 ON tbl1.y = tbl2.y' +2579 +2580 Args: +2581 expression (str | Expression): the SQL code string to parse. +2582 If an `Expression` instance is passed, it will be used as-is. +2583 on (str | Expression): optionally specify the join "on" criteria as a SQL string. +2584 If an `Expression` instance is passed, it will be used as-is. +2585 using (str | Expression): optionally specify the join "using" criteria as a SQL string. +2586 If an `Expression` instance is passed, it will be used as-is. +2587 append (bool): if `True`, add to any existing expressions. +2588 Otherwise, this resets the expressions. +2589 join_type (str): If set, alter the parsed join type +2590 dialect (str): the dialect used to parse the input expressions. +2591 copy (bool): if `False`, modify this expression instance in-place. +2592 opts (kwargs): other options to use to parse the input expressions. +2593 +2594 Returns: +2595 Select: the modified expression. +2596 """ +2597 parse_args = {"dialect": dialect, **opts} +2598 +2599 try: +2600 expression = maybe_parse(expression, into=Join, prefix="JOIN", **parse_args) +2601 except ParseError: +2602 expression = maybe_parse(expression, into=(Join, Expression), **parse_args) +2603 +2604 join = expression if isinstance(expression, Join) else Join(this=expression) +2605 +2606 if isinstance(join.this, Select): +2607 join.this.replace(join.this.subquery()) +2608 +2609 if join_type: +2610 natural: t.Optional[Token] +2611 side: t.Optional[Token] +2612 kind: t.Optional[Token] +2613 +2614 natural, side, kind = maybe_parse(join_type, into="JOIN_TYPE", **parse_args) # type: ignore +2615 +2616 if natural: +2617 join.set("natural", True) +2618 if side: +2619 join.set("side", side.text) +2620 if kind: +2621 join.set("kind", kind.text) +2622 +2623 if on: +2624 on = and_(*ensure_collection(on), dialect=dialect, copy=copy, **opts) +2625 join.set("on", on) +2626 +2627 if using: +2628 join = _apply_list_builder( +2629 *ensure_collection(using), +2630 instance=join, +2631 arg="using", +2632 append=append, +2633 copy=copy, +2634 **opts, +2635 ) +2636 +2637 if join_alias: +2638 join.set("this", alias_(join.this, join_alias, table=True)) +2639 return _apply_list_builder( +2640 join, +2641 instance=self, +2642 arg="joins", +2643 append=append, +2644 copy=copy, +2645 **opts, +2646 ) 2647 -2648 Returns: -2649 Create: the CREATE TABLE AS expression -2650 """ -2651 instance = _maybe_copy(self, copy) -2652 table_expression = maybe_parse( -2653 table, -2654 into=Table, -2655 dialect=dialect, -2656 **opts, -2657 ) -2658 properties_expression = None -2659 if properties: -2660 properties_expression = Properties.from_dict(properties) -2661 -2662 return Create( -2663 this=table_expression, -2664 kind="table", -2665 expression=instance, -2666 properties=properties_expression, -2667 ) -2668 -2669 def lock(self, update: bool = True, copy: bool = True) -> Select: -2670 """ -2671 Set the locking read mode for this expression. -2672 -2673 Examples: -2674 >>> Select().select("x").from_("tbl").where("x = 'a'").lock().sql("mysql") -2675 "SELECT x FROM tbl WHERE x = 'a' FOR UPDATE" -2676 -2677 >>> Select().select("x").from_("tbl").where("x = 'a'").lock(update=False).sql("mysql") -2678 "SELECT x FROM tbl WHERE x = 'a' FOR SHARE" +2648 def where(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: +2649 """ +2650 Append to or set the WHERE expressions. +2651 +2652 Example: +2653 >>> Select().select("x").from_("tbl").where("x = 'a' OR x < 'b'").sql() +2654 "SELECT x FROM tbl WHERE x = 'a' OR x < 'b'" +2655 +2656 Args: +2657 *expressions (str | Expression): the SQL code strings to parse. +2658 If an `Expression` instance is passed, it will be used as-is. +2659 Multiple expressions are combined with an AND operator. +2660 append (bool): if `True`, AND the new expressions to any existing expression. +2661 Otherwise, this resets the expression. +2662 dialect (str): the dialect used to parse the input expressions. +2663 copy (bool): if `False`, modify this expression instance in-place. +2664 opts (kwargs): other options to use to parse the input expressions. +2665 +2666 Returns: +2667 Select: the modified expression. +2668 """ +2669 return _apply_conjunction_builder( +2670 *expressions, +2671 instance=self, +2672 arg="where", +2673 append=append, +2674 into=Where, +2675 dialect=dialect, +2676 copy=copy, +2677 **opts, +2678 ) 2679 -2680 Args: -2681 update: if `True`, the locking type will be `FOR UPDATE`, else it will be `FOR SHARE`. -2682 copy: if `False`, modify this expression instance in-place. +2680 def having(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: +2681 """ +2682 Append to or set the HAVING expressions. 2683 -2684 Returns: -2685 The modified expression. -2686 """ +2684 Example: +2685 >>> Select().select("x", "COUNT(y)").from_("tbl").group_by("x").having("COUNT(y) > 3").sql() +2686 'SELECT x, COUNT(y) FROM tbl GROUP BY x HAVING COUNT(y) > 3' 2687 -2688 inst = _maybe_copy(self, copy) -2689 inst.set("lock", Lock(update=update)) -2690 -2691 return inst -2692 -2693 @property -2694 def named_selects(self) -> t.List[str]: -2695 return [e.output_name for e in self.expressions if e.alias_or_name] -2696 -2697 @property -2698 def is_star(self) -> bool: -2699 return any(expression.is_star for expression in self.expressions) -2700 -2701 @property -2702 def selects(self) -> t.List[Expression]: -2703 return self.expressions -2704 -2705 -2706class Subquery(DerivedTable, Unionable): -2707 arg_types = { -2708 "this": True, -2709 "alias": False, -2710 "with": False, -2711 **QUERY_MODIFIERS, -2712 } -2713 -2714 def unnest(self): -2715 """ -2716 Returns the first non subquery. -2717 """ -2718 expression = self -2719 while isinstance(expression, Subquery): -2720 expression = expression.this -2721 return expression -2722 -2723 @property -2724 def is_star(self) -> bool: -2725 return self.this.is_star -2726 -2727 @property -2728 def output_name(self): -2729 return self.alias -2730 -2731 -2732class TableSample(Expression): -2733 arg_types = { -2734 "this": False, -2735 "method": False, -2736 "bucket_numerator": False, -2737 "bucket_denominator": False, -2738 "bucket_field": False, -2739 "percent": False, -2740 "rows": False, -2741 "size": False, -2742 "seed": False, -2743 "kind": False, -2744 } -2745 -2746 -2747class Tag(Expression): -2748 """Tags are used for generating arbitrary sql like SELECT <span>x</span>.""" -2749 -2750 arg_types = { -2751 "this": False, -2752 "prefix": False, -2753 "postfix": False, -2754 } -2755 +2688 Args: +2689 *expressions (str | Expression): the SQL code strings to parse. +2690 If an `Expression` instance is passed, it will be used as-is. +2691 Multiple expressions are combined with an AND operator. +2692 append (bool): if `True`, AND the new expressions to any existing expression. +2693 Otherwise, this resets the expression. +2694 dialect (str): the dialect used to parse the input expressions. +2695 copy (bool): if `False`, modify this expression instance in-place. +2696 opts (kwargs): other options to use to parse the input expressions. +2697 +2698 Returns: +2699 Select: the modified expression. +2700 """ +2701 return _apply_conjunction_builder( +2702 *expressions, +2703 instance=self, +2704 arg="having", +2705 append=append, +2706 into=Having, +2707 dialect=dialect, +2708 copy=copy, +2709 **opts, +2710 ) +2711 +2712 def window(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: +2713 return _apply_list_builder( +2714 *expressions, +2715 instance=self, +2716 arg="windows", +2717 append=append, +2718 into=Window, +2719 dialect=dialect, +2720 copy=copy, +2721 **opts, +2722 ) +2723 +2724 def qualify(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: +2725 return _apply_conjunction_builder( +2726 *expressions, +2727 instance=self, +2728 arg="qualify", +2729 append=append, +2730 into=Qualify, +2731 dialect=dialect, +2732 copy=copy, +2733 **opts, +2734 ) +2735 +2736 def distinct(self, *ons: ExpOrStr, distinct: bool = True, copy: bool = True) -> Select: +2737 """ +2738 Set the OFFSET expression. +2739 +2740 Example: +2741 >>> Select().from_("tbl").select("x").distinct().sql() +2742 'SELECT DISTINCT x FROM tbl' +2743 +2744 Args: +2745 ons: the expressions to distinct on +2746 distinct: whether the Select should be distinct +2747 copy: if `False`, modify this expression instance in-place. +2748 +2749 Returns: +2750 Select: the modified expression. +2751 """ +2752 instance = _maybe_copy(self, copy) +2753 on = Tuple(expressions=[maybe_parse(on, copy=copy) for on in ons]) if ons else None +2754 instance.set("distinct", Distinct(on=on) if distinct else None) +2755 return instance 2756 -2757class Pivot(Expression): -2758 arg_types = { -2759 "this": False, -2760 "alias": False, -2761 "expressions": True, -2762 "field": True, -2763 "unpivot": True, -2764 "columns": False, -2765 } -2766 -2767 -2768class Window(Expression): -2769 arg_types = { -2770 "this": True, -2771 "partition_by": False, -2772 "order": False, -2773 "spec": False, -2774 "alias": False, -2775 } -2776 -2777 -2778class WindowSpec(Expression): -2779 arg_types = { -2780 "kind": False, -2781 "start": False, -2782 "start_side": False, -2783 "end": False, -2784 "end_side": False, -2785 } +2757 def ctas(self, table, properties=None, dialect=None, copy=True, **opts) -> Create: +2758 """ +2759 Convert this expression to a CREATE TABLE AS statement. +2760 +2761 Example: +2762 >>> Select().select("*").from_("tbl").ctas("x").sql() +2763 'CREATE TABLE x AS SELECT * FROM tbl' +2764 +2765 Args: +2766 table (str | Expression): the SQL code string to parse as the table name. +2767 If another `Expression` instance is passed, it will be used as-is. +2768 properties (dict): an optional mapping of table properties +2769 dialect (str): the dialect used to parse the input table. +2770 copy (bool): if `False`, modify this expression instance in-place. +2771 opts (kwargs): other options to use to parse the input table. +2772 +2773 Returns: +2774 Create: the CREATE TABLE AS expression +2775 """ +2776 instance = _maybe_copy(self, copy) +2777 table_expression = maybe_parse( +2778 table, +2779 into=Table, +2780 dialect=dialect, +2781 **opts, +2782 ) +2783 properties_expression = None +2784 if properties: +2785 properties_expression = Properties.from_dict(properties) 2786 -2787 -2788class Where(Expression): -2789 pass -2790 -2791 -2792class Star(Expression): -2793 arg_types = {"except": False, "replace": False} -2794 -2795 @property -2796 def name(self) -> str: -2797 return "*" -2798 -2799 @property -2800 def output_name(self): -2801 return self.name -2802 -2803 -2804class Parameter(Expression): -2805 arg_types = {"this": True, "wrapped": False} -2806 -2807 -2808class SessionParameter(Expression): -2809 arg_types = {"this": True, "kind": False} -2810 -2811 -2812class Placeholder(Expression): -2813 arg_types = {"this": False} -2814 +2787 return Create( +2788 this=table_expression, +2789 kind="table", +2790 expression=instance, +2791 properties=properties_expression, +2792 ) +2793 +2794 def lock(self, update: bool = True, copy: bool = True) -> Select: +2795 """ +2796 Set the locking read mode for this expression. +2797 +2798 Examples: +2799 >>> Select().select("x").from_("tbl").where("x = 'a'").lock().sql("mysql") +2800 "SELECT x FROM tbl WHERE x = 'a' FOR UPDATE" +2801 +2802 >>> Select().select("x").from_("tbl").where("x = 'a'").lock(update=False).sql("mysql") +2803 "SELECT x FROM tbl WHERE x = 'a' FOR SHARE" +2804 +2805 Args: +2806 update: if `True`, the locking type will be `FOR UPDATE`, else it will be `FOR SHARE`. +2807 copy: if `False`, modify this expression instance in-place. +2808 +2809 Returns: +2810 The modified expression. +2811 """ +2812 +2813 inst = _maybe_copy(self, copy) +2814 inst.set("lock", Lock(update=update)) 2815 -2816class Null(Condition): -2817 arg_types: t.Dict[str, t.Any] = {} -2818 -2819 @property -2820 def name(self) -> str: -2821 return "NULL" -2822 -2823 -2824class Boolean(Condition): -2825 pass -2826 -2827 -2828class DataType(Expression): -2829 arg_types = { -2830 "this": True, -2831 "expressions": False, -2832 "nested": False, -2833 "values": False, -2834 "prefix": False, -2835 } -2836 -2837 class Type(AutoName): -2838 CHAR = auto() -2839 NCHAR = auto() -2840 VARCHAR = auto() -2841 NVARCHAR = auto() -2842 TEXT = auto() -2843 MEDIUMTEXT = auto() -2844 LONGTEXT = auto() -2845 MEDIUMBLOB = auto() -2846 LONGBLOB = auto() -2847 BINARY = auto() -2848 VARBINARY = auto() -2849 INT = auto() -2850 UINT = auto() -2851 TINYINT = auto() -2852 UTINYINT = auto() -2853 SMALLINT = auto() -2854 USMALLINT = auto() -2855 BIGINT = auto() -2856 UBIGINT = auto() -2857 FLOAT = auto() -2858 DOUBLE = auto() -2859 DECIMAL = auto() -2860 BIGDECIMAL = auto() -2861 BIT = auto() -2862 BOOLEAN = auto() -2863 JSON = auto() -2864 JSONB = auto() -2865 INTERVAL = auto() -2866 TIME = auto() -2867 TIMESTAMP = auto() -2868 TIMESTAMPTZ = auto() -2869 TIMESTAMPLTZ = auto() -2870 DATE = auto() -2871 DATETIME = auto() -2872 ARRAY = auto() -2873 MAP = auto() -2874 UUID = auto() -2875 GEOGRAPHY = auto() -2876 GEOMETRY = auto() -2877 STRUCT = auto() -2878 NULLABLE = auto() -2879 HLLSKETCH = auto() -2880 HSTORE = auto() -2881 SUPER = auto() -2882 SERIAL = auto() -2883 SMALLSERIAL = auto() -2884 BIGSERIAL = auto() -2885 XML = auto() -2886 UNIQUEIDENTIFIER = auto() -2887 MONEY = auto() -2888 SMALLMONEY = auto() -2889 ROWVERSION = auto() -2890 IMAGE = auto() -2891 VARIANT = auto() -2892 OBJECT = auto() -2893 INET = auto() -2894 NULL = auto() -2895 UNKNOWN = auto() # Sentinel value, useful for type annotation -2896 -2897 TEXT_TYPES = { -2898 Type.CHAR, -2899 Type.NCHAR, -2900 Type.VARCHAR, -2901 Type.NVARCHAR, -2902 Type.TEXT, -2903 } +2816 return inst +2817 +2818 @property +2819 def named_selects(self) -> t.List[str]: +2820 return [e.output_name for e in self.expressions if e.alias_or_name] +2821 +2822 @property +2823 def is_star(self) -> bool: +2824 return any(expression.is_star for expression in self.expressions) +2825 +2826 @property +2827 def selects(self) -> t.List[Expression]: +2828 return self.expressions +2829 +2830 +2831class Subquery(DerivedTable, Unionable): +2832 arg_types = { +2833 "this": True, +2834 "alias": False, +2835 "with": False, +2836 **QUERY_MODIFIERS, +2837 } +2838 +2839 def unnest(self): +2840 """ +2841 Returns the first non subquery. +2842 """ +2843 expression = self +2844 while isinstance(expression, Subquery): +2845 expression = expression.this +2846 return expression +2847 +2848 @property +2849 def is_star(self) -> bool: +2850 return self.this.is_star +2851 +2852 @property +2853 def output_name(self): +2854 return self.alias +2855 +2856 +2857class TableSample(Expression): +2858 arg_types = { +2859 "this": False, +2860 "method": False, +2861 "bucket_numerator": False, +2862 "bucket_denominator": False, +2863 "bucket_field": False, +2864 "percent": False, +2865 "rows": False, +2866 "size": False, +2867 "seed": False, +2868 "kind": False, +2869 } +2870 +2871 +2872class Tag(Expression): +2873 """Tags are used for generating arbitrary sql like SELECT <span>x</span>.""" +2874 +2875 arg_types = { +2876 "this": False, +2877 "prefix": False, +2878 "postfix": False, +2879 } +2880 +2881 +2882class Pivot(Expression): +2883 arg_types = { +2884 "this": False, +2885 "alias": False, +2886 "expressions": True, +2887 "field": True, +2888 "unpivot": True, +2889 "columns": False, +2890 } +2891 +2892 +2893class Window(Expression): +2894 arg_types = { +2895 "this": True, +2896 "partition_by": False, +2897 "order": False, +2898 "spec": False, +2899 "alias": False, +2900 "over": False, +2901 "first": False, +2902 } +2903 2904 -2905 INTEGER_TYPES = { -2906 Type.INT, -2907 Type.TINYINT, -2908 Type.SMALLINT, -2909 Type.BIGINT, -2910 } -2911 -2912 FLOAT_TYPES = { -2913 Type.FLOAT, -2914 Type.DOUBLE, -2915 } -2916 -2917 NUMERIC_TYPES = {*INTEGER_TYPES, *FLOAT_TYPES} +2905class WindowSpec(Expression): +2906 arg_types = { +2907 "kind": False, +2908 "start": False, +2909 "start_side": False, +2910 "end": False, +2911 "end_side": False, +2912 } +2913 +2914 +2915class Where(Expression): +2916 pass +2917 2918 -2919 TEMPORAL_TYPES = { -2920 Type.TIMESTAMP, -2921 Type.TIMESTAMPTZ, -2922 Type.TIMESTAMPLTZ, -2923 Type.DATE, -2924 Type.DATETIME, -2925 } -2926 -2927 @classmethod -2928 def build( -2929 cls, dtype: str | DataType | DataType.Type, dialect: DialectType = None, **kwargs -2930 ) -> DataType: -2931 from sqlglot import parse_one -2932 -2933 if isinstance(dtype, str): -2934 if dtype.upper() in cls.Type.__members__: -2935 data_type_exp: t.Optional[Expression] = DataType(this=DataType.Type[dtype.upper()]) -2936 else: -2937 data_type_exp = parse_one(dtype, read=dialect, into=DataType) -2938 if data_type_exp is None: -2939 raise ValueError(f"Unparsable data type value: {dtype}") -2940 elif isinstance(dtype, DataType.Type): -2941 data_type_exp = DataType(this=dtype) -2942 elif isinstance(dtype, DataType): -2943 return dtype -2944 else: -2945 raise ValueError(f"Invalid data type: {type(dtype)}. Expected str or DataType.Type") -2946 return DataType(**{**data_type_exp.args, **kwargs}) -2947 -2948 def is_type(self, dtype: DataType.Type) -> bool: -2949 return self.this == dtype +2919class Star(Expression): +2920 arg_types = {"except": False, "replace": False} +2921 +2922 @property +2923 def name(self) -> str: +2924 return "*" +2925 +2926 @property +2927 def output_name(self): +2928 return self.name +2929 +2930 +2931class Parameter(Expression): +2932 arg_types = {"this": True, "wrapped": False} +2933 +2934 +2935class SessionParameter(Expression): +2936 arg_types = {"this": True, "kind": False} +2937 +2938 +2939class Placeholder(Expression): +2940 arg_types = {"this": False} +2941 +2942 +2943class Null(Condition): +2944 arg_types: t.Dict[str, t.Any] = {} +2945 +2946 @property +2947 def name(self) -> str: +2948 return "NULL" +2949 2950 -2951 -2952# https://www.postgresql.org/docs/15/datatype-pseudo.html -2953class PseudoType(Expression): -2954 pass -2955 -2956 -2957class StructKwarg(Expression): -2958 arg_types = {"this": True, "expression": True} -2959 -2960 -2961# WHERE x <OP> EXISTS|ALL|ANY|SOME(SELECT ...) -2962class SubqueryPredicate(Predicate): -2963 pass -2964 -2965 -2966class All(SubqueryPredicate): -2967 pass -2968 -2969 -2970class Any(SubqueryPredicate): -2971 pass -2972 -2973 -2974class Exists(SubqueryPredicate): -2975 pass -2976 -2977 -2978# Commands to interact with the databases or engines. For most of the command -2979# expressions we parse whatever comes after the command's name as a string. -2980class Command(Expression): -2981 arg_types = {"this": True, "expression": False} -2982 -2983 -2984class Transaction(Expression): -2985 arg_types = {"this": False, "modes": False} -2986 -2987 -2988class Commit(Expression): -2989 arg_types = {"chain": False} -2990 -2991 -2992class Rollback(Expression): -2993 arg_types = {"savepoint": False} -2994 -2995 -2996class AlterTable(Expression): -2997 arg_types = {"this": True, "actions": True, "exists": False} -2998 -2999 -3000class AddConstraint(Expression): -3001 arg_types = {"this": False, "expression": False, "enforced": False} -3002 -3003 -3004class DropPartition(Expression): -3005 arg_types = {"expressions": True, "exists": False} -3006 -3007 -3008# Binary expressions like (ADD a b) -3009class Binary(Expression): -3010 arg_types = {"this": True, "expression": True} -3011 -3012 @property -3013 def left(self): -3014 return self.this -3015 -3016 @property -3017 def right(self): -3018 return self.expression -3019 -3020 -3021class Add(Binary): -3022 pass +2951class Boolean(Condition): +2952 pass +2953 +2954 +2955class DataType(Expression): +2956 arg_types = { +2957 "this": True, +2958 "expressions": False, +2959 "nested": False, +2960 "values": False, +2961 "prefix": False, +2962 } +2963 +2964 class Type(AutoName): +2965 CHAR = auto() +2966 NCHAR = auto() +2967 VARCHAR = auto() +2968 NVARCHAR = auto() +2969 TEXT = auto() +2970 MEDIUMTEXT = auto() +2971 LONGTEXT = auto() +2972 MEDIUMBLOB = auto() +2973 LONGBLOB = auto() +2974 BINARY = auto() +2975 VARBINARY = auto() +2976 INT = auto() +2977 UINT = auto() +2978 TINYINT = auto() +2979 UTINYINT = auto() +2980 SMALLINT = auto() +2981 USMALLINT = auto() +2982 BIGINT = auto() +2983 UBIGINT = auto() +2984 FLOAT = auto() +2985 DOUBLE = auto() +2986 DECIMAL = auto() +2987 BIGDECIMAL = auto() +2988 BIT = auto() +2989 BOOLEAN = auto() +2990 JSON = auto() +2991 JSONB = auto() +2992 INTERVAL = auto() +2993 TIME = auto() +2994 TIMESTAMP = auto() +2995 TIMESTAMPTZ = auto() +2996 TIMESTAMPLTZ = auto() +2997 DATE = auto() +2998 DATETIME = auto() +2999 ARRAY = auto() +3000 MAP = auto() +3001 UUID = auto() +3002 GEOGRAPHY = auto() +3003 GEOMETRY = auto() +3004 STRUCT = auto() +3005 NULLABLE = auto() +3006 HLLSKETCH = auto() +3007 HSTORE = auto() +3008 SUPER = auto() +3009 SERIAL = auto() +3010 SMALLSERIAL = auto() +3011 BIGSERIAL = auto() +3012 XML = auto() +3013 UNIQUEIDENTIFIER = auto() +3014 MONEY = auto() +3015 SMALLMONEY = auto() +3016 ROWVERSION = auto() +3017 IMAGE = auto() +3018 VARIANT = auto() +3019 OBJECT = auto() +3020 INET = auto() +3021 NULL = auto() +3022 UNKNOWN = auto() # Sentinel value, useful for type annotation 3023 -3024 -3025class Connector(Binary, Condition): -3026 pass -3027 -3028 -3029class And(Connector): -3030 pass +3024 TEXT_TYPES = { +3025 Type.CHAR, +3026 Type.NCHAR, +3027 Type.VARCHAR, +3028 Type.NVARCHAR, +3029 Type.TEXT, +3030 } 3031 -3032 -3033class Or(Connector): -3034 pass -3035 -3036 -3037class BitwiseAnd(Binary): -3038 pass -3039 -3040 -3041class BitwiseLeftShift(Binary): -3042 pass +3032 INTEGER_TYPES = { +3033 Type.INT, +3034 Type.TINYINT, +3035 Type.SMALLINT, +3036 Type.BIGINT, +3037 } +3038 +3039 FLOAT_TYPES = { +3040 Type.FLOAT, +3041 Type.DOUBLE, +3042 } 3043 -3044 -3045class BitwiseOr(Binary): -3046 pass -3047 -3048 -3049class BitwiseRightShift(Binary): -3050 pass -3051 -3052 -3053class BitwiseXor(Binary): -3054 pass -3055 -3056 -3057class Div(Binary): -3058 pass +3044 NUMERIC_TYPES = {*INTEGER_TYPES, *FLOAT_TYPES} +3045 +3046 TEMPORAL_TYPES = { +3047 Type.TIMESTAMP, +3048 Type.TIMESTAMPTZ, +3049 Type.TIMESTAMPLTZ, +3050 Type.DATE, +3051 Type.DATETIME, +3052 } +3053 +3054 @classmethod +3055 def build( +3056 cls, dtype: str | DataType | DataType.Type, dialect: DialectType = None, **kwargs +3057 ) -> DataType: +3058 from sqlglot import parse_one 3059 -3060 -3061class Overlaps(Binary): -3062 pass -3063 -3064 -3065class Dot(Binary): -3066 @property -3067 def name(self) -> str: -3068 return self.expression.name -3069 -3070 @classmethod -3071 def build(self, expressions: t.Sequence[Expression]) -> Dot: -3072 """Build a Dot object with a sequence of expressions.""" -3073 if len(expressions) < 2: -3074 raise ValueError(f"Dot requires >= 2 expressions.") -3075 -3076 a, b, *expressions = expressions -3077 dot = Dot(this=a, expression=b) +3060 if isinstance(dtype, str): +3061 if dtype.upper() in cls.Type.__members__: +3062 data_type_exp: t.Optional[Expression] = DataType(this=DataType.Type[dtype.upper()]) +3063 else: +3064 data_type_exp = parse_one(dtype, read=dialect, into=DataType) +3065 if data_type_exp is None: +3066 raise ValueError(f"Unparsable data type value: {dtype}") +3067 elif isinstance(dtype, DataType.Type): +3068 data_type_exp = DataType(this=dtype) +3069 elif isinstance(dtype, DataType): +3070 return dtype +3071 else: +3072 raise ValueError(f"Invalid data type: {type(dtype)}. Expected str or DataType.Type") +3073 return DataType(**{**data_type_exp.args, **kwargs}) +3074 +3075 def is_type(self, dtype: DataType.Type) -> bool: +3076 return self.this == dtype +3077 3078 -3079 for expression in expressions: -3080 dot = Dot(this=dot, expression=expression) -3081 -3082 return dot +3079# https://www.postgresql.org/docs/15/datatype-pseudo.html +3080class PseudoType(Expression): +3081 pass +3082 3083 -3084 -3085class DPipe(Binary): -3086 pass +3084class StructKwarg(Expression): +3085 arg_types = {"this": True, "expression": True} +3086 3087 -3088 -3089class EQ(Binary, Predicate): +3088# WHERE x <OP> EXISTS|ALL|ANY|SOME(SELECT ...) +3089class SubqueryPredicate(Predicate): 3090 pass 3091 3092 -3093class NullSafeEQ(Binary, Predicate): +3093class All(SubqueryPredicate): 3094 pass 3095 3096 -3097class NullSafeNEQ(Binary, Predicate): +3097class Any(SubqueryPredicate): 3098 pass 3099 3100 -3101class Distance(Binary): +3101class Exists(SubqueryPredicate): 3102 pass 3103 3104 -3105class Escape(Binary): -3106 pass -3107 -3108 -3109class Glob(Binary, Predicate): -3110 pass -3111 -3112 -3113class GT(Binary, Predicate): -3114 pass -3115 -3116 -3117class GTE(Binary, Predicate): -3118 pass -3119 -3120 -3121class ILike(Binary, Predicate): -3122 pass -3123 -3124 -3125class ILikeAny(Binary, Predicate): -3126 pass -3127 -3128 -3129class IntDiv(Binary): -3130 pass -3131 -3132 -3133class Is(Binary, Predicate): -3134 pass -3135 -3136 -3137class Kwarg(Binary): -3138 """Kwarg in special functions like func(kwarg => y).""" -3139 -3140 -3141class Like(Binary, Predicate): -3142 pass -3143 -3144 -3145class LikeAny(Binary, Predicate): -3146 pass +3105# Commands to interact with the databases or engines. For most of the command +3106# expressions we parse whatever comes after the command's name as a string. +3107class Command(Expression): +3108 arg_types = {"this": True, "expression": False} +3109 +3110 +3111class Transaction(Expression): +3112 arg_types = {"this": False, "modes": False} +3113 +3114 +3115class Commit(Expression): +3116 arg_types = {"chain": False} +3117 +3118 +3119class Rollback(Expression): +3120 arg_types = {"savepoint": False} +3121 +3122 +3123class AlterTable(Expression): +3124 arg_types = {"this": True, "actions": True, "exists": False} +3125 +3126 +3127class AddConstraint(Expression): +3128 arg_types = {"this": False, "expression": False, "enforced": False} +3129 +3130 +3131class DropPartition(Expression): +3132 arg_types = {"expressions": True, "exists": False} +3133 +3134 +3135# Binary expressions like (ADD a b) +3136class Binary(Condition): +3137 arg_types = {"this": True, "expression": True} +3138 +3139 @property +3140 def left(self): +3141 return self.this +3142 +3143 @property +3144 def right(self): +3145 return self.expression +3146 3147 -3148 -3149class LT(Binary, Predicate): -3150 pass +3148class Add(Binary): +3149 pass +3150 3151 -3152 -3153class LTE(Binary, Predicate): -3154 pass +3152class Connector(Binary): +3153 pass +3154 3155 -3156 -3157class Mod(Binary): -3158 pass +3156class And(Connector): +3157 pass +3158 3159 -3160 -3161class Mul(Binary): -3162 pass +3160class Or(Connector): +3161 pass +3162 3163 -3164 -3165class NEQ(Binary, Predicate): -3166 pass +3164class BitwiseAnd(Binary): +3165 pass +3166 3167 -3168 -3169class SimilarTo(Binary, Predicate): -3170 pass +3168class BitwiseLeftShift(Binary): +3169 pass +3170 3171 -3172 -3173class Slice(Binary): -3174 arg_types = {"this": False, "expression": False} +3172class BitwiseOr(Binary): +3173 pass +3174 3175 -3176 -3177class Sub(Binary): -3178 pass +3176class BitwiseRightShift(Binary): +3177 pass +3178 3179 -3180 -3181class ArrayOverlaps(Binary): -3182 pass +3180class BitwiseXor(Binary): +3181 pass +3182 3183 -3184 -3185# Unary Expressions -3186# (NOT a) -3187class Unary(Expression): -3188 pass -3189 +3184class Div(Binary): +3185 pass +3186 +3187 +3188class Overlaps(Binary): +3189 pass 3190 -3191class BitwiseNot(Unary): -3192 pass -3193 -3194 -3195class Not(Unary, Condition): -3196 pass -3197 -3198 -3199class Paren(Unary, Condition): -3200 arg_types = {"this": True, "with": False} -3201 +3191 +3192class Dot(Binary): +3193 @property +3194 def name(self) -> str: +3195 return self.expression.name +3196 +3197 @classmethod +3198 def build(self, expressions: t.Sequence[Expression]) -> Dot: +3199 """Build a Dot object with a sequence of expressions.""" +3200 if len(expressions) < 2: +3201 raise ValueError(f"Dot requires >= 2 expressions.") 3202 -3203class Neg(Unary): -3204 pass +3203 a, b, *expressions = expressions +3204 dot = Dot(this=a, expression=b) 3205 -3206 -3207class Alias(Expression): -3208 arg_types = {"this": True, "alias": False} -3209 -3210 @property -3211 def output_name(self): -3212 return self.alias -3213 +3206 for expression in expressions: +3207 dot = Dot(this=dot, expression=expression) +3208 +3209 return dot +3210 +3211 +3212class DPipe(Binary): +3213 pass 3214 -3215class Aliases(Expression): -3216 arg_types = {"this": True, "expressions": True} -3217 -3218 @property -3219 def aliases(self): -3220 return self.expressions -3221 +3215 +3216class EQ(Binary, Predicate): +3217 pass +3218 +3219 +3220class NullSafeEQ(Binary, Predicate): +3221 pass 3222 -3223class AtTimeZone(Expression): -3224 arg_types = {"this": True, "zone": True} -3225 +3223 +3224class NullSafeNEQ(Binary, Predicate): +3225 pass 3226 -3227class Between(Predicate): -3228 arg_types = {"this": True, "low": True, "high": True} -3229 +3227 +3228class Distance(Binary): +3229 pass 3230 -3231class Bracket(Condition): -3232 arg_types = {"this": True, "expressions": True} -3233 +3231 +3232class Escape(Binary): +3233 pass 3234 -3235class Distinct(Expression): -3236 arg_types = {"expressions": False, "on": False} -3237 +3235 +3236class Glob(Binary, Predicate): +3237 pass 3238 -3239class In(Predicate): -3240 arg_types = { -3241 "this": True, -3242 "expressions": False, -3243 "query": False, -3244 "unnest": False, -3245 "field": False, -3246 "is_global": False, -3247 } -3248 -3249 -3250class TimeUnit(Expression): -3251 """Automatically converts unit arg into a var.""" -3252 -3253 arg_types = {"unit": False} +3239 +3240class GT(Binary, Predicate): +3241 pass +3242 +3243 +3244class GTE(Binary, Predicate): +3245 pass +3246 +3247 +3248class ILike(Binary, Predicate): +3249 pass +3250 +3251 +3252class ILikeAny(Binary, Predicate): +3253 pass 3254 -3255 def __init__(self, **args): -3256 unit = args.get("unit") -3257 if isinstance(unit, (Column, Literal)): -3258 args["unit"] = Var(this=unit.name) -3259 elif isinstance(unit, Week): -3260 unit.set("this", Var(this=unit.this.name)) -3261 super().__init__(**args) +3255 +3256class IntDiv(Binary): +3257 pass +3258 +3259 +3260class Is(Binary, Predicate): +3261 pass 3262 3263 -3264class Interval(TimeUnit): -3265 arg_types = {"this": False, "unit": False} +3264class Kwarg(Binary): +3265 """Kwarg in special functions like func(kwarg => y).""" 3266 3267 -3268class IgnoreNulls(Expression): +3268class Like(Binary, Predicate): 3269 pass 3270 3271 -3272class RespectNulls(Expression): +3272class LikeAny(Binary, Predicate): 3273 pass 3274 3275 -3276# Functions -3277class Func(Condition): -3278 """ -3279 The base class for all function expressions. -3280 -3281 Attributes: -3282 is_var_len_args (bool): if set to True the last argument defined in arg_types will be -3283 treated as a variable length argument and the argument's value will be stored as a list. -3284 _sql_names (list): determines the SQL name (1st item in the list) and aliases (subsequent items) -3285 for this function expression. These values are used to map this node to a name during parsing -3286 as well as to provide the function's name during SQL string generation. By default the SQL -3287 name is set to the expression's class name transformed to snake case. -3288 """ -3289 -3290 is_var_len_args = False +3276class LT(Binary, Predicate): +3277 pass +3278 +3279 +3280class LTE(Binary, Predicate): +3281 pass +3282 +3283 +3284class Mod(Binary): +3285 pass +3286 +3287 +3288class Mul(Binary): +3289 pass +3290 3291 -3292 @classmethod -3293 def from_arg_list(cls, args): -3294 if cls.is_var_len_args: -3295 all_arg_keys = list(cls.arg_types) -3296 # If this function supports variable length argument treat the last argument as such. -3297 non_var_len_arg_keys = all_arg_keys[:-1] if cls.is_var_len_args else all_arg_keys -3298 num_non_var = len(non_var_len_arg_keys) +3292class NEQ(Binary, Predicate): +3293 pass +3294 +3295 +3296class SimilarTo(Binary, Predicate): +3297 pass +3298 3299 -3300 args_dict = {arg_key: arg for arg, arg_key in zip(args, non_var_len_arg_keys)} -3301 args_dict[all_arg_keys[-1]] = args[num_non_var:] -3302 else: -3303 args_dict = {arg_key: arg for arg, arg_key in zip(args, cls.arg_types)} -3304 -3305 return cls(**args_dict) +3300class Slice(Binary): +3301 arg_types = {"this": False, "expression": False} +3302 +3303 +3304class Sub(Binary): +3305 pass 3306 -3307 @classmethod -3308 def sql_names(cls): -3309 if cls is Func: -3310 raise NotImplementedError( -3311 "SQL name is only supported by concrete function implementations" -3312 ) -3313 if "_sql_names" not in cls.__dict__: -3314 cls._sql_names = [camel_to_snake_case(cls.__name__)] -3315 return cls._sql_names +3307 +3308class ArrayOverlaps(Binary): +3309 pass +3310 +3311 +3312# Unary Expressions +3313# (NOT a) +3314class Unary(Condition): +3315 pass 3316 -3317 @classmethod -3318 def sql_name(cls): -3319 return cls.sql_names()[0] +3317 +3318class BitwiseNot(Unary): +3319 pass 3320 -3321 @classmethod -3322 def default_parser_mappings(cls): -3323 return {name: cls.from_arg_list for name in cls.sql_names()} +3321 +3322class Not(Unary): +3323 pass 3324 3325 -3326class AggFunc(Func): -3327 pass +3326class Paren(Unary): +3327 arg_types = {"this": True, "with": False} 3328 3329 -3330class Abs(Func): +3330class Neg(Unary): 3331 pass 3332 3333 -3334class Anonymous(Func): -3335 arg_types = {"this": True, "expressions": False} -3336 is_var_len_args = True -3337 -3338 -3339# https://docs.snowflake.com/en/sql-reference/functions/hll -3340# https://docs.aws.amazon.com/redshift/latest/dg/r_HLL_function.html -3341class Hll(AggFunc): -3342 arg_types = {"this": True, "expressions": False} -3343 is_var_len_args = True +3334class Alias(Expression): +3335 arg_types = {"this": True, "alias": False} +3336 +3337 @property +3338 def output_name(self): +3339 return self.alias +3340 +3341 +3342class Aliases(Expression): +3343 arg_types = {"this": True, "expressions": True} 3344 -3345 -3346class ApproxDistinct(AggFunc): -3347 arg_types = {"this": True, "accuracy": False} +3345 @property +3346 def aliases(self): +3347 return self.expressions 3348 3349 -3350class Array(Func): -3351 arg_types = {"expressions": False} -3352 is_var_len_args = True +3350class AtTimeZone(Expression): +3351 arg_types = {"this": True, "zone": True} +3352 3353 -3354 -3355# https://docs.snowflake.com/en/sql-reference/functions/to_char -3356class ToChar(Func): -3357 arg_types = {"this": True, "format": False} -3358 -3359 -3360class GenerateSeries(Func): -3361 arg_types = {"start": True, "end": True, "step": False} -3362 -3363 -3364class ArrayAgg(AggFunc): -3365 pass -3366 -3367 -3368class ArrayAll(Func): -3369 arg_types = {"this": True, "expression": True} -3370 -3371 -3372class ArrayAny(Func): -3373 arg_types = {"this": True, "expression": True} -3374 +3354class Between(Predicate): +3355 arg_types = {"this": True, "low": True, "high": True} +3356 +3357 +3358class Bracket(Condition): +3359 arg_types = {"this": True, "expressions": True} +3360 +3361 +3362class Distinct(Expression): +3363 arg_types = {"expressions": False, "on": False} +3364 +3365 +3366class In(Predicate): +3367 arg_types = { +3368 "this": True, +3369 "expressions": False, +3370 "query": False, +3371 "unnest": False, +3372 "field": False, +3373 "is_global": False, +3374 } 3375 -3376class ArrayConcat(Func): -3377 arg_types = {"this": True, "expressions": False} -3378 is_var_len_args = True +3376 +3377class TimeUnit(Expression): +3378 """Automatically converts unit arg into a var.""" 3379 -3380 -3381class ArrayContains(Binary, Func): -3382 pass -3383 -3384 -3385class ArrayContained(Binary): -3386 pass -3387 -3388 -3389class ArrayFilter(Func): -3390 arg_types = {"this": True, "expression": True} -3391 _sql_names = ["FILTER", "ARRAY_FILTER"] -3392 +3380 arg_types = {"unit": False} +3381 +3382 def __init__(self, **args): +3383 unit = args.get("unit") +3384 if isinstance(unit, (Column, Literal)): +3385 args["unit"] = Var(this=unit.name) +3386 elif isinstance(unit, Week): +3387 unit.set("this", Var(this=unit.this.name)) +3388 super().__init__(**args) +3389 +3390 +3391class Interval(TimeUnit): +3392 arg_types = {"this": False, "unit": False} 3393 -3394class ArrayJoin(Func): -3395 arg_types = {"this": True, "expression": True, "null": False} -3396 +3394 +3395class IgnoreNulls(Expression): +3396 pass 3397 -3398class ArraySize(Func): -3399 arg_types = {"this": True, "expression": False} -3400 +3398 +3399class RespectNulls(Expression): +3400 pass 3401 -3402class ArraySort(Func): -3403 arg_types = {"this": True, "expression": False} -3404 -3405 -3406class ArraySum(Func): -3407 pass -3408 -3409 -3410class ArrayUnionAgg(AggFunc): -3411 pass -3412 -3413 -3414class Avg(AggFunc): -3415 pass +3402 +3403# Functions +3404class Func(Condition): +3405 """ +3406 The base class for all function expressions. +3407 +3408 Attributes: +3409 is_var_len_args (bool): if set to True the last argument defined in arg_types will be +3410 treated as a variable length argument and the argument's value will be stored as a list. +3411 _sql_names (list): determines the SQL name (1st item in the list) and aliases (subsequent items) +3412 for this function expression. These values are used to map this node to a name during parsing +3413 as well as to provide the function's name during SQL string generation. By default the SQL +3414 name is set to the expression's class name transformed to snake case. +3415 """ 3416 -3417 -3418class AnyValue(AggFunc): -3419 pass -3420 -3421 -3422class Case(Func): -3423 arg_types = {"this": False, "ifs": True, "default": False} -3424 -3425 -3426class Cast(Func): -3427 arg_types = {"this": True, "to": True} -3428 -3429 @property -3430 def name(self) -> str: -3431 return self.this.name -3432 -3433 @property -3434 def to(self): -3435 return self.args["to"] -3436 -3437 @property -3438 def output_name(self): -3439 return self.name -3440 -3441 def is_type(self, dtype: DataType.Type) -> bool: -3442 return self.to.is_type(dtype) +3417 is_var_len_args = False +3418 +3419 @classmethod +3420 def from_arg_list(cls, args): +3421 if cls.is_var_len_args: +3422 all_arg_keys = list(cls.arg_types) +3423 # If this function supports variable length argument treat the last argument as such. +3424 non_var_len_arg_keys = all_arg_keys[:-1] if cls.is_var_len_args else all_arg_keys +3425 num_non_var = len(non_var_len_arg_keys) +3426 +3427 args_dict = {arg_key: arg for arg, arg_key in zip(args, non_var_len_arg_keys)} +3428 args_dict[all_arg_keys[-1]] = args[num_non_var:] +3429 else: +3430 args_dict = {arg_key: arg for arg, arg_key in zip(args, cls.arg_types)} +3431 +3432 return cls(**args_dict) +3433 +3434 @classmethod +3435 def sql_names(cls): +3436 if cls is Func: +3437 raise NotImplementedError( +3438 "SQL name is only supported by concrete function implementations" +3439 ) +3440 if "_sql_names" not in cls.__dict__: +3441 cls._sql_names = [camel_to_snake_case(cls.__name__)] +3442 return cls._sql_names 3443 -3444 -3445class Collate(Binary): -3446 pass +3444 @classmethod +3445 def sql_name(cls): +3446 return cls.sql_names()[0] 3447 -3448 -3449class TryCast(Cast): -3450 pass +3448 @classmethod +3449 def default_parser_mappings(cls): +3450 return {name: cls.from_arg_list for name in cls.sql_names()} 3451 3452 -3453class Ceil(Func): -3454 arg_types = {"this": True, "decimals": False} -3455 _sql_names = ["CEIL", "CEILING"] +3453class AggFunc(Func): +3454 pass +3455 3456 -3457 -3458class Coalesce(Func): -3459 arg_types = {"this": True, "expressions": False} -3460 is_var_len_args = True -3461 -3462 -3463class Concat(Func): -3464 arg_types = {"expressions": True} -3465 is_var_len_args = True -3466 -3467 -3468class ConcatWs(Concat): -3469 _sql_names = ["CONCAT_WS"] -3470 +3457class Abs(Func): +3458 pass +3459 +3460 +3461class Anonymous(Func): +3462 arg_types = {"this": True, "expressions": False} +3463 is_var_len_args = True +3464 +3465 +3466# https://docs.snowflake.com/en/sql-reference/functions/hll +3467# https://docs.aws.amazon.com/redshift/latest/dg/r_HLL_function.html +3468class Hll(AggFunc): +3469 arg_types = {"this": True, "expressions": False} +3470 is_var_len_args = True 3471 -3472class Count(AggFunc): -3473 arg_types = {"this": False} -3474 +3472 +3473class ApproxDistinct(AggFunc): +3474 arg_types = {"this": True, "accuracy": False} 3475 -3476class CountIf(AggFunc): -3477 pass -3478 -3479 -3480class CurrentDate(Func): -3481 arg_types = {"this": False} -3482 -3483 -3484class CurrentDatetime(Func): -3485 arg_types = {"this": False} +3476 +3477class Array(Func): +3478 arg_types = {"expressions": False} +3479 is_var_len_args = True +3480 +3481 +3482# https://docs.snowflake.com/en/sql-reference/functions/to_char +3483class ToChar(Func): +3484 arg_types = {"this": True, "format": False} +3485 3486 -3487 -3488class CurrentTime(Func): -3489 arg_types = {"this": False} +3487class GenerateSeries(Func): +3488 arg_types = {"start": True, "end": True, "step": False} +3489 3490 -3491 -3492class CurrentTimestamp(Func): -3493 arg_types = {"this": False} +3491class ArrayAgg(AggFunc): +3492 pass +3493 3494 -3495 -3496class CurrentUser(Func): -3497 arg_types = {"this": False} +3495class ArrayAll(Func): +3496 arg_types = {"this": True, "expression": True} +3497 3498 -3499 -3500class DateAdd(Func, TimeUnit): -3501 arg_types = {"this": True, "expression": True, "unit": False} +3499class ArrayAny(Func): +3500 arg_types = {"this": True, "expression": True} +3501 3502 -3503 -3504class DateSub(Func, TimeUnit): -3505 arg_types = {"this": True, "expression": True, "unit": False} +3503class ArrayConcat(Func): +3504 arg_types = {"this": True, "expressions": False} +3505 is_var_len_args = True 3506 3507 -3508class DateDiff(Func, TimeUnit): -3509 _sql_names = ["DATEDIFF", "DATE_DIFF"] -3510 arg_types = {"this": True, "expression": True, "unit": False} +3508class ArrayContains(Binary, Func): +3509 pass +3510 3511 -3512 -3513class DateTrunc(Func): -3514 arg_types = {"unit": True, "this": True, "zone": False} +3512class ArrayContained(Binary): +3513 pass +3514 3515 -3516 -3517class DatetimeAdd(Func, TimeUnit): -3518 arg_types = {"this": True, "expression": True, "unit": False} +3516class ArrayFilter(Func): +3517 arg_types = {"this": True, "expression": True} +3518 _sql_names = ["FILTER", "ARRAY_FILTER"] 3519 3520 -3521class DatetimeSub(Func, TimeUnit): -3522 arg_types = {"this": True, "expression": True, "unit": False} +3521class ArrayJoin(Func): +3522 arg_types = {"this": True, "expression": True, "null": False} 3523 3524 -3525class DatetimeDiff(Func, TimeUnit): -3526 arg_types = {"this": True, "expression": True, "unit": False} +3525class ArraySize(Func): +3526 arg_types = {"this": True, "expression": False} 3527 3528 -3529class DatetimeTrunc(Func, TimeUnit): -3530 arg_types = {"this": True, "unit": True, "zone": False} +3529class ArraySort(Func): +3530 arg_types = {"this": True, "expression": False} 3531 3532 -3533class DayOfWeek(Func): -3534 _sql_names = ["DAY_OF_WEEK", "DAYOFWEEK"] +3533class ArraySum(Func): +3534 pass 3535 3536 -3537class DayOfMonth(Func): -3538 _sql_names = ["DAY_OF_MONTH", "DAYOFMONTH"] +3537class ArrayUnionAgg(AggFunc): +3538 pass 3539 3540 -3541class DayOfYear(Func): -3542 _sql_names = ["DAY_OF_YEAR", "DAYOFYEAR"] +3541class Avg(AggFunc): +3542 pass 3543 3544 -3545class WeekOfYear(Func): -3546 _sql_names = ["WEEK_OF_YEAR", "WEEKOFYEAR"] +3545class AnyValue(AggFunc): +3546 pass 3547 3548 -3549class LastDateOfMonth(Func): -3550 pass +3549class Case(Func): +3550 arg_types = {"this": False, "ifs": True, "default": False} 3551 -3552 -3553class Extract(Func): -3554 arg_types = {"this": True, "expression": True} -3555 -3556 -3557class TimestampAdd(Func, TimeUnit): -3558 arg_types = {"this": True, "expression": True, "unit": False} -3559 -3560 -3561class TimestampSub(Func, TimeUnit): -3562 arg_types = {"this": True, "expression": True, "unit": False} -3563 -3564 -3565class TimestampDiff(Func, TimeUnit): -3566 arg_types = {"this": True, "expression": True, "unit": False} +3552 def when(self, condition: ExpOrStr, then: ExpOrStr, copy: bool = True, **opts) -> Case: +3553 instance = _maybe_copy(self, copy) +3554 instance.append( +3555 "ifs", +3556 If( +3557 this=maybe_parse(condition, copy=copy, **opts), +3558 true=maybe_parse(then, copy=copy, **opts), +3559 ), +3560 ) +3561 return instance +3562 +3563 def else_(self, condition: ExpOrStr, copy: bool = True, **opts) -> Case: +3564 instance = _maybe_copy(self, copy) +3565 instance.set("default", maybe_parse(condition, copy=copy, **opts)) +3566 return instance 3567 3568 -3569class TimestampTrunc(Func, TimeUnit): -3570 arg_types = {"this": True, "unit": True, "zone": False} +3569class Cast(Func): +3570 arg_types = {"this": True, "to": True} 3571 -3572 -3573class TimeAdd(Func, TimeUnit): -3574 arg_types = {"this": True, "expression": True, "unit": False} +3572 @property +3573 def name(self) -> str: +3574 return self.this.name 3575 -3576 -3577class TimeSub(Func, TimeUnit): -3578 arg_types = {"this": True, "expression": True, "unit": False} +3576 @property +3577 def to(self): +3578 return self.args["to"] 3579 -3580 -3581class TimeDiff(Func, TimeUnit): -3582 arg_types = {"this": True, "expression": True, "unit": False} +3580 @property +3581 def output_name(self): +3582 return self.name 3583 -3584 -3585class TimeTrunc(Func, TimeUnit): -3586 arg_types = {"this": True, "unit": True, "zone": False} +3584 def is_type(self, dtype: DataType.Type) -> bool: +3585 return self.to.is_type(dtype) +3586 3587 -3588 -3589class DateFromParts(Func): -3590 _sql_names = ["DATEFROMPARTS"] -3591 arg_types = {"year": True, "month": True, "day": True} -3592 -3593 -3594class DateStrToDate(Func): -3595 pass -3596 -3597 -3598class DateToDateStr(Func): -3599 pass +3588class Collate(Binary): +3589 pass +3590 +3591 +3592class TryCast(Cast): +3593 pass +3594 +3595 +3596class Ceil(Func): +3597 arg_types = {"this": True, "decimals": False} +3598 _sql_names = ["CEIL", "CEILING"] +3599 3600 -3601 -3602class DateToDi(Func): -3603 pass +3601class Coalesce(Func): +3602 arg_types = {"this": True, "expressions": False} +3603 is_var_len_args = True 3604 3605 -3606class Day(Func): -3607 pass -3608 +3606class Concat(Func): +3607 arg_types = {"expressions": True} +3608 is_var_len_args = True 3609 -3610class Decode(Func): -3611 arg_types = {"this": True, "charset": True, "replace": False} -3612 +3610 +3611class ConcatWs(Concat): +3612 _sql_names = ["CONCAT_WS"] 3613 -3614class DiToDate(Func): -3615 pass -3616 +3614 +3615class Count(AggFunc): +3616 arg_types = {"this": False} 3617 -3618class Encode(Func): -3619 arg_types = {"this": True, "charset": True} -3620 +3618 +3619class CountIf(AggFunc): +3620 pass 3621 -3622class Exp(Func): -3623 pass -3624 +3622 +3623class CurrentDate(Func): +3624 arg_types = {"this": False} 3625 -3626class Explode(Func): -3627 pass -3628 +3626 +3627class CurrentDatetime(Func): +3628 arg_types = {"this": False} 3629 -3630class ExponentialTimeDecayedAvg(AggFunc): -3631 arg_types = {"this": True, "time": False, "decay": False} -3632 +3630 +3631class CurrentTime(Func): +3632 arg_types = {"this": False} 3633 -3634class Floor(Func): -3635 arg_types = {"this": True, "decimals": False} -3636 +3634 +3635class CurrentTimestamp(Func): +3636 arg_types = {"this": False} 3637 -3638class Greatest(Func): -3639 arg_types = {"this": True, "expressions": False} -3640 is_var_len_args = True +3638 +3639class CurrentUser(Func): +3640 arg_types = {"this": False} 3641 3642 -3643class GroupConcat(Func): -3644 arg_types = {"this": True, "separator": False} +3643class DateAdd(Func, TimeUnit): +3644 arg_types = {"this": True, "expression": True, "unit": False} 3645 3646 -3647class GroupUniqArray(AggFunc): -3648 arg_types = {"this": True, "size": False} +3647class DateSub(Func, TimeUnit): +3648 arg_types = {"this": True, "expression": True, "unit": False} 3649 3650 -3651class Hex(Func): -3652 pass -3653 +3651class DateDiff(Func, TimeUnit): +3652 _sql_names = ["DATEDIFF", "DATE_DIFF"] +3653 arg_types = {"this": True, "expression": True, "unit": False} 3654 -3655class Histogram(AggFunc): -3656 arg_types = {"this": True, "bins": False} -3657 +3655 +3656class DateTrunc(Func): +3657 arg_types = {"unit": True, "this": True, "zone": False} 3658 -3659class If(Func): -3660 arg_types = {"this": True, "true": True, "false": False} -3661 +3659 +3660class DatetimeAdd(Func, TimeUnit): +3661 arg_types = {"this": True, "expression": True, "unit": False} 3662 -3663class IfNull(Func): -3664 arg_types = {"this": True, "expression": False} -3665 _sql_names = ["IFNULL", "NVL"] +3663 +3664class DatetimeSub(Func, TimeUnit): +3665 arg_types = {"this": True, "expression": True, "unit": False} 3666 3667 -3668class Initcap(Func): -3669 pass +3668class DatetimeDiff(Func, TimeUnit): +3669 arg_types = {"this": True, "expression": True, "unit": False} 3670 3671 -3672class JSONKeyValue(Expression): -3673 arg_types = {"this": True, "expression": True} +3672class DatetimeTrunc(Func, TimeUnit): +3673 arg_types = {"this": True, "unit": True, "zone": False} 3674 3675 -3676class JSONObject(Func): -3677 arg_types = { -3678 "expressions": False, -3679 "null_handling": False, -3680 "unique_keys": False, -3681 "return_type": False, -3682 "format_json": False, -3683 "encoding": False, -3684 } -3685 +3676class DayOfWeek(Func): +3677 _sql_names = ["DAY_OF_WEEK", "DAYOFWEEK"] +3678 +3679 +3680class DayOfMonth(Func): +3681 _sql_names = ["DAY_OF_MONTH", "DAYOFMONTH"] +3682 +3683 +3684class DayOfYear(Func): +3685 _sql_names = ["DAY_OF_YEAR", "DAYOFYEAR"] 3686 -3687class JSONBContains(Binary): -3688 _sql_names = ["JSONB_CONTAINS"] -3689 +3687 +3688class WeekOfYear(Func): +3689 _sql_names = ["WEEK_OF_YEAR", "WEEKOFYEAR"] 3690 -3691class JSONExtract(Binary, Func): -3692 _sql_names = ["JSON_EXTRACT"] -3693 +3691 +3692class LastDateOfMonth(Func): +3693 pass 3694 -3695class JSONExtractScalar(JSONExtract): -3696 _sql_names = ["JSON_EXTRACT_SCALAR"] -3697 +3695 +3696class Extract(Func): +3697 arg_types = {"this": True, "expression": True} 3698 -3699class JSONBExtract(JSONExtract): -3700 _sql_names = ["JSONB_EXTRACT"] -3701 +3699 +3700class TimestampAdd(Func, TimeUnit): +3701 arg_types = {"this": True, "expression": True, "unit": False} 3702 -3703class JSONBExtractScalar(JSONExtract): -3704 _sql_names = ["JSONB_EXTRACT_SCALAR"] -3705 +3703 +3704class TimestampSub(Func, TimeUnit): +3705 arg_types = {"this": True, "expression": True, "unit": False} 3706 -3707class JSONFormat(Func): -3708 arg_types = {"this": False, "options": False} -3709 _sql_names = ["JSON_FORMAT"] +3707 +3708class TimestampDiff(Func, TimeUnit): +3709 arg_types = {"this": True, "expression": True, "unit": False} 3710 3711 -3712class Least(Func): -3713 arg_types = {"expressions": False} -3714 is_var_len_args = True +3712class TimestampTrunc(Func, TimeUnit): +3713 arg_types = {"this": True, "unit": True, "zone": False} +3714 3715 -3716 -3717class Length(Func): -3718 pass +3716class TimeAdd(Func, TimeUnit): +3717 arg_types = {"this": True, "expression": True, "unit": False} +3718 3719 -3720 -3721class Levenshtein(Func): -3722 arg_types = { -3723 "this": True, -3724 "expression": False, -3725 "ins_cost": False, -3726 "del_cost": False, -3727 "sub_cost": False, -3728 } -3729 +3720class TimeSub(Func, TimeUnit): +3721 arg_types = {"this": True, "expression": True, "unit": False} +3722 +3723 +3724class TimeDiff(Func, TimeUnit): +3725 arg_types = {"this": True, "expression": True, "unit": False} +3726 +3727 +3728class TimeTrunc(Func, TimeUnit): +3729 arg_types = {"this": True, "unit": True, "zone": False} 3730 -3731class Ln(Func): -3732 pass -3733 -3734 -3735class Log(Func): -3736 arg_types = {"this": True, "expression": False} -3737 -3738 -3739class Log2(Func): -3740 pass -3741 -3742 -3743class Log10(Func): -3744 pass -3745 -3746 -3747class LogicalOr(AggFunc): -3748 _sql_names = ["LOGICAL_OR", "BOOL_OR", "BOOLOR_AGG"] -3749 -3750 -3751class LogicalAnd(AggFunc): -3752 _sql_names = ["LOGICAL_AND", "BOOL_AND", "BOOLAND_AGG"] -3753 -3754 -3755class Lower(Func): -3756 _sql_names = ["LOWER", "LCASE"] -3757 -3758 -3759class Map(Func): -3760 arg_types = {"keys": False, "values": False} -3761 -3762 -3763class StarMap(Func): -3764 pass -3765 -3766 -3767class VarMap(Func): -3768 arg_types = {"keys": True, "values": True} -3769 is_var_len_args = True -3770 +3731 +3732class DateFromParts(Func): +3733 _sql_names = ["DATEFROMPARTS"] +3734 arg_types = {"year": True, "month": True, "day": True} +3735 +3736 +3737class DateStrToDate(Func): +3738 pass +3739 +3740 +3741class DateToDateStr(Func): +3742 pass +3743 +3744 +3745class DateToDi(Func): +3746 pass +3747 +3748 +3749class Day(Func): +3750 pass +3751 +3752 +3753class Decode(Func): +3754 arg_types = {"this": True, "charset": True, "replace": False} +3755 +3756 +3757class DiToDate(Func): +3758 pass +3759 +3760 +3761class Encode(Func): +3762 arg_types = {"this": True, "charset": True} +3763 +3764 +3765class Exp(Func): +3766 pass +3767 +3768 +3769class Explode(Func): +3770 pass 3771 -3772# https://dev.mysql.com/doc/refman/8.0/en/fulltext-search.html -3773class MatchAgainst(Func): -3774 arg_types = {"this": True, "expressions": True, "modifier": False} +3772 +3773class ExponentialTimeDecayedAvg(AggFunc): +3774 arg_types = {"this": True, "time": False, "decay": False} 3775 3776 -3777class Max(AggFunc): -3778 arg_types = {"this": True, "expressions": False} -3779 is_var_len_args = True +3777class Floor(Func): +3778 arg_types = {"this": True, "decimals": False} +3779 3780 -3781 -3782class MD5(Func): -3783 _sql_names = ["MD5"] +3781class Greatest(Func): +3782 arg_types = {"this": True, "expressions": False} +3783 is_var_len_args = True 3784 3785 -3786class Min(AggFunc): -3787 arg_types = {"this": True, "expressions": False} -3788 is_var_len_args = True +3786class GroupConcat(Func): +3787 arg_types = {"this": True, "separator": False} +3788 3789 -3790 -3791class Month(Func): -3792 pass +3790class GroupUniqArray(AggFunc): +3791 arg_types = {"this": True, "size": False} +3792 3793 -3794 -3795class Nvl2(Func): -3796 arg_types = {"this": True, "true": True, "false": False} +3794class Hex(Func): +3795 pass +3796 3797 -3798 -3799class Posexplode(Func): -3800 pass +3798class Histogram(AggFunc): +3799 arg_types = {"this": True, "bins": False} +3800 3801 -3802 -3803class Pow(Binary, Func): -3804 _sql_names = ["POWER", "POW"] +3802class If(Func): +3803 arg_types = {"this": True, "true": True, "false": False} +3804 3805 -3806 -3807class PercentileCont(AggFunc): -3808 pass +3806class IfNull(Func): +3807 arg_types = {"this": True, "expression": False} +3808 _sql_names = ["IFNULL", "NVL"] 3809 3810 -3811class PercentileDisc(AggFunc): +3811class Initcap(Func): 3812 pass 3813 3814 -3815class Quantile(AggFunc): -3816 arg_types = {"this": True, "quantile": True} +3815class JSONKeyValue(Expression): +3816 arg_types = {"this": True, "expression": True} 3817 3818 -3819# Clickhouse-specific: -3820# https://clickhouse.com/docs/en/sql-reference/aggregate-functions/reference/quantiles/#quantiles -3821class Quantiles(AggFunc): -3822 arg_types = {"parameters": True, "expressions": True} -3823 is_var_len_args = True -3824 -3825 -3826class QuantileIf(AggFunc): -3827 arg_types = {"parameters": True, "expressions": True} +3819class JSONObject(Func): +3820 arg_types = { +3821 "expressions": False, +3822 "null_handling": False, +3823 "unique_keys": False, +3824 "return_type": False, +3825 "format_json": False, +3826 "encoding": False, +3827 } 3828 3829 -3830class ApproxQuantile(Quantile): -3831 arg_types = {"this": True, "quantile": True, "accuracy": False, "weight": False} +3830class JSONBContains(Binary): +3831 _sql_names = ["JSONB_CONTAINS"] 3832 3833 -3834class RangeN(Func): -3835 arg_types = {"this": True, "expressions": True, "each": False} +3834class JSONExtract(Binary, Func): +3835 _sql_names = ["JSON_EXTRACT"] 3836 3837 -3838class ReadCSV(Func): -3839 _sql_names = ["READ_CSV"] -3840 is_var_len_args = True -3841 arg_types = {"this": True, "expressions": False} -3842 -3843 -3844class Reduce(Func): -3845 arg_types = {"this": True, "initial": True, "merge": True, "finish": False} -3846 -3847 -3848class RegexpExtract(Func): -3849 arg_types = { -3850 "this": True, -3851 "expression": True, -3852 "position": False, -3853 "occurrence": False, -3854 "group": False, -3855 } -3856 -3857 -3858class RegexpLike(Func): -3859 arg_types = {"this": True, "expression": True, "flag": False} -3860 -3861 -3862class RegexpILike(Func): -3863 arg_types = {"this": True, "expression": True, "flag": False} -3864 -3865 -3866# https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.functions.split.html -3867# limit is the number of times a pattern is applied -3868class RegexpSplit(Func): -3869 arg_types = {"this": True, "expression": True, "limit": False} -3870 -3871 -3872class Repeat(Func): -3873 arg_types = {"this": True, "times": True} -3874 -3875 -3876class Round(Func): -3877 arg_types = {"this": True, "decimals": False} -3878 -3879 -3880class RowNumber(Func): -3881 arg_types: t.Dict[str, t.Any] = {} -3882 -3883 -3884class SafeDivide(Func): -3885 arg_types = {"this": True, "expression": True} -3886 -3887 -3888class SetAgg(AggFunc): -3889 pass -3890 -3891 -3892class SHA(Func): -3893 _sql_names = ["SHA", "SHA1"] -3894 -3895 -3896class SHA2(Func): -3897 _sql_names = ["SHA2"] -3898 arg_types = {"this": True, "length": False} -3899 +3838class JSONExtractScalar(JSONExtract): +3839 _sql_names = ["JSON_EXTRACT_SCALAR"] +3840 +3841 +3842class JSONBExtract(JSONExtract): +3843 _sql_names = ["JSONB_EXTRACT"] +3844 +3845 +3846class JSONBExtractScalar(JSONExtract): +3847 _sql_names = ["JSONB_EXTRACT_SCALAR"] +3848 +3849 +3850class JSONFormat(Func): +3851 arg_types = {"this": False, "options": False} +3852 _sql_names = ["JSON_FORMAT"] +3853 +3854 +3855class Least(Func): +3856 arg_types = {"expressions": False} +3857 is_var_len_args = True +3858 +3859 +3860class Length(Func): +3861 pass +3862 +3863 +3864class Levenshtein(Func): +3865 arg_types = { +3866 "this": True, +3867 "expression": False, +3868 "ins_cost": False, +3869 "del_cost": False, +3870 "sub_cost": False, +3871 } +3872 +3873 +3874class Ln(Func): +3875 pass +3876 +3877 +3878class Log(Func): +3879 arg_types = {"this": True, "expression": False} +3880 +3881 +3882class Log2(Func): +3883 pass +3884 +3885 +3886class Log10(Func): +3887 pass +3888 +3889 +3890class LogicalOr(AggFunc): +3891 _sql_names = ["LOGICAL_OR", "BOOL_OR", "BOOLOR_AGG"] +3892 +3893 +3894class LogicalAnd(AggFunc): +3895 _sql_names = ["LOGICAL_AND", "BOOL_AND", "BOOLAND_AGG"] +3896 +3897 +3898class Lower(Func): +3899 _sql_names = ["LOWER", "LCASE"] 3900 -3901class SortArray(Func): -3902 arg_types = {"this": True, "asc": False} -3903 +3901 +3902class Map(Func): +3903 arg_types = {"keys": False, "values": False} 3904 -3905class Split(Func): -3906 arg_types = {"this": True, "expression": True, "limit": False} -3907 +3905 +3906class StarMap(Func): +3907 pass 3908 -3909# Start may be omitted in the case of postgres -3910# https://www.postgresql.org/docs/9.1/functions-string.html @ Table 9-6 -3911class Substring(Func): -3912 arg_types = {"this": True, "start": False, "length": False} +3909 +3910class VarMap(Func): +3911 arg_types = {"keys": True, "values": True} +3912 is_var_len_args = True 3913 3914 -3915class StrPosition(Func): -3916 arg_types = { -3917 "this": True, -3918 "substr": True, -3919 "position": False, -3920 "instance": False, -3921 } -3922 +3915# https://dev.mysql.com/doc/refman/8.0/en/fulltext-search.html +3916class MatchAgainst(Func): +3917 arg_types = {"this": True, "expressions": True, "modifier": False} +3918 +3919 +3920class Max(AggFunc): +3921 arg_types = {"this": True, "expressions": False} +3922 is_var_len_args = True 3923 -3924class StrToDate(Func): -3925 arg_types = {"this": True, "format": True} -3926 +3924 +3925class MD5(Func): +3926 _sql_names = ["MD5"] 3927 -3928class StrToTime(Func): -3929 arg_types = {"this": True, "format": True} -3930 -3931 -3932# Spark allows unix_timestamp() -3933# https://spark.apache.org/docs/3.1.3/api/python/reference/api/pyspark.sql.functions.unix_timestamp.html -3934class StrToUnix(Func): -3935 arg_types = {"this": False, "format": False} +3928 +3929class Min(AggFunc): +3930 arg_types = {"this": True, "expressions": False} +3931 is_var_len_args = True +3932 +3933 +3934class Month(Func): +3935 pass 3936 3937 -3938class NumberToStr(Func): -3939 arg_types = {"this": True, "format": True} +3938class Nvl2(Func): +3939 arg_types = {"this": True, "true": True, "false": False} 3940 3941 -3942class Struct(Func): -3943 arg_types = {"expressions": True} -3944 is_var_len_args = True +3942class Posexplode(Func): +3943 pass +3944 3945 -3946 -3947class StructExtract(Func): -3948 arg_types = {"this": True, "expression": True} +3946class Pow(Binary, Func): +3947 _sql_names = ["POWER", "POW"] +3948 3949 -3950 -3951class Sum(AggFunc): -3952 pass +3950class PercentileCont(AggFunc): +3951 arg_types = {"this": True, "expression": False} +3952 3953 -3954 -3955class Sqrt(Func): -3956 pass +3954class PercentileDisc(AggFunc): +3955 arg_types = {"this": True, "expression": False} +3956 3957 -3958 -3959class Stddev(AggFunc): -3960 pass +3958class Quantile(AggFunc): +3959 arg_types = {"this": True, "quantile": True} +3960 3961 -3962 -3963class StddevPop(AggFunc): -3964 pass -3965 -3966 -3967class StddevSamp(AggFunc): -3968 pass -3969 -3970 -3971class TimeToStr(Func): -3972 arg_types = {"this": True, "format": True} -3973 -3974 -3975class TimeToTimeStr(Func): -3976 pass -3977 -3978 -3979class TimeToUnix(Func): -3980 pass -3981 -3982 -3983class TimeStrToDate(Func): -3984 pass +3962# Clickhouse-specific: +3963# https://clickhouse.com/docs/en/sql-reference/aggregate-functions/reference/quantiles/#quantiles +3964class Quantiles(AggFunc): +3965 arg_types = {"parameters": True, "expressions": True} +3966 is_var_len_args = True +3967 +3968 +3969class QuantileIf(AggFunc): +3970 arg_types = {"parameters": True, "expressions": True} +3971 +3972 +3973class ApproxQuantile(Quantile): +3974 arg_types = {"this": True, "quantile": True, "accuracy": False, "weight": False} +3975 +3976 +3977class RangeN(Func): +3978 arg_types = {"this": True, "expressions": True, "each": False} +3979 +3980 +3981class ReadCSV(Func): +3982 _sql_names = ["READ_CSV"] +3983 is_var_len_args = True +3984 arg_types = {"this": True, "expressions": False} 3985 3986 -3987class TimeStrToTime(Func): -3988 pass +3987class Reduce(Func): +3988 arg_types = {"this": True, "initial": True, "merge": True, "finish": False} 3989 3990 -3991class TimeStrToUnix(Func): -3992 pass -3993 -3994 -3995class Trim(Func): -3996 arg_types = { -3997 "this": True, -3998 "expression": False, -3999 "position": False, -4000 "collation": False, -4001 } -4002 +3991class RegexpExtract(Func): +3992 arg_types = { +3993 "this": True, +3994 "expression": True, +3995 "position": False, +3996 "occurrence": False, +3997 "group": False, +3998 } +3999 +4000 +4001class RegexpLike(Func): +4002 arg_types = {"this": True, "expression": True, "flag": False} 4003 -4004class TsOrDsAdd(Func, TimeUnit): -4005 arg_types = {"this": True, "expression": True, "unit": False} -4006 +4004 +4005class RegexpILike(Func): +4006 arg_types = {"this": True, "expression": True, "flag": False} 4007 -4008class TsOrDsToDateStr(Func): -4009 pass -4010 -4011 -4012class TsOrDsToDate(Func): -4013 arg_types = {"this": True, "format": False} +4008 +4009# https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.functions.split.html +4010# limit is the number of times a pattern is applied +4011class RegexpSplit(Func): +4012 arg_types = {"this": True, "expression": True, "limit": False} +4013 4014 -4015 -4016class TsOrDiToDi(Func): -4017 pass +4015class Repeat(Func): +4016 arg_types = {"this": True, "times": True} +4017 4018 -4019 -4020class Unhex(Func): -4021 pass +4019class Round(Func): +4020 arg_types = {"this": True, "decimals": False} +4021 4022 -4023 -4024class UnixToStr(Func): -4025 arg_types = {"this": True, "format": False} +4023class RowNumber(Func): +4024 arg_types: t.Dict[str, t.Any] = {} +4025 4026 -4027 -4028# https://prestodb.io/docs/current/functions/datetime.html -4029# presto has weird zone/hours/minutes -4030class UnixToTime(Func): -4031 arg_types = {"this": True, "scale": False, "zone": False, "hours": False, "minutes": False} -4032 -4033 SECONDS = Literal.string("seconds") -4034 MILLIS = Literal.string("millis") -4035 MICROS = Literal.string("micros") -4036 +4027class SafeDivide(Func): +4028 arg_types = {"this": True, "expression": True} +4029 +4030 +4031class SetAgg(AggFunc): +4032 pass +4033 +4034 +4035class SHA(Func): +4036 _sql_names = ["SHA", "SHA1"] 4037 -4038class UnixToTimeStr(Func): -4039 pass -4040 -4041 -4042class Upper(Func): -4043 _sql_names = ["UPPER", "UCASE"] -4044 -4045 -4046class Variance(AggFunc): -4047 _sql_names = ["VARIANCE", "VARIANCE_SAMP", "VAR_SAMP"] -4048 -4049 -4050class VariancePop(AggFunc): -4051 _sql_names = ["VARIANCE_POP", "VAR_POP"] -4052 -4053 -4054class Week(Func): -4055 arg_types = {"this": True, "mode": False} +4038 +4039class SHA2(Func): +4040 _sql_names = ["SHA2"] +4041 arg_types = {"this": True, "length": False} +4042 +4043 +4044class SortArray(Func): +4045 arg_types = {"this": True, "asc": False} +4046 +4047 +4048class Split(Func): +4049 arg_types = {"this": True, "expression": True, "limit": False} +4050 +4051 +4052# Start may be omitted in the case of postgres +4053# https://www.postgresql.org/docs/9.1/functions-string.html @ Table 9-6 +4054class Substring(Func): +4055 arg_types = {"this": True, "start": False, "length": False} 4056 4057 -4058class XMLTable(Func): -4059 arg_types = {"this": True, "passing": False, "columns": False, "by_ref": False} -4060 -4061 -4062class Year(Func): -4063 pass -4064 +4058class StrPosition(Func): +4059 arg_types = { +4060 "this": True, +4061 "substr": True, +4062 "position": False, +4063 "instance": False, +4064 } 4065 -4066class Use(Expression): -4067 arg_types = {"this": True, "kind": False} -4068 +4066 +4067class StrToDate(Func): +4068 arg_types = {"this": True, "format": True} 4069 -4070class Merge(Expression): -4071 arg_types = {"this": True, "using": True, "on": True, "expressions": True} -4072 +4070 +4071class StrToTime(Func): +4072 arg_types = {"this": True, "format": True} 4073 -4074class When(Func): -4075 arg_types = {"matched": True, "source": False, "condition": False, "then": True} -4076 -4077 -4078def _norm_arg(arg): -4079 return arg.lower() if type(arg) is str else arg +4074 +4075# Spark allows unix_timestamp() +4076# https://spark.apache.org/docs/3.1.3/api/python/reference/api/pyspark.sql.functions.unix_timestamp.html +4077class StrToUnix(Func): +4078 arg_types = {"this": False, "format": False} +4079 4080 -4081 -4082ALL_FUNCTIONS = subclasses(__name__, Func, (AggFunc, Anonymous, Func)) +4081class NumberToStr(Func): +4082 arg_types = {"this": True, "format": True} 4083 4084 -4085# Helpers -4086@t.overload -4087def maybe_parse( -4088 sql_or_expression: ExpOrStr, -4089 *, -4090 into: t.Type[E], -4091 dialect: DialectType = None, -4092 prefix: t.Optional[str] = None, -4093 copy: bool = False, -4094 **opts, -4095) -> E: -4096 ... +4085class Struct(Func): +4086 arg_types = {"expressions": True} +4087 is_var_len_args = True +4088 +4089 +4090class StructExtract(Func): +4091 arg_types = {"this": True, "expression": True} +4092 +4093 +4094class Sum(AggFunc): +4095 pass +4096 4097 -4098 -4099@t.overload -4100def maybe_parse( -4101 sql_or_expression: str | E, -4102 *, -4103 into: t.Optional[IntoType] = None, -4104 dialect: DialectType = None, -4105 prefix: t.Optional[str] = None, -4106 copy: bool = False, -4107 **opts, -4108) -> E: -4109 ... -4110 -4111 -4112def maybe_parse( -4113 sql_or_expression: ExpOrStr, -4114 *, -4115 into: t.Optional[IntoType] = None, -4116 dialect: DialectType = None, -4117 prefix: t.Optional[str] = None, -4118 copy: bool = False, -4119 **opts, -4120) -> Expression: -4121 """Gracefully handle a possible string or expression. -4122 -4123 Example: -4124 >>> maybe_parse("1") -4125 (LITERAL this: 1, is_string: False) -4126 >>> maybe_parse(to_identifier("x")) -4127 (IDENTIFIER this: x, quoted: False) +4098class Sqrt(Func): +4099 pass +4100 +4101 +4102class Stddev(AggFunc): +4103 pass +4104 +4105 +4106class StddevPop(AggFunc): +4107 pass +4108 +4109 +4110class StddevSamp(AggFunc): +4111 pass +4112 +4113 +4114class TimeToStr(Func): +4115 arg_types = {"this": True, "format": True} +4116 +4117 +4118class TimeToTimeStr(Func): +4119 pass +4120 +4121 +4122class TimeToUnix(Func): +4123 pass +4124 +4125 +4126class TimeStrToDate(Func): +4127 pass 4128 -4129 Args: -4130 sql_or_expression: the SQL code string or an expression -4131 into: the SQLGlot Expression to parse into -4132 dialect: the dialect used to parse the input expressions (in the case that an -4133 input expression is a SQL string). -4134 prefix: a string to prefix the sql with before it gets parsed -4135 (automatically includes a space) -4136 copy: whether or not to copy the expression. -4137 **opts: other options to use to parse the input expressions (again, in the case -4138 that an input expression is a SQL string). -4139 -4140 Returns: -4141 Expression: the parsed or given expression. -4142 """ -4143 if isinstance(sql_or_expression, Expression): -4144 if copy: -4145 return sql_or_expression.copy() -4146 return sql_or_expression -4147 -4148 import sqlglot +4129 +4130class TimeStrToTime(Func): +4131 pass +4132 +4133 +4134class TimeStrToUnix(Func): +4135 pass +4136 +4137 +4138class Trim(Func): +4139 arg_types = { +4140 "this": True, +4141 "expression": False, +4142 "position": False, +4143 "collation": False, +4144 } +4145 +4146 +4147class TsOrDsAdd(Func, TimeUnit): +4148 arg_types = {"this": True, "expression": True, "unit": False} 4149 -4150 sql = str(sql_or_expression) -4151 if prefix: -4152 sql = f"{prefix} {sql}" -4153 return sqlglot.parse_one(sql, read=dialect, into=into, **opts) +4150 +4151class TsOrDsToDateStr(Func): +4152 pass +4153 4154 -4155 -4156def _maybe_copy(instance, copy=True): -4157 return instance.copy() if copy else instance +4155class TsOrDsToDate(Func): +4156 arg_types = {"this": True, "format": False} +4157 4158 -4159 -4160def _is_wrong_expression(expression, into): -4161 return isinstance(expression, Expression) and not isinstance(expression, into) +4159class TsOrDiToDi(Func): +4160 pass +4161 4162 -4163 -4164def _apply_builder( -4165 expression, -4166 instance, -4167 arg, -4168 copy=True, -4169 prefix=None, -4170 into=None, -4171 dialect=None, -4172 **opts, -4173): -4174 if _is_wrong_expression(expression, into): -4175 expression = into(this=expression) -4176 instance = _maybe_copy(instance, copy) -4177 expression = maybe_parse( -4178 sql_or_expression=expression, -4179 prefix=prefix, -4180 into=into, -4181 dialect=dialect, -4182 **opts, -4183 ) -4184 instance.set(arg, expression) -4185 return instance -4186 +4163class Unhex(Func): +4164 pass +4165 +4166 +4167class UnixToStr(Func): +4168 arg_types = {"this": True, "format": False} +4169 +4170 +4171# https://prestodb.io/docs/current/functions/datetime.html +4172# presto has weird zone/hours/minutes +4173class UnixToTime(Func): +4174 arg_types = {"this": True, "scale": False, "zone": False, "hours": False, "minutes": False} +4175 +4176 SECONDS = Literal.string("seconds") +4177 MILLIS = Literal.string("millis") +4178 MICROS = Literal.string("micros") +4179 +4180 +4181class UnixToTimeStr(Func): +4182 pass +4183 +4184 +4185class Upper(Func): +4186 _sql_names = ["UPPER", "UCASE"] 4187 -4188def _apply_child_list_builder( -4189 *expressions, -4190 instance, -4191 arg, -4192 append=True, -4193 copy=True, -4194 prefix=None, -4195 into=None, -4196 dialect=None, -4197 properties=None, -4198 **opts, -4199): -4200 instance = _maybe_copy(instance, copy) -4201 parsed = [] -4202 for expression in expressions: -4203 if _is_wrong_expression(expression, into): -4204 expression = into(expressions=[expression]) -4205 expression = maybe_parse( -4206 expression, -4207 into=into, -4208 dialect=dialect, -4209 prefix=prefix, -4210 **opts, -4211 ) -4212 parsed.extend(expression.expressions) -4213 -4214 existing = instance.args.get(arg) -4215 if append and existing: -4216 parsed = existing.expressions + parsed -4217 -4218 child = into(expressions=parsed) -4219 for k, v in (properties or {}).items(): -4220 child.set(k, v) -4221 instance.set(arg, child) -4222 return instance -4223 -4224 -4225def _apply_list_builder( -4226 *expressions, -4227 instance, -4228 arg, -4229 append=True, -4230 copy=True, -4231 prefix=None, -4232 into=None, -4233 dialect=None, -4234 **opts, -4235): -4236 inst = _maybe_copy(instance, copy) -4237 -4238 expressions = [ -4239 maybe_parse( -4240 sql_or_expression=expression, -4241 into=into, -4242 prefix=prefix, -4243 dialect=dialect, -4244 **opts, -4245 ) -4246 for expression in expressions -4247 ] -4248 -4249 existing_expressions = inst.args.get(arg) -4250 if append and existing_expressions: -4251 expressions = existing_expressions + expressions -4252 -4253 inst.set(arg, expressions) -4254 return inst -4255 -4256 -4257def _apply_conjunction_builder( -4258 *expressions, -4259 instance, -4260 arg, -4261 into=None, -4262 append=True, -4263 copy=True, -4264 dialect=None, -4265 **opts, -4266): -4267 expressions = [exp for exp in expressions if exp is not None and exp != ""] -4268 if not expressions: -4269 return instance -4270 -4271 inst = _maybe_copy(instance, copy) -4272 -4273 existing = inst.args.get(arg) -4274 if append and existing is not None: -4275 expressions = [existing.this if into else existing] + list(expressions) -4276 -4277 node = and_(*expressions, dialect=dialect, **opts) -4278 -4279 inst.set(arg, into(this=node) if into else node) -4280 return inst -4281 -4282 -4283def _combine(expressions, operator, dialect=None, **opts): -4284 expressions = [condition(expression, dialect=dialect, **opts) for expression in expressions] -4285 this = expressions[0] -4286 if expressions[1:]: -4287 this = _wrap_operator(this) -4288 for expression in expressions[1:]: -4289 this = operator(this=this, expression=_wrap_operator(expression)) -4290 return this -4291 -4292 -4293def _wrap_operator(expression): -4294 if isinstance(expression, (And, Or, Not)): -4295 expression = Paren(this=expression) -4296 return expression -4297 +4188 +4189class Variance(AggFunc): +4190 _sql_names = ["VARIANCE", "VARIANCE_SAMP", "VAR_SAMP"] +4191 +4192 +4193class VariancePop(AggFunc): +4194 _sql_names = ["VARIANCE_POP", "VAR_POP"] +4195 +4196 +4197class Week(Func): +4198 arg_types = {"this": True, "mode": False} +4199 +4200 +4201class XMLTable(Func): +4202 arg_types = {"this": True, "passing": False, "columns": False, "by_ref": False} +4203 +4204 +4205class Year(Func): +4206 pass +4207 +4208 +4209class Use(Expression): +4210 arg_types = {"this": True, "kind": False} +4211 +4212 +4213class Merge(Expression): +4214 arg_types = {"this": True, "using": True, "on": True, "expressions": True} +4215 +4216 +4217class When(Func): +4218 arg_types = {"matched": True, "source": False, "condition": False, "then": True} +4219 +4220 +4221# https://docs.oracle.com/javadb/10.8.3.0/ref/rrefsqljnextvaluefor.html +4222# https://learn.microsoft.com/en-us/sql/t-sql/functions/next-value-for-transact-sql?view=sql-server-ver16 +4223class NextValueFor(Func): +4224 arg_types = {"this": True, "order": False} +4225 +4226 +4227def _norm_arg(arg): +4228 return arg.lower() if type(arg) is str else arg +4229 +4230 +4231ALL_FUNCTIONS = subclasses(__name__, Func, (AggFunc, Anonymous, Func)) +4232 +4233 +4234# Helpers +4235@t.overload +4236def maybe_parse( +4237 sql_or_expression: ExpOrStr, +4238 *, +4239 into: t.Type[E], +4240 dialect: DialectType = None, +4241 prefix: t.Optional[str] = None, +4242 copy: bool = False, +4243 **opts, +4244) -> E: +4245 ... +4246 +4247 +4248@t.overload +4249def maybe_parse( +4250 sql_or_expression: str | E, +4251 *, +4252 into: t.Optional[IntoType] = None, +4253 dialect: DialectType = None, +4254 prefix: t.Optional[str] = None, +4255 copy: bool = False, +4256 **opts, +4257) -> E: +4258 ... +4259 +4260 +4261def maybe_parse( +4262 sql_or_expression: ExpOrStr, +4263 *, +4264 into: t.Optional[IntoType] = None, +4265 dialect: DialectType = None, +4266 prefix: t.Optional[str] = None, +4267 copy: bool = False, +4268 **opts, +4269) -> Expression: +4270 """Gracefully handle a possible string or expression. +4271 +4272 Example: +4273 >>> maybe_parse("1") +4274 (LITERAL this: 1, is_string: False) +4275 >>> maybe_parse(to_identifier("x")) +4276 (IDENTIFIER this: x, quoted: False) +4277 +4278 Args: +4279 sql_or_expression: the SQL code string or an expression +4280 into: the SQLGlot Expression to parse into +4281 dialect: the dialect used to parse the input expressions (in the case that an +4282 input expression is a SQL string). +4283 prefix: a string to prefix the sql with before it gets parsed +4284 (automatically includes a space) +4285 copy: whether or not to copy the expression. +4286 **opts: other options to use to parse the input expressions (again, in the case +4287 that an input expression is a SQL string). +4288 +4289 Returns: +4290 Expression: the parsed or given expression. +4291 """ +4292 if isinstance(sql_or_expression, Expression): +4293 if copy: +4294 return sql_or_expression.copy() +4295 return sql_or_expression +4296 +4297 import sqlglot 4298 -4299def union(left, right, distinct=True, dialect=None, **opts): -4300 """ -4301 Initializes a syntax tree from one UNION expression. -4302 -4303 Example: -4304 >>> union("SELECT * FROM foo", "SELECT * FROM bla").sql() -4305 'SELECT * FROM foo UNION SELECT * FROM bla' -4306 -4307 Args: -4308 left (str | Expression): the SQL code string corresponding to the left-hand side. -4309 If an `Expression` instance is passed, it will be used as-is. -4310 right (str | Expression): the SQL code string corresponding to the right-hand side. -4311 If an `Expression` instance is passed, it will be used as-is. -4312 distinct (bool): set the DISTINCT flag if and only if this is true. -4313 dialect (str): the dialect used to parse the input expression. -4314 opts (kwargs): other options to use to parse the input expressions. -4315 Returns: -4316 Union: the syntax tree for the UNION expression. -4317 """ -4318 left = maybe_parse(sql_or_expression=left, dialect=dialect, **opts) -4319 right = maybe_parse(sql_or_expression=right, dialect=dialect, **opts) -4320 -4321 return Union(this=left, expression=right, distinct=distinct) -4322 -4323 -4324def intersect(left, right, distinct=True, dialect=None, **opts): -4325 """ -4326 Initializes a syntax tree from one INTERSECT expression. -4327 -4328 Example: -4329 >>> intersect("SELECT * FROM foo", "SELECT * FROM bla").sql() -4330 'SELECT * FROM foo INTERSECT SELECT * FROM bla' -4331 -4332 Args: -4333 left (str | Expression): the SQL code string corresponding to the left-hand side. -4334 If an `Expression` instance is passed, it will be used as-is. -4335 right (str | Expression): the SQL code string corresponding to the right-hand side. -4336 If an `Expression` instance is passed, it will be used as-is. -4337 distinct (bool): set the DISTINCT flag if and only if this is true. -4338 dialect (str): the dialect used to parse the input expression. -4339 opts (kwargs): other options to use to parse the input expressions. -4340 Returns: -4341 Intersect: the syntax tree for the INTERSECT expression. -4342 """ -4343 left = maybe_parse(sql_or_expression=left, dialect=dialect, **opts) -4344 right = maybe_parse(sql_or_expression=right, dialect=dialect, **opts) -4345 -4346 return Intersect(this=left, expression=right, distinct=distinct) -4347 -4348 -4349def except_(left, right, distinct=True, dialect=None, **opts): -4350 """ -4351 Initializes a syntax tree from one EXCEPT expression. -4352 -4353 Example: -4354 >>> except_("SELECT * FROM foo", "SELECT * FROM bla").sql() -4355 'SELECT * FROM foo EXCEPT SELECT * FROM bla' -4356 -4357 Args: -4358 left (str | Expression): the SQL code string corresponding to the left-hand side. -4359 If an `Expression` instance is passed, it will be used as-is. -4360 right (str | Expression): the SQL code string corresponding to the right-hand side. -4361 If an `Expression` instance is passed, it will be used as-is. -4362 distinct (bool): set the DISTINCT flag if and only if this is true. -4363 dialect (str): the dialect used to parse the input expression. -4364 opts (kwargs): other options to use to parse the input expressions. -4365 Returns: -4366 Except: the syntax tree for the EXCEPT statement. -4367 """ -4368 left = maybe_parse(sql_or_expression=left, dialect=dialect, **opts) -4369 right = maybe_parse(sql_or_expression=right, dialect=dialect, **opts) -4370 -4371 return Except(this=left, expression=right, distinct=distinct) +4299 sql = str(sql_or_expression) +4300 if prefix: +4301 sql = f"{prefix} {sql}" +4302 return sqlglot.parse_one(sql, read=dialect, into=into, **opts) +4303 +4304 +4305def _maybe_copy(instance, copy=True): +4306 return instance.copy() if copy else instance +4307 +4308 +4309def _is_wrong_expression(expression, into): +4310 return isinstance(expression, Expression) and not isinstance(expression, into) +4311 +4312 +4313def _apply_builder( +4314 expression, +4315 instance, +4316 arg, +4317 copy=True, +4318 prefix=None, +4319 into=None, +4320 dialect=None, +4321 **opts, +4322): +4323 if _is_wrong_expression(expression, into): +4324 expression = into(this=expression) +4325 instance = _maybe_copy(instance, copy) +4326 expression = maybe_parse( +4327 sql_or_expression=expression, +4328 prefix=prefix, +4329 into=into, +4330 dialect=dialect, +4331 **opts, +4332 ) +4333 instance.set(arg, expression) +4334 return instance +4335 +4336 +4337def _apply_child_list_builder( +4338 *expressions, +4339 instance, +4340 arg, +4341 append=True, +4342 copy=True, +4343 prefix=None, +4344 into=None, +4345 dialect=None, +4346 properties=None, +4347 **opts, +4348): +4349 instance = _maybe_copy(instance, copy) +4350 parsed = [] +4351 for expression in expressions: +4352 if _is_wrong_expression(expression, into): +4353 expression = into(expressions=[expression]) +4354 expression = maybe_parse( +4355 expression, +4356 into=into, +4357 dialect=dialect, +4358 prefix=prefix, +4359 **opts, +4360 ) +4361 parsed.extend(expression.expressions) +4362 +4363 existing = instance.args.get(arg) +4364 if append and existing: +4365 parsed = existing.expressions + parsed +4366 +4367 child = into(expressions=parsed) +4368 for k, v in (properties or {}).items(): +4369 child.set(k, v) +4370 instance.set(arg, child) +4371 return instance 4372 4373 -4374def select(*expressions: ExpOrStr, dialect: DialectType = None, **opts) -> Select: -4375 """ -4376 Initializes a syntax tree from one or multiple SELECT expressions. -4377 -4378 Example: -4379 >>> select("col1", "col2").from_("tbl").sql() -4380 'SELECT col1, col2 FROM tbl' -4381 -4382 Args: -4383 *expressions: the SQL code string to parse as the expressions of a -4384 SELECT statement. If an Expression instance is passed, this is used as-is. -4385 dialect: the dialect used to parse the input expressions (in the case that an -4386 input expression is a SQL string). -4387 **opts: other options to use to parse the input expressions (again, in the case -4388 that an input expression is a SQL string). -4389 -4390 Returns: -4391 Select: the syntax tree for the SELECT statement. -4392 """ -4393 return Select().select(*expressions, dialect=dialect, **opts) -4394 -4395 -4396def from_(*expressions, dialect=None, **opts) -> Select: -4397 """ -4398 Initializes a syntax tree from a FROM expression. -4399 -4400 Example: -4401 >>> from_("tbl").select("col1", "col2").sql() -4402 'SELECT col1, col2 FROM tbl' -4403 -4404 Args: -4405 *expressions (str | Expression): the SQL code string to parse as the FROM expressions of a -4406 SELECT statement. If an Expression instance is passed, this is used as-is. -4407 dialect (str): the dialect used to parse the input expression (in the case that the -4408 input expression is a SQL string). -4409 **opts: other options to use to parse the input expressions (again, in the case -4410 that the input expression is a SQL string). -4411 -4412 Returns: -4413 Select: the syntax tree for the SELECT statement. -4414 """ -4415 return Select().from_(*expressions, dialect=dialect, **opts) -4416 -4417 -4418def update( -4419 table: str | Table, -4420 properties: dict, -4421 where: t.Optional[ExpOrStr] = None, -4422 from_: t.Optional[ExpOrStr] = None, -4423 dialect: DialectType = None, -4424 **opts, -4425) -> Update: -4426 """ -4427 Creates an update statement. -4428 -4429 Example: -4430 >>> update("my_table", {"x": 1, "y": "2", "z": None}, from_="baz", where="id > 1").sql() -4431 "UPDATE my_table SET x = 1, y = '2', z = NULL FROM baz WHERE id > 1" -4432 -4433 Args: -4434 *properties: dictionary of properties to set which are -4435 auto converted to sql objects eg None -> NULL -4436 where: sql conditional parsed into a WHERE statement -4437 from_: sql statement parsed into a FROM statement -4438 dialect: the dialect used to parse the input expressions. -4439 **opts: other options to use to parse the input expressions. -4440 -4441 Returns: -4442 Update: the syntax tree for the UPDATE statement. -4443 """ -4444 update_expr = Update(this=maybe_parse(table, into=Table, dialect=dialect)) -4445 update_expr.set( -4446 "expressions", -4447 [ -4448 EQ(this=maybe_parse(k, dialect=dialect, **opts), expression=convert(v)) -4449 for k, v in properties.items() -4450 ], -4451 ) -4452 if from_: -4453 update_expr.set( -4454 "from", -4455 maybe_parse(from_, into=From, dialect=dialect, prefix="FROM", **opts), -4456 ) -4457 if isinstance(where, Condition): -4458 where = Where(this=where) -4459 if where: -4460 update_expr.set( -4461 "where", -4462 maybe_parse(where, into=Where, dialect=dialect, prefix="WHERE", **opts), -4463 ) -4464 return update_expr -4465 -4466 -4467def delete( -4468 table: ExpOrStr, -4469 where: t.Optional[ExpOrStr] = None, -4470 returning: t.Optional[ExpOrStr] = None, -4471 dialect: DialectType = None, -4472 **opts, -4473) -> Delete: -4474 """ -4475 Builds a delete statement. -4476 -4477 Example: -4478 >>> delete("my_table", where="id > 1").sql() -4479 'DELETE FROM my_table WHERE id > 1' -4480 -4481 Args: -4482 where: sql conditional parsed into a WHERE statement -4483 returning: sql conditional parsed into a RETURNING statement -4484 dialect: the dialect used to parse the input expressions. -4485 **opts: other options to use to parse the input expressions. -4486 -4487 Returns: -4488 Delete: the syntax tree for the DELETE statement. -4489 """ -4490 delete_expr = Delete().delete(table, dialect=dialect, copy=False, **opts) -4491 if where: -4492 delete_expr = delete_expr.where(where, dialect=dialect, copy=False, **opts) -4493 if returning: -4494 delete_expr = delete_expr.returning(returning, dialect=dialect, copy=False, **opts) -4495 return delete_expr +4374def _apply_list_builder( +4375 *expressions, +4376 instance, +4377 arg, +4378 append=True, +4379 copy=True, +4380 prefix=None, +4381 into=None, +4382 dialect=None, +4383 **opts, +4384): +4385 inst = _maybe_copy(instance, copy) +4386 +4387 expressions = [ +4388 maybe_parse( +4389 sql_or_expression=expression, +4390 into=into, +4391 prefix=prefix, +4392 dialect=dialect, +4393 **opts, +4394 ) +4395 for expression in expressions +4396 ] +4397 +4398 existing_expressions = inst.args.get(arg) +4399 if append and existing_expressions: +4400 expressions = existing_expressions + expressions +4401 +4402 inst.set(arg, expressions) +4403 return inst +4404 +4405 +4406def _apply_conjunction_builder( +4407 *expressions, +4408 instance, +4409 arg, +4410 into=None, +4411 append=True, +4412 copy=True, +4413 dialect=None, +4414 **opts, +4415): +4416 expressions = [exp for exp in expressions if exp is not None and exp != ""] +4417 if not expressions: +4418 return instance +4419 +4420 inst = _maybe_copy(instance, copy) +4421 +4422 existing = inst.args.get(arg) +4423 if append and existing is not None: +4424 expressions = [existing.this if into else existing] + list(expressions) +4425 +4426 node = and_(*expressions, dialect=dialect, copy=copy, **opts) +4427 +4428 inst.set(arg, into(this=node) if into else node) +4429 return inst +4430 +4431 +4432def _combine(expressions, operator, dialect=None, copy=True, **opts): +4433 expressions = [ +4434 condition(expression, dialect=dialect, copy=copy, **opts) for expression in expressions +4435 ] +4436 this = expressions[0] +4437 if expressions[1:]: +4438 this = _wrap(this, Connector) +4439 for expression in expressions[1:]: +4440 this = operator(this=this, expression=_wrap(expression, Connector)) +4441 return this +4442 +4443 +4444def _wrap(expression: E, kind: t.Type[Expression]) -> E | Paren: +4445 if isinstance(expression, kind): +4446 return Paren(this=expression) +4447 return expression +4448 +4449 +4450def union(left, right, distinct=True, dialect=None, **opts): +4451 """ +4452 Initializes a syntax tree from one UNION expression. +4453 +4454 Example: +4455 >>> union("SELECT * FROM foo", "SELECT * FROM bla").sql() +4456 'SELECT * FROM foo UNION SELECT * FROM bla' +4457 +4458 Args: +4459 left (str | Expression): the SQL code string corresponding to the left-hand side. +4460 If an `Expression` instance is passed, it will be used as-is. +4461 right (str | Expression): the SQL code string corresponding to the right-hand side. +4462 If an `Expression` instance is passed, it will be used as-is. +4463 distinct (bool): set the DISTINCT flag if and only if this is true. +4464 dialect (str): the dialect used to parse the input expression. +4465 opts (kwargs): other options to use to parse the input expressions. +4466 Returns: +4467 Union: the syntax tree for the UNION expression. +4468 """ +4469 left = maybe_parse(sql_or_expression=left, dialect=dialect, **opts) +4470 right = maybe_parse(sql_or_expression=right, dialect=dialect, **opts) +4471 +4472 return Union(this=left, expression=right, distinct=distinct) +4473 +4474 +4475def intersect(left, right, distinct=True, dialect=None, **opts): +4476 """ +4477 Initializes a syntax tree from one INTERSECT expression. +4478 +4479 Example: +4480 >>> intersect("SELECT * FROM foo", "SELECT * FROM bla").sql() +4481 'SELECT * FROM foo INTERSECT SELECT * FROM bla' +4482 +4483 Args: +4484 left (str | Expression): the SQL code string corresponding to the left-hand side. +4485 If an `Expression` instance is passed, it will be used as-is. +4486 right (str | Expression): the SQL code string corresponding to the right-hand side. +4487 If an `Expression` instance is passed, it will be used as-is. +4488 distinct (bool): set the DISTINCT flag if and only if this is true. +4489 dialect (str): the dialect used to parse the input expression. +4490 opts (kwargs): other options to use to parse the input expressions. +4491 Returns: +4492 Intersect: the syntax tree for the INTERSECT expression. +4493 """ +4494 left = maybe_parse(sql_or_expression=left, dialect=dialect, **opts) +4495 right = maybe_parse(sql_or_expression=right, dialect=dialect, **opts) 4496 -4497 -4498def condition(expression, dialect=None, **opts) -> Condition: -4499 """ -4500 Initialize a logical condition expression. -4501 -4502 Example: -4503 >>> condition("x=1").sql() -4504 'x = 1' -4505 -4506 This is helpful for composing larger logical syntax trees: -4507 >>> where = condition("x=1") -4508 >>> where = where.and_("y=1") -4509 >>> Select().from_("tbl").select("*").where(where).sql() -4510 'SELECT * FROM tbl WHERE x = 1 AND y = 1' -4511 -4512 Args: -4513 *expression (str | Expression): the SQL code string to parse. -4514 If an Expression instance is passed, this is used as-is. -4515 dialect (str): the dialect used to parse the input expression (in the case that the -4516 input expression is a SQL string). -4517 **opts: other options to use to parse the input expressions (again, in the case -4518 that the input expression is a SQL string). -4519 -4520 Returns: -4521 Condition: the expression -4522 """ -4523 return maybe_parse( # type: ignore -4524 expression, -4525 into=Condition, -4526 dialect=dialect, -4527 **opts, -4528 ) -4529 -4530 -4531def and_(*expressions, dialect=None, **opts) -> And: -4532 """ -4533 Combine multiple conditions with an AND logical operator. -4534 -4535 Example: -4536 >>> and_("x=1", and_("y=1", "z=1")).sql() -4537 'x = 1 AND (y = 1 AND z = 1)' -4538 -4539 Args: -4540 *expressions (str | Expression): the SQL code strings to parse. -4541 If an Expression instance is passed, this is used as-is. -4542 dialect (str): the dialect used to parse the input expression. -4543 **opts: other options to use to parse the input expressions. -4544 -4545 Returns: -4546 And: the new condition -4547 """ -4548 return _combine(expressions, And, dialect, **opts) -4549 +4497 return Intersect(this=left, expression=right, distinct=distinct) +4498 +4499 +4500def except_(left, right, distinct=True, dialect=None, **opts): +4501 """ +4502 Initializes a syntax tree from one EXCEPT expression. +4503 +4504 Example: +4505 >>> except_("SELECT * FROM foo", "SELECT * FROM bla").sql() +4506 'SELECT * FROM foo EXCEPT SELECT * FROM bla' +4507 +4508 Args: +4509 left (str | Expression): the SQL code string corresponding to the left-hand side. +4510 If an `Expression` instance is passed, it will be used as-is. +4511 right (str | Expression): the SQL code string corresponding to the right-hand side. +4512 If an `Expression` instance is passed, it will be used as-is. +4513 distinct (bool): set the DISTINCT flag if and only if this is true. +4514 dialect (str): the dialect used to parse the input expression. +4515 opts (kwargs): other options to use to parse the input expressions. +4516 Returns: +4517 Except: the syntax tree for the EXCEPT statement. +4518 """ +4519 left = maybe_parse(sql_or_expression=left, dialect=dialect, **opts) +4520 right = maybe_parse(sql_or_expression=right, dialect=dialect, **opts) +4521 +4522 return Except(this=left, expression=right, distinct=distinct) +4523 +4524 +4525def select(*expressions: ExpOrStr, dialect: DialectType = None, **opts) -> Select: +4526 """ +4527 Initializes a syntax tree from one or multiple SELECT expressions. +4528 +4529 Example: +4530 >>> select("col1", "col2").from_("tbl").sql() +4531 'SELECT col1, col2 FROM tbl' +4532 +4533 Args: +4534 *expressions: the SQL code string to parse as the expressions of a +4535 SELECT statement. If an Expression instance is passed, this is used as-is. +4536 dialect: the dialect used to parse the input expressions (in the case that an +4537 input expression is a SQL string). +4538 **opts: other options to use to parse the input expressions (again, in the case +4539 that an input expression is a SQL string). +4540 +4541 Returns: +4542 Select: the syntax tree for the SELECT statement. +4543 """ +4544 return Select().select(*expressions, dialect=dialect, **opts) +4545 +4546 +4547def from_(*expressions, dialect=None, **opts) -> Select: +4548 """ +4549 Initializes a syntax tree from a FROM expression. 4550 -4551def or_(*expressions, dialect=None, **opts) -> Or: -4552 """ -4553 Combine multiple conditions with an OR logical operator. +4551 Example: +4552 >>> from_("tbl").select("col1", "col2").sql() +4553 'SELECT col1, col2 FROM tbl' 4554 -4555 Example: -4556 >>> or_("x=1", or_("y=1", "z=1")).sql() -4557 'x = 1 OR (y = 1 OR z = 1)' -4558 -4559 Args: -4560 *expressions (str | Expression): the SQL code strings to parse. -4561 If an Expression instance is passed, this is used as-is. -4562 dialect (str): the dialect used to parse the input expression. -4563 **opts: other options to use to parse the input expressions. -4564 -4565 Returns: -4566 Or: the new condition -4567 """ -4568 return _combine(expressions, Or, dialect, **opts) -4569 -4570 -4571def not_(expression, dialect=None, **opts) -> Not: -4572 """ -4573 Wrap a condition with a NOT operator. -4574 -4575 Example: -4576 >>> not_("this_suit='black'").sql() -4577 "NOT this_suit = 'black'" -4578 -4579 Args: -4580 expression (str | Expression): the SQL code strings to parse. -4581 If an Expression instance is passed, this is used as-is. -4582 dialect (str): the dialect used to parse the input expression. -4583 **opts: other options to use to parse the input expressions. -4584 -4585 Returns: -4586 Not: the new condition -4587 """ -4588 this = condition( -4589 expression, -4590 dialect=dialect, -4591 **opts, -4592 ) -4593 return Not(this=_wrap_operator(this)) -4594 -4595 -4596def paren(expression) -> Paren: -4597 return Paren(this=expression) -4598 -4599 -4600SAFE_IDENTIFIER_RE = re.compile(r"^[_a-zA-Z][\w]*$") -4601 -4602 -4603@t.overload -4604def to_identifier(name: None, quoted: t.Optional[bool] = None) -> None: -4605 ... -4606 -4607 -4608@t.overload -4609def to_identifier(name: str | Identifier, quoted: t.Optional[bool] = None) -> Identifier: -4610 ... -4611 -4612 -4613def to_identifier(name, quoted=None): -4614 """Builds an identifier. -4615 -4616 Args: -4617 name: The name to turn into an identifier. -4618 quoted: Whether or not force quote the identifier. -4619 -4620 Returns: -4621 The identifier ast node. -4622 """ -4623 -4624 if name is None: -4625 return None -4626 -4627 if isinstance(name, Identifier): -4628 identifier = name -4629 elif isinstance(name, str): -4630 identifier = Identifier( -4631 this=name, -4632 quoted=not SAFE_IDENTIFIER_RE.match(name) if quoted is None else quoted, -4633 ) -4634 else: -4635 raise ValueError(f"Name needs to be a string or an Identifier, got: {name.__class__}") -4636 return identifier +4555 Args: +4556 *expressions (str | Expression): the SQL code string to parse as the FROM expressions of a +4557 SELECT statement. If an Expression instance is passed, this is used as-is. +4558 dialect (str): the dialect used to parse the input expression (in the case that the +4559 input expression is a SQL string). +4560 **opts: other options to use to parse the input expressions (again, in the case +4561 that the input expression is a SQL string). +4562 +4563 Returns: +4564 Select: the syntax tree for the SELECT statement. +4565 """ +4566 return Select().from_(*expressions, dialect=dialect, **opts) +4567 +4568 +4569def update( +4570 table: str | Table, +4571 properties: dict, +4572 where: t.Optional[ExpOrStr] = None, +4573 from_: t.Optional[ExpOrStr] = None, +4574 dialect: DialectType = None, +4575 **opts, +4576) -> Update: +4577 """ +4578 Creates an update statement. +4579 +4580 Example: +4581 >>> update("my_table", {"x": 1, "y": "2", "z": None}, from_="baz", where="id > 1").sql() +4582 "UPDATE my_table SET x = 1, y = '2', z = NULL FROM baz WHERE id > 1" +4583 +4584 Args: +4585 *properties: dictionary of properties to set which are +4586 auto converted to sql objects eg None -> NULL +4587 where: sql conditional parsed into a WHERE statement +4588 from_: sql statement parsed into a FROM statement +4589 dialect: the dialect used to parse the input expressions. +4590 **opts: other options to use to parse the input expressions. +4591 +4592 Returns: +4593 Update: the syntax tree for the UPDATE statement. +4594 """ +4595 update_expr = Update(this=maybe_parse(table, into=Table, dialect=dialect)) +4596 update_expr.set( +4597 "expressions", +4598 [ +4599 EQ(this=maybe_parse(k, dialect=dialect, **opts), expression=convert(v)) +4600 for k, v in properties.items() +4601 ], +4602 ) +4603 if from_: +4604 update_expr.set( +4605 "from", +4606 maybe_parse(from_, into=From, dialect=dialect, prefix="FROM", **opts), +4607 ) +4608 if isinstance(where, Condition): +4609 where = Where(this=where) +4610 if where: +4611 update_expr.set( +4612 "where", +4613 maybe_parse(where, into=Where, dialect=dialect, prefix="WHERE", **opts), +4614 ) +4615 return update_expr +4616 +4617 +4618def delete( +4619 table: ExpOrStr, +4620 where: t.Optional[ExpOrStr] = None, +4621 returning: t.Optional[ExpOrStr] = None, +4622 dialect: DialectType = None, +4623 **opts, +4624) -> Delete: +4625 """ +4626 Builds a delete statement. +4627 +4628 Example: +4629 >>> delete("my_table", where="id > 1").sql() +4630 'DELETE FROM my_table WHERE id > 1' +4631 +4632 Args: +4633 where: sql conditional parsed into a WHERE statement +4634 returning: sql conditional parsed into a RETURNING statement +4635 dialect: the dialect used to parse the input expressions. +4636 **opts: other options to use to parse the input expressions. 4637 -4638 -4639INTERVAL_STRING_RE = re.compile(r"\s*([0-9]+)\s*([a-zA-Z]+)\s*") -4640 -4641 -4642def to_interval(interval: str | Literal) -> Interval: -4643 """Builds an interval expression from a string like '1 day' or '5 months'.""" -4644 if isinstance(interval, Literal): -4645 if not interval.is_string: -4646 raise ValueError("Invalid interval string.") +4638 Returns: +4639 Delete: the syntax tree for the DELETE statement. +4640 """ +4641 delete_expr = Delete().delete(table, dialect=dialect, copy=False, **opts) +4642 if where: +4643 delete_expr = delete_expr.where(where, dialect=dialect, copy=False, **opts) +4644 if returning: +4645 delete_expr = delete_expr.returning(returning, dialect=dialect, copy=False, **opts) +4646 return delete_expr 4647 -4648 interval = interval.this -4649 -4650 interval_parts = INTERVAL_STRING_RE.match(interval) # type: ignore -4651 -4652 if not interval_parts: -4653 raise ValueError("Invalid interval string.") -4654 -4655 return Interval( -4656 this=Literal.string(interval_parts.group(1)), -4657 unit=Var(this=interval_parts.group(2)), -4658 ) -4659 -4660 -4661@t.overload -4662def to_table(sql_path: str | Table, **kwargs) -> Table: -4663 ... -4664 -4665 -4666@t.overload -4667def to_table(sql_path: None, **kwargs) -> None: -4668 ... -4669 -4670 -4671def to_table(sql_path: t.Optional[str | Table], **kwargs) -> t.Optional[Table]: -4672 """ -4673 Create a table expression from a `[catalog].[schema].[table]` sql path. Catalog and schema are optional. -4674 If a table is passed in then that table is returned. -4675 -4676 Args: -4677 sql_path: a `[catalog].[schema].[table]` string. -4678 -4679 Returns: -4680 A table expression. -4681 """ -4682 if sql_path is None or isinstance(sql_path, Table): -4683 return sql_path -4684 if not isinstance(sql_path, str): -4685 raise ValueError(f"Invalid type provided for a table: {type(sql_path)}") -4686 -4687 catalog, db, table_name = (to_identifier(x) for x in split_num_words(sql_path, ".", 3)) -4688 return Table(this=table_name, db=db, catalog=catalog, **kwargs) -4689 -4690 -4691def to_column(sql_path: str | Column, **kwargs) -> Column: -4692 """ -4693 Create a column from a `[table].[column]` sql path. Schema is optional. -4694 -4695 If a column is passed in then that column is returned. -4696 -4697 Args: -4698 sql_path: `[table].[column]` string +4648 +4649def condition(expression, dialect=None, copy=True, **opts) -> Condition: +4650 """ +4651 Initialize a logical condition expression. +4652 +4653 Example: +4654 >>> condition("x=1").sql() +4655 'x = 1' +4656 +4657 This is helpful for composing larger logical syntax trees: +4658 >>> where = condition("x=1") +4659 >>> where = where.and_("y=1") +4660 >>> Select().from_("tbl").select("*").where(where).sql() +4661 'SELECT * FROM tbl WHERE x = 1 AND y = 1' +4662 +4663 Args: +4664 *expression (str | Expression): the SQL code string to parse. +4665 If an Expression instance is passed, this is used as-is. +4666 dialect (str): the dialect used to parse the input expression (in the case that the +4667 input expression is a SQL string). +4668 copy (bool): Whether or not to copy `expression` (only applies to expressions). +4669 **opts: other options to use to parse the input expressions (again, in the case +4670 that the input expression is a SQL string). +4671 +4672 Returns: +4673 Condition: the expression +4674 """ +4675 return maybe_parse( # type: ignore +4676 expression, +4677 into=Condition, +4678 dialect=dialect, +4679 copy=copy, +4680 **opts, +4681 ) +4682 +4683 +4684def and_(*expressions, dialect=None, copy=True, **opts) -> And: +4685 """ +4686 Combine multiple conditions with an AND logical operator. +4687 +4688 Example: +4689 >>> and_("x=1", and_("y=1", "z=1")).sql() +4690 'x = 1 AND (y = 1 AND z = 1)' +4691 +4692 Args: +4693 *expressions (str | Expression): the SQL code strings to parse. +4694 If an Expression instance is passed, this is used as-is. +4695 dialect (str): the dialect used to parse the input expression. +4696 copy (bool): whether or not to copy `expressions` (only applies to Expressions). +4697 **opts: other options to use to parse the input expressions. +4698 4699 Returns: -4700 Table: A column expression +4700 And: the new condition 4701 """ -4702 if sql_path is None or isinstance(sql_path, Column): -4703 return sql_path -4704 if not isinstance(sql_path, str): -4705 raise ValueError(f"Invalid type provided for column: {type(sql_path)}") -4706 return column(*reversed(sql_path.split(".")), **kwargs) # type: ignore -4707 +4702 return _combine(expressions, And, dialect, copy=copy, **opts) +4703 +4704 +4705def or_(*expressions, dialect=None, copy=True, **opts) -> Or: +4706 """ +4707 Combine multiple conditions with an OR logical operator. 4708 -4709def alias_( -4710 expression: ExpOrStr, -4711 alias: str | Identifier, -4712 table: bool | t.Sequence[str | Identifier] = False, -4713 quoted: t.Optional[bool] = None, -4714 dialect: DialectType = None, -4715 **opts, -4716): -4717 """Create an Alias expression. -4718 -4719 Example: -4720 >>> alias_('foo', 'bar').sql() -4721 'foo AS bar' -4722 -4723 >>> alias_('(select 1, 2)', 'bar', table=['a', 'b']).sql() -4724 '(SELECT 1, 2) AS bar(a, b)' +4709 Example: +4710 >>> or_("x=1", or_("y=1", "z=1")).sql() +4711 'x = 1 OR (y = 1 OR z = 1)' +4712 +4713 Args: +4714 *expressions (str | Expression): the SQL code strings to parse. +4715 If an Expression instance is passed, this is used as-is. +4716 dialect (str): the dialect used to parse the input expression. +4717 copy (bool): whether or not to copy `expressions` (only applies to Expressions). +4718 **opts: other options to use to parse the input expressions. +4719 +4720 Returns: +4721 Or: the new condition +4722 """ +4723 return _combine(expressions, Or, dialect, copy=copy, **opts) +4724 4725 -4726 Args: -4727 expression: the SQL code strings to parse. -4728 If an Expression instance is passed, this is used as-is. -4729 alias: the alias name to use. If the name has -4730 special characters it is quoted. -4731 table: Whether or not to create a table alias, can also be a list of columns. -4732 quoted: whether or not to quote the alias -4733 dialect: the dialect used to parse the input expression. -4734 **opts: other options to use to parse the input expressions. -4735 -4736 Returns: -4737 Alias: the aliased expression -4738 """ -4739 exp = maybe_parse(expression, dialect=dialect, **opts) -4740 alias = to_identifier(alias, quoted=quoted) -4741 -4742 if table: -4743 table_alias = TableAlias(this=alias) -4744 -4745 exp = exp.copy() if isinstance(expression, Expression) else exp -4746 exp.set("alias", table_alias) -4747 -4748 if not isinstance(table, bool): -4749 for column in table: -4750 table_alias.append("columns", to_identifier(column, quoted=quoted)) +4726def not_(expression, dialect=None, copy=True, **opts) -> Not: +4727 """ +4728 Wrap a condition with a NOT operator. +4729 +4730 Example: +4731 >>> not_("this_suit='black'").sql() +4732 "NOT this_suit = 'black'" +4733 +4734 Args: +4735 expression (str | Expression): the SQL code strings to parse. +4736 If an Expression instance is passed, this is used as-is. +4737 dialect (str): the dialect used to parse the input expression. +4738 **opts: other options to use to parse the input expressions. +4739 +4740 Returns: +4741 Not: the new condition +4742 """ +4743 this = condition( +4744 expression, +4745 dialect=dialect, +4746 copy=copy, +4747 **opts, +4748 ) +4749 return Not(this=_wrap(this, Connector)) +4750 4751 -4752 return exp -4753 -4754 # We don't set the "alias" arg for Window expressions, because that would add an IDENTIFIER node in -4755 # the AST, representing a "named_window" [1] construct (eg. bigquery). What we want is an ALIAS node -4756 # for the complete Window expression. -4757 # -4758 # [1]: https://cloud.google.com/bigquery/docs/reference/standard-sql/window-function-calls -4759 -4760 if "alias" in exp.arg_types and not isinstance(exp, Window): -4761 exp = exp.copy() -4762 exp.set("alias", alias) -4763 return exp -4764 return Alias(this=exp, alias=alias) -4765 -4766 -4767def subquery(expression, alias=None, dialect=None, **opts): -4768 """ -4769 Build a subquery expression. -4770 -4771 Example: -4772 >>> subquery('select x from tbl', 'bar').select('x').sql() -4773 'SELECT x FROM (SELECT x FROM tbl) AS bar' -4774 -4775 Args: -4776 expression (str | Expression): the SQL code strings to parse. -4777 If an Expression instance is passed, this is used as-is. -4778 alias (str | Expression): the alias name to use. -4779 dialect (str): the dialect used to parse the input expression. -4780 **opts: other options to use to parse the input expressions. -4781 -4782 Returns: -4783 Select: a new select with the subquery expression included -4784 """ -4785 -4786 expression = maybe_parse(expression, dialect=dialect, **opts).subquery(alias) -4787 return Select().from_(expression, dialect=dialect, **opts) -4788 -4789 -4790def column( -4791 col: str | Identifier, -4792 table: t.Optional[str | Identifier] = None, -4793 db: t.Optional[str | Identifier] = None, -4794 catalog: t.Optional[str | Identifier] = None, -4795 quoted: t.Optional[bool] = None, -4796) -> Column: -4797 """ -4798 Build a Column. -4799 -4800 Args: -4801 col: column name -4802 table: table name -4803 db: db name -4804 catalog: catalog name -4805 quoted: whether or not to force quote each part -4806 Returns: -4807 Column: column instance -4808 """ -4809 return Column( -4810 this=to_identifier(col, quoted=quoted), -4811 table=to_identifier(table, quoted=quoted), -4812 db=to_identifier(db, quoted=quoted), -4813 catalog=to_identifier(catalog, quoted=quoted), +4752def paren(expression, copy=True) -> Paren: +4753 return Paren(this=_maybe_copy(expression, copy)) +4754 +4755 +4756SAFE_IDENTIFIER_RE = re.compile(r"^[_a-zA-Z][\w]*$") +4757 +4758 +4759@t.overload +4760def to_identifier(name: None, quoted: t.Optional[bool] = None) -> None: +4761 ... +4762 +4763 +4764@t.overload +4765def to_identifier(name: str | Identifier, quoted: t.Optional[bool] = None) -> Identifier: +4766 ... +4767 +4768 +4769def to_identifier(name, quoted=None): +4770 """Builds an identifier. +4771 +4772 Args: +4773 name: The name to turn into an identifier. +4774 quoted: Whether or not force quote the identifier. +4775 +4776 Returns: +4777 The identifier ast node. +4778 """ +4779 +4780 if name is None: +4781 return None +4782 +4783 if isinstance(name, Identifier): +4784 identifier = name +4785 elif isinstance(name, str): +4786 identifier = Identifier( +4787 this=name, +4788 quoted=not SAFE_IDENTIFIER_RE.match(name) if quoted is None else quoted, +4789 ) +4790 else: +4791 raise ValueError(f"Name needs to be a string or an Identifier, got: {name.__class__}") +4792 return identifier +4793 +4794 +4795INTERVAL_STRING_RE = re.compile(r"\s*([0-9]+)\s*([a-zA-Z]+)\s*") +4796 +4797 +4798def to_interval(interval: str | Literal) -> Interval: +4799 """Builds an interval expression from a string like '1 day' or '5 months'.""" +4800 if isinstance(interval, Literal): +4801 if not interval.is_string: +4802 raise ValueError("Invalid interval string.") +4803 +4804 interval = interval.this +4805 +4806 interval_parts = INTERVAL_STRING_RE.match(interval) # type: ignore +4807 +4808 if not interval_parts: +4809 raise ValueError("Invalid interval string.") +4810 +4811 return Interval( +4812 this=Literal.string(interval_parts.group(1)), +4813 unit=Var(this=interval_parts.group(2)), 4814 ) 4815 4816 -4817def cast(expression: ExpOrStr, to: str | DataType | DataType.Type, **opts) -> Cast: -4818 """Cast an expression to a data type. -4819 -4820 Example: -4821 >>> cast('x + 1', 'int').sql() -4822 'CAST(x + 1 AS INT)' -4823 -4824 Args: -4825 expression: The expression to cast. -4826 to: The datatype to cast to. -4827 -4828 Returns: -4829 A cast node. -4830 """ -4831 expression = maybe_parse(expression, **opts) -4832 return Cast(this=expression, to=DataType.build(to, **opts)) -4833 +4817@t.overload +4818def to_table(sql_path: str | Table, **kwargs) -> Table: +4819 ... +4820 +4821 +4822@t.overload +4823def to_table(sql_path: None, **kwargs) -> None: +4824 ... +4825 +4826 +4827def to_table(sql_path: t.Optional[str | Table], **kwargs) -> t.Optional[Table]: +4828 """ +4829 Create a table expression from a `[catalog].[schema].[table]` sql path. Catalog and schema are optional. +4830 If a table is passed in then that table is returned. +4831 +4832 Args: +4833 sql_path: a `[catalog].[schema].[table]` string. 4834 -4835def table_(table, db=None, catalog=None, quoted=None, alias=None) -> Table: -4836 """Build a Table. -4837 -4838 Args: -4839 table (str | Expression): column name -4840 db (str | Expression): db name -4841 catalog (str | Expression): catalog name +4835 Returns: +4836 A table expression. +4837 """ +4838 if sql_path is None or isinstance(sql_path, Table): +4839 return sql_path +4840 if not isinstance(sql_path, str): +4841 raise ValueError(f"Invalid type provided for a table: {type(sql_path)}") 4842 -4843 Returns: -4844 Table: table instance -4845 """ -4846 return Table( -4847 this=to_identifier(table, quoted=quoted), -4848 db=to_identifier(db, quoted=quoted), -4849 catalog=to_identifier(catalog, quoted=quoted), -4850 alias=TableAlias(this=to_identifier(alias)) if alias else None, -4851 ) +4843 catalog, db, table_name = (to_identifier(x) for x in split_num_words(sql_path, ".", 3)) +4844 return Table(this=table_name, db=db, catalog=catalog, **kwargs) +4845 +4846 +4847def to_column(sql_path: str | Column, **kwargs) -> Column: +4848 """ +4849 Create a column from a `[table].[column]` sql path. Schema is optional. +4850 +4851 If a column is passed in then that column is returned. 4852 -4853 -4854def values( -4855 values: t.Iterable[t.Tuple[t.Any, ...]], -4856 alias: t.Optional[str] = None, -4857 columns: t.Optional[t.Iterable[str] | t.Dict[str, DataType]] = None, -4858) -> Values: -4859 """Build VALUES statement. -4860 -4861 Example: -4862 >>> values([(1, '2')]).sql() -4863 "VALUES (1, '2')" +4853 Args: +4854 sql_path: `[table].[column]` string +4855 Returns: +4856 Table: A column expression +4857 """ +4858 if sql_path is None or isinstance(sql_path, Column): +4859 return sql_path +4860 if not isinstance(sql_path, str): +4861 raise ValueError(f"Invalid type provided for column: {type(sql_path)}") +4862 return column(*reversed(sql_path.split(".")), **kwargs) # type: ignore +4863 4864 -4865 Args: -4866 values: values statements that will be converted to SQL -4867 alias: optional alias -4868 columns: Optional list of ordered column names or ordered dictionary of column names to types. -4869 If either are provided then an alias is also required. -4870 If a dictionary is provided then the first column of the values will be casted to the expected type -4871 in order to help with type inference. -4872 -4873 Returns: -4874 Values: the Values expression object -4875 """ -4876 if columns and not alias: -4877 raise ValueError("Alias is required when providing columns") -4878 table_alias = ( -4879 TableAlias(this=to_identifier(alias), columns=[to_identifier(x) for x in columns]) -4880 if columns -4881 else TableAlias(this=to_identifier(alias) if alias else None) -4882 ) -4883 expressions = [convert(tup) for tup in values] -4884 if columns and isinstance(columns, dict): -4885 types = list(columns.values()) -4886 expressions[0].set( -4887 "expressions", -4888 [cast(x, types[i]) for i, x in enumerate(expressions[0].expressions)], -4889 ) -4890 return Values( -4891 expressions=expressions, -4892 alias=table_alias, -4893 ) -4894 -4895 -4896def var(name: t.Optional[ExpOrStr]) -> Var: -4897 """Build a SQL variable. -4898 -4899 Example: -4900 >>> repr(var('x')) -4901 '(VAR this: x)' -4902 -4903 >>> repr(var(column('x', table='y'))) -4904 '(VAR this: x)' -4905 -4906 Args: -4907 name: The name of the var or an expression who's name will become the var. -4908 -4909 Returns: -4910 The new variable node. -4911 """ -4912 if not name: -4913 raise ValueError("Cannot convert empty name into var.") -4914 -4915 if isinstance(name, Expression): -4916 name = name.name -4917 return Var(this=name) -4918 -4919 -4920def rename_table(old_name: str | Table, new_name: str | Table) -> AlterTable: -4921 """Build ALTER TABLE... RENAME... expression +4865def alias_( +4866 expression: ExpOrStr, +4867 alias: str | Identifier, +4868 table: bool | t.Sequence[str | Identifier] = False, +4869 quoted: t.Optional[bool] = None, +4870 dialect: DialectType = None, +4871 **opts, +4872): +4873 """Create an Alias expression. +4874 +4875 Example: +4876 >>> alias_('foo', 'bar').sql() +4877 'foo AS bar' +4878 +4879 >>> alias_('(select 1, 2)', 'bar', table=['a', 'b']).sql() +4880 '(SELECT 1, 2) AS bar(a, b)' +4881 +4882 Args: +4883 expression: the SQL code strings to parse. +4884 If an Expression instance is passed, this is used as-is. +4885 alias: the alias name to use. If the name has +4886 special characters it is quoted. +4887 table: Whether or not to create a table alias, can also be a list of columns. +4888 quoted: whether or not to quote the alias +4889 dialect: the dialect used to parse the input expression. +4890 **opts: other options to use to parse the input expressions. +4891 +4892 Returns: +4893 Alias: the aliased expression +4894 """ +4895 exp = maybe_parse(expression, dialect=dialect, **opts) +4896 alias = to_identifier(alias, quoted=quoted) +4897 +4898 if table: +4899 table_alias = TableAlias(this=alias) +4900 +4901 exp = exp.copy() if isinstance(expression, Expression) else exp +4902 exp.set("alias", table_alias) +4903 +4904 if not isinstance(table, bool): +4905 for column in table: +4906 table_alias.append("columns", to_identifier(column, quoted=quoted)) +4907 +4908 return exp +4909 +4910 # We don't set the "alias" arg for Window expressions, because that would add an IDENTIFIER node in +4911 # the AST, representing a "named_window" [1] construct (eg. bigquery). What we want is an ALIAS node +4912 # for the complete Window expression. +4913 # +4914 # [1]: https://cloud.google.com/bigquery/docs/reference/standard-sql/window-function-calls +4915 +4916 if "alias" in exp.arg_types and not isinstance(exp, Window): +4917 exp = exp.copy() +4918 exp.set("alias", alias) +4919 return exp +4920 return Alias(this=exp, alias=alias) +4921 4922 -4923 Args: -4924 old_name: The old name of the table -4925 new_name: The new name of the table +4923def subquery(expression, alias=None, dialect=None, **opts): +4924 """ +4925 Build a subquery expression. 4926 -4927 Returns: -4928 Alter table expression -4929 """ -4930 old_table = to_table(old_name) -4931 new_table = to_table(new_name) -4932 return AlterTable( -4933 this=old_table, -4934 actions=[ -4935 RenameTable(this=new_table), -4936 ], -4937 ) -4938 -4939 -4940def convert(value) -> Expression: -4941 """Convert a python value into an expression object. -4942 -4943 Raises an error if a conversion is not possible. +4927 Example: +4928 >>> subquery('select x from tbl', 'bar').select('x').sql() +4929 'SELECT x FROM (SELECT x FROM tbl) AS bar' +4930 +4931 Args: +4932 expression (str | Expression): the SQL code strings to parse. +4933 If an Expression instance is passed, this is used as-is. +4934 alias (str | Expression): the alias name to use. +4935 dialect (str): the dialect used to parse the input expression. +4936 **opts: other options to use to parse the input expressions. +4937 +4938 Returns: +4939 Select: a new select with the subquery expression included +4940 """ +4941 +4942 expression = maybe_parse(expression, dialect=dialect, **opts).subquery(alias) +4943 return Select().from_(expression, dialect=dialect, **opts) 4944 -4945 Args: -4946 value (Any): a python object -4947 -4948 Returns: -4949 Expression: the equivalent expression object -4950 """ -4951 if isinstance(value, Expression): -4952 return value -4953 if value is None: -4954 return NULL -4955 if isinstance(value, bool): -4956 return Boolean(this=value) -4957 if isinstance(value, str): -4958 return Literal.string(value) -4959 if isinstance(value, float) and math.isnan(value): -4960 return NULL -4961 if isinstance(value, numbers.Number): -4962 return Literal.number(value) -4963 if isinstance(value, tuple): -4964 return Tuple(expressions=[convert(v) for v in value]) -4965 if isinstance(value, list): -4966 return Array(expressions=[convert(v) for v in value]) -4967 if isinstance(value, dict): -4968 return Map( -4969 keys=[convert(k) for k in value], -4970 values=[convert(v) for v in value.values()], -4971 ) -4972 if isinstance(value, datetime.datetime): -4973 datetime_literal = Literal.string( -4974 (value if value.tzinfo else value.replace(tzinfo=datetime.timezone.utc)).isoformat() -4975 ) -4976 return TimeStrToTime(this=datetime_literal) -4977 if isinstance(value, datetime.date): -4978 date_literal = Literal.string(value.strftime("%Y-%m-%d")) -4979 return DateStrToDate(this=date_literal) -4980 raise ValueError(f"Cannot convert {value}") -4981 -4982 -4983def replace_children(expression, fun, *args, **kwargs): -4984 """ -4985 Replace children of an expression with the result of a lambda fun(child) -> exp. +4945 +4946def column( +4947 col: str | Identifier, +4948 table: t.Optional[str | Identifier] = None, +4949 db: t.Optional[str | Identifier] = None, +4950 catalog: t.Optional[str | Identifier] = None, +4951 quoted: t.Optional[bool] = None, +4952) -> Column: +4953 """ +4954 Build a Column. +4955 +4956 Args: +4957 col: column name +4958 table: table name +4959 db: db name +4960 catalog: catalog name +4961 quoted: whether or not to force quote each part +4962 Returns: +4963 Column: column instance +4964 """ +4965 return Column( +4966 this=to_identifier(col, quoted=quoted), +4967 table=to_identifier(table, quoted=quoted), +4968 db=to_identifier(db, quoted=quoted), +4969 catalog=to_identifier(catalog, quoted=quoted), +4970 ) +4971 +4972 +4973def cast(expression: ExpOrStr, to: str | DataType | DataType.Type, **opts) -> Cast: +4974 """Cast an expression to a data type. +4975 +4976 Example: +4977 >>> cast('x + 1', 'int').sql() +4978 'CAST(x + 1 AS INT)' +4979 +4980 Args: +4981 expression: The expression to cast. +4982 to: The datatype to cast to. +4983 +4984 Returns: +4985 A cast node. 4986 """ -4987 for k, v in expression.args.items(): -4988 is_list_arg = type(v) is list +4987 expression = maybe_parse(expression, **opts) +4988 return Cast(this=expression, to=DataType.build(to, **opts)) 4989 -4990 child_nodes = v if is_list_arg else [v] -4991 new_child_nodes = [] -4992 -4993 for cn in child_nodes: -4994 if isinstance(cn, Expression): -4995 for child_node in ensure_collection(fun(cn, *args, **kwargs)): -4996 new_child_nodes.append(child_node) -4997 child_node.parent = expression -4998 child_node.arg_key = k -4999 else: -5000 new_child_nodes.append(cn) -5001 -5002 expression.args[k] = new_child_nodes if is_list_arg else seq_get(new_child_nodes, 0) -5003 -5004 -5005def column_table_names(expression): -5006 """ -5007 Return all table names referenced through columns in an expression. +4990 +4991def table_(table, db=None, catalog=None, quoted=None, alias=None) -> Table: +4992 """Build a Table. +4993 +4994 Args: +4995 table (str | Expression): column name +4996 db (str | Expression): db name +4997 catalog (str | Expression): catalog name +4998 +4999 Returns: +5000 Table: table instance +5001 """ +5002 return Table( +5003 this=to_identifier(table, quoted=quoted), +5004 db=to_identifier(db, quoted=quoted), +5005 catalog=to_identifier(catalog, quoted=quoted), +5006 alias=TableAlias(this=to_identifier(alias)) if alias else None, +5007 ) 5008 -5009 Example: -5010 >>> import sqlglot -5011 >>> column_table_names(sqlglot.parse_one("a.b AND c.d AND c.e")) -5012 ['c', 'a'] -5013 -5014 Args: -5015 expression (sqlglot.Expression): expression to find table names +5009 +5010def values( +5011 values: t.Iterable[t.Tuple[t.Any, ...]], +5012 alias: t.Optional[str] = None, +5013 columns: t.Optional[t.Iterable[str] | t.Dict[str, DataType]] = None, +5014) -> Values: +5015 """Build VALUES statement. 5016 -5017 Returns: -5018 list: A list of unique names -5019 """ -5020 return list(dict.fromkeys(column.table for column in expression.find_all(Column))) -5021 -5022 -5023def table_name(table) -> str: -5024 """Get the full name of a table as a string. -5025 -5026 Args: -5027 table (exp.Table | str): table expression node or string. -5028 -5029 Examples: -5030 >>> from sqlglot import exp, parse_one -5031 >>> table_name(parse_one("select * from a.b.c").find(exp.Table)) -5032 'a.b.c' -5033 -5034 Returns: -5035 The table name. -5036 """ -5037 -5038 table = maybe_parse(table, into=Table) -5039 -5040 if not table: -5041 raise ValueError(f"Cannot parse {table}") +5017 Example: +5018 >>> values([(1, '2')]).sql() +5019 "VALUES (1, '2')" +5020 +5021 Args: +5022 values: values statements that will be converted to SQL +5023 alias: optional alias +5024 columns: Optional list of ordered column names or ordered dictionary of column names to types. +5025 If either are provided then an alias is also required. +5026 +5027 Returns: +5028 Values: the Values expression object +5029 """ +5030 if columns and not alias: +5031 raise ValueError("Alias is required when providing columns") +5032 +5033 return Values( +5034 expressions=[convert(tup) for tup in values], +5035 alias=( +5036 TableAlias(this=to_identifier(alias), columns=[to_identifier(x) for x in columns]) +5037 if columns +5038 else (TableAlias(this=to_identifier(alias)) if alias else None) +5039 ), +5040 ) +5041 5042 -5043 return ".".join( -5044 part -5045 for part in ( -5046 table.text("catalog"), -5047 table.text("db"), -5048 table.name, -5049 ) -5050 if part -5051 ) +5043def var(name: t.Optional[ExpOrStr]) -> Var: +5044 """Build a SQL variable. +5045 +5046 Example: +5047 >>> repr(var('x')) +5048 '(VAR this: x)' +5049 +5050 >>> repr(var(column('x', table='y'))) +5051 '(VAR this: x)' 5052 -5053 -5054def replace_tables(expression, mapping): -5055 """Replace all tables in expression according to the mapping. -5056 -5057 Args: -5058 expression (sqlglot.Expression): expression node to be transformed and replaced. -5059 mapping (Dict[str, str]): mapping of table names. -5060 -5061 Examples: -5062 >>> from sqlglot import exp, parse_one -5063 >>> replace_tables(parse_one("select * from a.b"), {"a.b": "c"}).sql() -5064 'SELECT * FROM c' +5053 Args: +5054 name: The name of the var or an expression who's name will become the var. +5055 +5056 Returns: +5057 The new variable node. +5058 """ +5059 if not name: +5060 raise ValueError("Cannot convert empty name into var.") +5061 +5062 if isinstance(name, Expression): +5063 name = name.name +5064 return Var(this=name) 5065 -5066 Returns: -5067 The mapped expression. -5068 """ +5066 +5067def rename_table(old_name: str | Table, new_name: str | Table) -> AlterTable: +5068 """Build ALTER TABLE... RENAME... expression 5069 -5070 def _replace_tables(node): -5071 if isinstance(node, Table): -5072 new_name = mapping.get(table_name(node)) -5073 if new_name: -5074 return to_table( -5075 new_name, -5076 **{k: v for k, v in node.args.items() if k not in ("this", "db", "catalog")}, -5077 ) -5078 return node -5079 -5080 return expression.transform(_replace_tables) -5081 -5082 -5083def replace_placeholders(expression, *args, **kwargs): -5084 """Replace placeholders in an expression. +5070 Args: +5071 old_name: The old name of the table +5072 new_name: The new name of the table +5073 +5074 Returns: +5075 Alter table expression +5076 """ +5077 old_table = to_table(old_name) +5078 new_table = to_table(new_name) +5079 return AlterTable( +5080 this=old_table, +5081 actions=[ +5082 RenameTable(this=new_table), +5083 ], +5084 ) 5085 -5086 Args: -5087 expression (sqlglot.Expression): expression node to be transformed and replaced. -5088 args: positional names that will substitute unnamed placeholders in the given order. -5089 kwargs: keyword arguments that will substitute named placeholders. -5090 -5091 Examples: -5092 >>> from sqlglot import exp, parse_one -5093 >>> replace_placeholders( -5094 ... parse_one("select * from :tbl where ? = ?"), -5095 ... exp.to_identifier("str_col"), "b", tbl=exp.to_identifier("foo") -5096 ... ).sql() -5097 "SELECT * FROM foo WHERE str_col = 'b'" -5098 -5099 Returns: -5100 The mapped expression. -5101 """ -5102 -5103 def _replace_placeholders(node, args, **kwargs): -5104 if isinstance(node, Placeholder): -5105 if node.name: -5106 new_name = kwargs.get(node.name) -5107 if new_name: -5108 return convert(new_name) -5109 else: -5110 try: -5111 return convert(next(args)) -5112 except StopIteration: -5113 pass -5114 return node -5115 -5116 return expression.transform(_replace_placeholders, iter(args), **kwargs) -5117 -5118 -5119def expand( -5120 expression: Expression, sources: t.Dict[str, Subqueryable], copy: bool = True -5121) -> Expression: -5122 """Transforms an expression by expanding all referenced sources into subqueries. -5123 -5124 Examples: -5125 >>> from sqlglot import parse_one -5126 >>> expand(parse_one("select * from x AS z"), {"x": parse_one("select * from y")}).sql() -5127 'SELECT * FROM (SELECT * FROM y) AS z /* source: x */' +5086 +5087def convert(value: t.Any, copy: bool = False) -> Expression: +5088 """Convert a python value into an expression object. +5089 +5090 Raises an error if a conversion is not possible. +5091 +5092 Args: +5093 value: A python object. +5094 copy: Whether or not to copy `value` (only applies to Expressions and collections). +5095 +5096 Returns: +5097 Expression: the equivalent expression object. +5098 """ +5099 if isinstance(value, Expression): +5100 return _maybe_copy(value, copy) +5101 if isinstance(value, str): +5102 return Literal.string(value) +5103 if isinstance(value, bool): +5104 return Boolean(this=value) +5105 if value is None or (isinstance(value, float) and math.isnan(value)): +5106 return NULL +5107 if isinstance(value, numbers.Number): +5108 return Literal.number(value) +5109 if isinstance(value, datetime.datetime): +5110 datetime_literal = Literal.string( +5111 (value if value.tzinfo else value.replace(tzinfo=datetime.timezone.utc)).isoformat() +5112 ) +5113 return TimeStrToTime(this=datetime_literal) +5114 if isinstance(value, datetime.date): +5115 date_literal = Literal.string(value.strftime("%Y-%m-%d")) +5116 return DateStrToDate(this=date_literal) +5117 if isinstance(value, tuple): +5118 return Tuple(expressions=[convert(v, copy=copy) for v in value]) +5119 if isinstance(value, list): +5120 return Array(expressions=[convert(v, copy=copy) for v in value]) +5121 if isinstance(value, dict): +5122 return Map( +5123 keys=[convert(k, copy=copy) for k in value], +5124 values=[convert(v, copy=copy) for v in value.values()], +5125 ) +5126 raise ValueError(f"Cannot convert {value}") +5127 5128 -5129 >>> expand(parse_one("select * from x AS z"), {"x": parse_one("select * from y"), "y": parse_one("select * from z")}).sql() -5130 'SELECT * FROM (SELECT * FROM (SELECT * FROM z) AS y /* source: y */) AS z /* source: x */' -5131 -5132 Args: -5133 expression: The expression to expand. -5134 sources: A dictionary of name to Subqueryables. -5135 copy: Whether or not to copy the expression during transformation. Defaults to True. -5136 -5137 Returns: -5138 The transformed expression. -5139 """ -5140 -5141 def _expand(node: Expression): -5142 if isinstance(node, Table): -5143 name = table_name(node) -5144 source = sources.get(name) -5145 if source: -5146 subquery = source.subquery(node.alias or name) -5147 subquery.comments = [f"source: {name}"] -5148 return subquery.transform(_expand, copy=False) -5149 return node +5129def replace_children(expression, fun, *args, **kwargs): +5130 """ +5131 Replace children of an expression with the result of a lambda fun(child) -> exp. +5132 """ +5133 for k, v in expression.args.items(): +5134 is_list_arg = type(v) is list +5135 +5136 child_nodes = v if is_list_arg else [v] +5137 new_child_nodes = [] +5138 +5139 for cn in child_nodes: +5140 if isinstance(cn, Expression): +5141 for child_node in ensure_collection(fun(cn, *args, **kwargs)): +5142 new_child_nodes.append(child_node) +5143 child_node.parent = expression +5144 child_node.arg_key = k +5145 else: +5146 new_child_nodes.append(cn) +5147 +5148 expression.args[k] = new_child_nodes if is_list_arg else seq_get(new_child_nodes, 0) +5149 5150 -5151 return expression.transform(_expand, copy=copy) -5152 -5153 -5154def func(name: str, *args, dialect: DialectType = None, **kwargs) -> Func: -5155 """ -5156 Returns a Func expression. -5157 -5158 Examples: -5159 >>> func("abs", 5).sql() -5160 'ABS(5)' -5161 -5162 >>> func("cast", this=5, to=DataType.build("DOUBLE")).sql() -5163 'CAST(5 AS DOUBLE)' -5164 -5165 Args: -5166 name: the name of the function to build. -5167 args: the args used to instantiate the function of interest. -5168 dialect: the source dialect. -5169 kwargs: the kwargs used to instantiate the function of interest. -5170 -5171 Note: -5172 The arguments `args` and `kwargs` are mutually exclusive. -5173 -5174 Returns: -5175 An instance of the function of interest, or an anonymous function, if `name` doesn't -5176 correspond to an existing `sqlglot.expressions.Func` class. -5177 """ -5178 if args and kwargs: -5179 raise ValueError("Can't use both args and kwargs to instantiate a function.") -5180 -5181 from sqlglot.dialects.dialect import Dialect -5182 -5183 converted = [convert(arg) for arg in args] -5184 kwargs = {key: convert(value) for key, value in kwargs.items()} +5151def column_table_names(expression): +5152 """ +5153 Return all table names referenced through columns in an expression. +5154 +5155 Example: +5156 >>> import sqlglot +5157 >>> column_table_names(sqlglot.parse_one("a.b AND c.d AND c.e")) +5158 ['c', 'a'] +5159 +5160 Args: +5161 expression (sqlglot.Expression): expression to find table names +5162 +5163 Returns: +5164 list: A list of unique names +5165 """ +5166 return list(dict.fromkeys(column.table for column in expression.find_all(Column))) +5167 +5168 +5169def table_name(table) -> str: +5170 """Get the full name of a table as a string. +5171 +5172 Args: +5173 table (exp.Table | str): table expression node or string. +5174 +5175 Examples: +5176 >>> from sqlglot import exp, parse_one +5177 >>> table_name(parse_one("select * from a.b.c").find(exp.Table)) +5178 'a.b.c' +5179 +5180 Returns: +5181 The table name. +5182 """ +5183 +5184 table = maybe_parse(table, into=Table) 5185 -5186 parser = Dialect.get_or_raise(dialect)().parser() -5187 from_args_list = parser.FUNCTIONS.get(name.upper()) +5186 if not table: +5187 raise ValueError(f"Cannot parse {table}") 5188 -5189 if from_args_list: -5190 function = from_args_list(converted) if converted else from_args_list.__self__(**kwargs) # type: ignore -5191 else: -5192 kwargs = kwargs or {"expressions": converted} -5193 function = Anonymous(this=name, **kwargs) -5194 -5195 for error_message in function.error_messages(converted): -5196 raise ValueError(error_message) -5197 -5198 return function +5189 return ".".join( +5190 part +5191 for part in ( +5192 table.text("catalog"), +5193 table.text("db"), +5194 table.name, +5195 ) +5196 if part +5197 ) +5198 5199 -5200 -5201def true(): -5202 """ -5203 Returns a true Boolean expression. -5204 """ -5205 return Boolean(this=True) +5200def replace_tables(expression, mapping): +5201 """Replace all tables in expression according to the mapping. +5202 +5203 Args: +5204 expression (sqlglot.Expression): expression node to be transformed and replaced. +5205 mapping (Dict[str, str]): mapping of table names. 5206 -5207 -5208def false(): -5209 """ -5210 Returns a false Boolean expression. -5211 """ -5212 return Boolean(this=False) -5213 -5214 -5215def null(): -5216 """ -5217 Returns a Null expression. -5218 """ -5219 return Null() -5220 -5221 -5222# TODO: deprecate this -5223TRUE = Boolean(this=True) -5224FALSE = Boolean(this=False) -5225NULL = Null() +5207 Examples: +5208 >>> from sqlglot import exp, parse_one +5209 >>> replace_tables(parse_one("select * from a.b"), {"a.b": "c"}).sql() +5210 'SELECT * FROM c' +5211 +5212 Returns: +5213 The mapped expression. +5214 """ +5215 +5216 def _replace_tables(node): +5217 if isinstance(node, Table): +5218 new_name = mapping.get(table_name(node)) +5219 if new_name: +5220 return to_table( +5221 new_name, +5222 **{k: v for k, v in node.args.items() if k not in ("this", "db", "catalog")}, +5223 ) +5224 return node +5225 +5226 return expression.transform(_replace_tables) +5227 +5228 +5229def replace_placeholders(expression, *args, **kwargs): +5230 """Replace placeholders in an expression. +5231 +5232 Args: +5233 expression (sqlglot.Expression): expression node to be transformed and replaced. +5234 args: positional names that will substitute unnamed placeholders in the given order. +5235 kwargs: keyword arguments that will substitute named placeholders. +5236 +5237 Examples: +5238 >>> from sqlglot import exp, parse_one +5239 >>> replace_placeholders( +5240 ... parse_one("select * from :tbl where ? = ?"), +5241 ... exp.to_identifier("str_col"), "b", tbl=exp.to_identifier("foo") +5242 ... ).sql() +5243 "SELECT * FROM foo WHERE str_col = 'b'" +5244 +5245 Returns: +5246 The mapped expression. +5247 """ +5248 +5249 def _replace_placeholders(node, args, **kwargs): +5250 if isinstance(node, Placeholder): +5251 if node.name: +5252 new_name = kwargs.get(node.name) +5253 if new_name: +5254 return convert(new_name) +5255 else: +5256 try: +5257 return convert(next(args)) +5258 except StopIteration: +5259 pass +5260 return node +5261 +5262 return expression.transform(_replace_placeholders, iter(args), **kwargs) +5263 +5264 +5265def expand( +5266 expression: Expression, sources: t.Dict[str, Subqueryable], copy: bool = True +5267) -> Expression: +5268 """Transforms an expression by expanding all referenced sources into subqueries. +5269 +5270 Examples: +5271 >>> from sqlglot import parse_one +5272 >>> expand(parse_one("select * from x AS z"), {"x": parse_one("select * from y")}).sql() +5273 'SELECT * FROM (SELECT * FROM y) AS z /* source: x */' +5274 +5275 >>> expand(parse_one("select * from x AS z"), {"x": parse_one("select * from y"), "y": parse_one("select * from z")}).sql() +5276 'SELECT * FROM (SELECT * FROM (SELECT * FROM z) AS y /* source: y */) AS z /* source: x */' +5277 +5278 Args: +5279 expression: The expression to expand. +5280 sources: A dictionary of name to Subqueryables. +5281 copy: Whether or not to copy the expression during transformation. Defaults to True. +5282 +5283 Returns: +5284 The transformed expression. +5285 """ +5286 +5287 def _expand(node: Expression): +5288 if isinstance(node, Table): +5289 name = table_name(node) +5290 source = sources.get(name) +5291 if source: +5292 subquery = source.subquery(node.alias or name) +5293 subquery.comments = [f"source: {name}"] +5294 return subquery.transform(_expand, copy=False) +5295 return node +5296 +5297 return expression.transform(_expand, copy=copy) +5298 +5299 +5300def func(name: str, *args, dialect: DialectType = None, **kwargs) -> Func: +5301 """ +5302 Returns a Func expression. +5303 +5304 Examples: +5305 >>> func("abs", 5).sql() +5306 'ABS(5)' +5307 +5308 >>> func("cast", this=5, to=DataType.build("DOUBLE")).sql() +5309 'CAST(5 AS DOUBLE)' +5310 +5311 Args: +5312 name: the name of the function to build. +5313 args: the args used to instantiate the function of interest. +5314 dialect: the source dialect. +5315 kwargs: the kwargs used to instantiate the function of interest. +5316 +5317 Note: +5318 The arguments `args` and `kwargs` are mutually exclusive. +5319 +5320 Returns: +5321 An instance of the function of interest, or an anonymous function, if `name` doesn't +5322 correspond to an existing `sqlglot.expressions.Func` class. +5323 """ +5324 if args and kwargs: +5325 raise ValueError("Can't use both args and kwargs to instantiate a function.") +5326 +5327 from sqlglot.dialects.dialect import Dialect +5328 +5329 converted: t.List[Expression] = [maybe_parse(arg, dialect=dialect) for arg in args] +5330 kwargs = {key: maybe_parse(value, dialect=dialect) for key, value in kwargs.items()} +5331 +5332 parser = Dialect.get_or_raise(dialect)().parser() +5333 from_args_list = parser.FUNCTIONS.get(name.upper()) +5334 +5335 if from_args_list: +5336 function = from_args_list(converted) if converted else from_args_list.__self__(**kwargs) # type: ignore +5337 else: +5338 kwargs = kwargs or {"expressions": converted} +5339 function = Anonymous(this=name, **kwargs) +5340 +5341 for error_message in function.error_messages(converted): +5342 raise ValueError(error_message) +5343 +5344 return function +5345 +5346 +5347def true(): +5348 """ +5349 Returns a true Boolean expression. +5350 """ +5351 return Boolean(this=True) +5352 +5353 +5354def false(): +5355 """ +5356 Returns a false Boolean expression. +5357 """ +5358 return Boolean(this=False) +5359 +5360 +5361def null(): +5362 """ +5363 Returns a Null expression. +5364 """ +5365 return Null() +5366 +5367 +5368# TODO: deprecate this +5369TRUE = Boolean(this=True) +5370FALSE = Boolean(this=False) +5371NULL = Null() @@ -10116,7 +10295,7 @@ to check that the provided arguments don't exceed the function argument limit.
    653class Condition(Expression):
    -654    def and_(self, *expressions, dialect=None, **opts):
    +654    def and_(self, *expressions, dialect=None, copy=True, **opts):
     655        """
     656        AND this condition with one or multiple expressions.
     657
    @@ -10128,44 +10307,167 @@ to check that the provided arguments don't exceed the function argument limit.663            *expressions (str | Expression): the SQL code strings to parse.
     664                If an `Expression` instance is passed, it will be used as-is.
     665            dialect (str): the dialect used to parse the input expression.
    -666            opts (kwargs): other options to use to parse the input expressions.
    -667
    -668        Returns:
    -669            And: the new condition.
    -670        """
    -671        return and_(self, *expressions, dialect=dialect, **opts)
    -672
    -673    def or_(self, *expressions, dialect=None, **opts):
    -674        """
    -675        OR this condition with one or multiple expressions.
    -676
    -677        Example:
    -678            >>> condition("x=1").or_("y=1").sql()
    -679            'x = 1 OR y = 1'
    -680
    -681        Args:
    -682            *expressions (str | Expression): the SQL code strings to parse.
    -683                If an `Expression` instance is passed, it will be used as-is.
    -684            dialect (str): the dialect used to parse the input expression.
    -685            opts (kwargs): other options to use to parse the input expressions.
    -686
    -687        Returns:
    -688            Or: the new condition.
    -689        """
    -690        return or_(self, *expressions, dialect=dialect, **opts)
    -691
    -692    def not_(self):
    -693        """
    -694        Wrap this condition with NOT.
    -695
    -696        Example:
    -697            >>> condition("x=1").not_().sql()
    -698            'NOT x = 1'
    -699
    -700        Returns:
    -701            Not: the new condition.
    -702        """
    -703        return not_(self)
    +666            copy (bool): whether or not to copy the involved expressions (only applies to Expressions).
    +667            opts (kwargs): other options to use to parse the input expressions.
    +668
    +669        Returns:
    +670            And: the new condition.
    +671        """
    +672        return and_(self, *expressions, dialect=dialect, copy=copy, **opts)
    +673
    +674    def or_(self, *expressions, dialect=None, copy=True, **opts):
    +675        """
    +676        OR this condition with one or multiple expressions.
    +677
    +678        Example:
    +679            >>> condition("x=1").or_("y=1").sql()
    +680            'x = 1 OR y = 1'
    +681
    +682        Args:
    +683            *expressions (str | Expression): the SQL code strings to parse.
    +684                If an `Expression` instance is passed, it will be used as-is.
    +685            dialect (str): the dialect used to parse the input expression.
    +686            copy (bool): whether or not to copy the involved expressions (only applies to Expressions).
    +687            opts (kwargs): other options to use to parse the input expressions.
    +688
    +689        Returns:
    +690            Or: the new condition.
    +691        """
    +692        return or_(self, *expressions, dialect=dialect, copy=copy, **opts)
    +693
    +694    def not_(self, copy=True):
    +695        """
    +696        Wrap this condition with NOT.
    +697
    +698        Example:
    +699            >>> condition("x=1").not_().sql()
    +700            'NOT x = 1'
    +701
    +702        Args:
    +703            copy (bool): whether or not to copy this object.
    +704
    +705        Returns:
    +706            Not: the new condition.
    +707        """
    +708        return not_(self, copy=copy)
    +709
    +710    def _binop(self, klass: t.Type[E], other: ExpOrStr, reverse=False) -> E:
    +711        this = self.copy()
    +712        other = convert(other, copy=True)
    +713        if not isinstance(this, klass) and not isinstance(other, klass):
    +714            this = _wrap(this, Binary)
    +715            other = _wrap(other, Binary)
    +716        if reverse:
    +717            return klass(this=other, expression=this)
    +718        return klass(this=this, expression=other)
    +719
    +720    def __getitem__(self, other: ExpOrStr | t.Tuple[ExpOrStr]):
    +721        return Bracket(
    +722            this=self.copy(), expressions=[convert(e, copy=True) for e in ensure_list(other)]
    +723        )
    +724
    +725    def isin(
    +726        self, *expressions: t.Any, query: t.Optional[ExpOrStr] = None, copy=True, **opts
    +727    ) -> In:
    +728        return In(
    +729            this=_maybe_copy(self, copy),
    +730            expressions=[convert(e, copy=copy) for e in expressions],
    +731            query=maybe_parse(query, copy=copy, **opts) if query else None,
    +732        )
    +733
    +734    def between(self, low: t.Any, high: t.Any, copy=True, **opts) -> Between:
    +735        return Between(
    +736            this=_maybe_copy(self, copy),
    +737            low=convert(low, copy=copy, **opts),
    +738            high=convert(high, copy=copy, **opts),
    +739        )
    +740
    +741    def like(self, other: ExpOrStr) -> Like:
    +742        return self._binop(Like, other)
    +743
    +744    def ilike(self, other: ExpOrStr) -> ILike:
    +745        return self._binop(ILike, other)
    +746
    +747    def eq(self, other: ExpOrStr) -> EQ:
    +748        return self._binop(EQ, other)
    +749
    +750    def neq(self, other: ExpOrStr) -> NEQ:
    +751        return self._binop(NEQ, other)
    +752
    +753    def rlike(self, other: ExpOrStr) -> RegexpLike:
    +754        return self._binop(RegexpLike, other)
    +755
    +756    def __lt__(self, other: ExpOrStr) -> LT:
    +757        return self._binop(LT, other)
    +758
    +759    def __le__(self, other: ExpOrStr) -> LTE:
    +760        return self._binop(LTE, other)
    +761
    +762    def __gt__(self, other: ExpOrStr) -> GT:
    +763        return self._binop(GT, other)
    +764
    +765    def __ge__(self, other: ExpOrStr) -> GTE:
    +766        return self._binop(GTE, other)
    +767
    +768    def __add__(self, other: ExpOrStr) -> Add:
    +769        return self._binop(Add, other)
    +770
    +771    def __radd__(self, other: ExpOrStr) -> Add:
    +772        return self._binop(Add, other, reverse=True)
    +773
    +774    def __sub__(self, other: ExpOrStr) -> Sub:
    +775        return self._binop(Sub, other)
    +776
    +777    def __rsub__(self, other: ExpOrStr) -> Sub:
    +778        return self._binop(Sub, other, reverse=True)
    +779
    +780    def __mul__(self, other: ExpOrStr) -> Mul:
    +781        return self._binop(Mul, other)
    +782
    +783    def __rmul__(self, other: ExpOrStr) -> Mul:
    +784        return self._binop(Mul, other, reverse=True)
    +785
    +786    def __truediv__(self, other: ExpOrStr) -> Div:
    +787        return self._binop(Div, other)
    +788
    +789    def __rtruediv__(self, other: ExpOrStr) -> Div:
    +790        return self._binop(Div, other, reverse=True)
    +791
    +792    def __floordiv__(self, other: ExpOrStr) -> IntDiv:
    +793        return self._binop(IntDiv, other)
    +794
    +795    def __rfloordiv__(self, other: ExpOrStr) -> IntDiv:
    +796        return self._binop(IntDiv, other, reverse=True)
    +797
    +798    def __mod__(self, other: ExpOrStr) -> Mod:
    +799        return self._binop(Mod, other)
    +800
    +801    def __rmod__(self, other: ExpOrStr) -> Mod:
    +802        return self._binop(Mod, other, reverse=True)
    +803
    +804    def __pow__(self, other: ExpOrStr) -> Pow:
    +805        return self._binop(Pow, other)
    +806
    +807    def __rpow__(self, other: ExpOrStr) -> Pow:
    +808        return self._binop(Pow, other, reverse=True)
    +809
    +810    def __and__(self, other: ExpOrStr) -> And:
    +811        return self._binop(And, other)
    +812
    +813    def __rand__(self, other: ExpOrStr) -> And:
    +814        return self._binop(And, other, reverse=True)
    +815
    +816    def __or__(self, other: ExpOrStr) -> Or:
    +817        return self._binop(Or, other)
    +818
    +819    def __ror__(self, other: ExpOrStr) -> Or:
    +820        return self._binop(Or, other, reverse=True)
    +821
    +822    def __neg__(self) -> Neg:
    +823        return Neg(this=_wrap(self.copy(), Binary))
    +824
    +825    def __invert__(self) -> Not:
    +826        return not_(self.copy())
     
    @@ -10176,13 +10478,13 @@ to check that the provided arguments don't exceed the function argument limit. def - and_(self, *expressions, dialect=None, **opts): + and_(self, *expressions, dialect=None, copy=True, **opts): -
    654    def and_(self, *expressions, dialect=None, **opts):
    +            
    654    def and_(self, *expressions, dialect=None, copy=True, **opts):
     655        """
     656        AND this condition with one or multiple expressions.
     657
    @@ -10194,12 +10496,13 @@ to check that the provided arguments don't exceed the function argument limit.663            *expressions (str | Expression): the SQL code strings to parse.
     664                If an `Expression` instance is passed, it will be used as-is.
     665            dialect (str): the dialect used to parse the input expression.
    -666            opts (kwargs): other options to use to parse the input expressions.
    -667
    -668        Returns:
    -669            And: the new condition.
    -670        """
    -671        return and_(self, *expressions, dialect=dialect, **opts)
    +666            copy (bool): whether or not to copy the involved expressions (only applies to Expressions).
    +667            opts (kwargs): other options to use to parse the input expressions.
    +668
    +669        Returns:
    +670            And: the new condition.
    +671        """
    +672        return and_(self, *expressions, dialect=dialect, copy=copy, **opts)
     
    @@ -10221,6 +10524,7 @@ to check that the provided arguments don't exceed the function argument limit.*expressions (str | Expression): the SQL code strings to parse. If an Expression instance is passed, it will be used as-is.
  • dialect (str): the dialect used to parse the input expression.
  • +
  • copy (bool): whether or not to copy the involved expressions (only applies to Expressions).
  • opts (kwargs): other options to use to parse the input expressions.
  • @@ -10238,30 +10542,31 @@ If an Expression instance is passed, it w
    def - or_(self, *expressions, dialect=None, **opts): + or_(self, *expressions, dialect=None, copy=True, **opts):
    -
    673    def or_(self, *expressions, dialect=None, **opts):
    -674        """
    -675        OR this condition with one or multiple expressions.
    -676
    -677        Example:
    -678            >>> condition("x=1").or_("y=1").sql()
    -679            'x = 1 OR y = 1'
    -680
    -681        Args:
    -682            *expressions (str | Expression): the SQL code strings to parse.
    -683                If an `Expression` instance is passed, it will be used as-is.
    -684            dialect (str): the dialect used to parse the input expression.
    -685            opts (kwargs): other options to use to parse the input expressions.
    -686
    -687        Returns:
    -688            Or: the new condition.
    -689        """
    -690        return or_(self, *expressions, dialect=dialect, **opts)
    +            
    674    def or_(self, *expressions, dialect=None, copy=True, **opts):
    +675        """
    +676        OR this condition with one or multiple expressions.
    +677
    +678        Example:
    +679            >>> condition("x=1").or_("y=1").sql()
    +680            'x = 1 OR y = 1'
    +681
    +682        Args:
    +683            *expressions (str | Expression): the SQL code strings to parse.
    +684                If an `Expression` instance is passed, it will be used as-is.
    +685            dialect (str): the dialect used to parse the input expression.
    +686            copy (bool): whether or not to copy the involved expressions (only applies to Expressions).
    +687            opts (kwargs): other options to use to parse the input expressions.
    +688
    +689        Returns:
    +690            Or: the new condition.
    +691        """
    +692        return or_(self, *expressions, dialect=dialect, copy=copy, **opts)
     
    @@ -10283,6 +10588,7 @@ If an Expression instance is passed, it w
  • *expressions (str | Expression): the SQL code strings to parse. If an Expression instance is passed, it will be used as-is.
  • dialect (str): the dialect used to parse the input expression.
  • +
  • copy (bool): whether or not to copy the involved expressions (only applies to Expressions).
  • opts (kwargs): other options to use to parse the input expressions.
  • @@ -10300,24 +10606,27 @@ If an Expression instance is passed, it w
    def - not_(self): + not_(self, copy=True):
    -
    692    def not_(self):
    -693        """
    -694        Wrap this condition with NOT.
    -695
    -696        Example:
    -697            >>> condition("x=1").not_().sql()
    -698            'NOT x = 1'
    -699
    -700        Returns:
    -701            Not: the new condition.
    -702        """
    -703        return not_(self)
    +            
    694    def not_(self, copy=True):
    +695        """
    +696        Wrap this condition with NOT.
    +697
    +698        Example:
    +699            >>> condition("x=1").not_().sql()
    +700            'NOT x = 1'
    +701
    +702        Args:
    +703            copy (bool): whether or not to copy this object.
    +704
    +705        Returns:
    +706            Not: the new condition.
    +707        """
    +708        return not_(self, copy=copy)
     
    @@ -10333,6 +10642,12 @@ If an Expression instance is passed, it w
    +
    Arguments:
    + +
      +
    • copy (bool): whether or not to copy this object.
    • +
    +
    Returns:
    @@ -10341,6 +10656,149 @@ If an Expression instance is passed, it w
    + +
    + +
    + + def + isin( self, *expressions: Any, query: Union[str, sqlglot.expressions.Expression, NoneType] = None, copy=True, **opts) -> sqlglot.expressions.In: + + + +
    + +
    725    def isin(
    +726        self, *expressions: t.Any, query: t.Optional[ExpOrStr] = None, copy=True, **opts
    +727    ) -> In:
    +728        return In(
    +729            this=_maybe_copy(self, copy),
    +730            expressions=[convert(e, copy=copy) for e in expressions],
    +731            query=maybe_parse(query, copy=copy, **opts) if query else None,
    +732        )
    +
    + + + + +
    +
    + +
    + + def + between( self, low: Any, high: Any, copy=True, **opts) -> sqlglot.expressions.Between: + + + +
    + +
    734    def between(self, low: t.Any, high: t.Any, copy=True, **opts) -> Between:
    +735        return Between(
    +736            this=_maybe_copy(self, copy),
    +737            low=convert(low, copy=copy, **opts),
    +738            high=convert(high, copy=copy, **opts),
    +739        )
    +
    + + + + +
    +
    + +
    + + def + like( self, other: Union[str, sqlglot.expressions.Expression]) -> sqlglot.expressions.Like: + + + +
    + +
    741    def like(self, other: ExpOrStr) -> Like:
    +742        return self._binop(Like, other)
    +
    + + + + +
    +
    + +
    + + def + ilike( self, other: Union[str, sqlglot.expressions.Expression]) -> sqlglot.expressions.ILike: + + + +
    + +
    744    def ilike(self, other: ExpOrStr) -> ILike:
    +745        return self._binop(ILike, other)
    +
    + + + + +
    +
    + +
    + + def + eq( self, other: Union[str, sqlglot.expressions.Expression]) -> sqlglot.expressions.EQ: + + + +
    + +
    747    def eq(self, other: ExpOrStr) -> EQ:
    +748        return self._binop(EQ, other)
    +
    + + + + +
    +
    + +
    + + def + neq( self, other: Union[str, sqlglot.expressions.Expression]) -> sqlglot.expressions.NEQ: + + + +
    + +
    750    def neq(self, other: ExpOrStr) -> NEQ:
    +751        return self._binop(NEQ, other)
    +
    + + + + +
    +
    + +
    + + def + rlike( self, other: Union[str, sqlglot.expressions.Expression]) -> sqlglot.expressions.RegexpLike: + + + +
    + +
    753    def rlike(self, other: ExpOrStr) -> RegexpLike:
    +754        return self._binop(RegexpLike, other)
    +
    + + + +
    Inherited Members
    @@ -10399,8 +10857,8 @@ If an Expression instance is passed, it w
    -
    706class Predicate(Condition):
    -707    """Relationships like x = y, x > 1, x >= y."""
    +            
    829class Predicate(Condition):
    +830    """Relationships like x = y, x > 1, x >= y."""
     
    @@ -10455,6 +10913,13 @@ If an Expression instance is passed, it w
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -10471,26 +10936,26 @@ If an Expression instance is passed, it w -
    710class DerivedTable(Expression):
    -711    @property
    -712    def alias_column_names(self):
    -713        table_alias = self.args.get("alias")
    -714        if not table_alias:
    -715            return []
    -716        column_list = table_alias.assert_is(TableAlias).args.get("columns") or []
    -717        return [c.name for c in column_list]
    -718
    -719    @property
    -720    def selects(self):
    -721        alias = self.args.get("alias")
    -722
    -723        if alias:
    -724            return alias.columns
    -725        return []
    -726
    -727    @property
    -728    def named_selects(self):
    -729        return [select.output_name for select in self.selects]
    +            
    833class DerivedTable(Expression):
    +834    @property
    +835    def alias_column_names(self):
    +836        table_alias = self.args.get("alias")
    +837        if not table_alias:
    +838            return []
    +839        column_list = table_alias.assert_is(TableAlias).args.get("columns") or []
    +840        return [c.name for c in column_list]
    +841
    +842    @property
    +843    def selects(self):
    +844        alias = self.args.get("alias")
    +845
    +846        if alias:
    +847            return alias.columns
    +848        return []
    +849
    +850    @property
    +851    def named_selects(self):
    +852        return [select.output_name for select in self.selects]
     
    @@ -10553,66 +11018,66 @@ If an Expression instance is passed, it w
    -
    732class Unionable(Expression):
    -733    def union(self, expression, distinct=True, dialect=None, **opts):
    -734        """
    -735        Builds a UNION expression.
    -736
    -737        Example:
    -738            >>> import sqlglot
    -739            >>> sqlglot.parse_one("SELECT * FROM foo").union("SELECT * FROM bla").sql()
    -740            'SELECT * FROM foo UNION SELECT * FROM bla'
    -741
    -742        Args:
    -743            expression (str | Expression): the SQL code string.
    -744                If an `Expression` instance is passed, it will be used as-is.
    -745            distinct (bool): set the DISTINCT flag if and only if this is true.
    -746            dialect (str): the dialect used to parse the input expression.
    -747            opts (kwargs): other options to use to parse the input expressions.
    -748        Returns:
    -749            Union: the Union expression.
    -750        """
    -751        return union(left=self, right=expression, distinct=distinct, dialect=dialect, **opts)
    -752
    -753    def intersect(self, expression, distinct=True, dialect=None, **opts):
    -754        """
    -755        Builds an INTERSECT expression.
    -756
    -757        Example:
    -758            >>> import sqlglot
    -759            >>> sqlglot.parse_one("SELECT * FROM foo").intersect("SELECT * FROM bla").sql()
    -760            'SELECT * FROM foo INTERSECT SELECT * FROM bla'
    -761
    -762        Args:
    -763            expression (str | Expression): the SQL code string.
    -764                If an `Expression` instance is passed, it will be used as-is.
    -765            distinct (bool): set the DISTINCT flag if and only if this is true.
    -766            dialect (str): the dialect used to parse the input expression.
    -767            opts (kwargs): other options to use to parse the input expressions.
    -768        Returns:
    -769            Intersect: the Intersect expression
    -770        """
    -771        return intersect(left=self, right=expression, distinct=distinct, dialect=dialect, **opts)
    -772
    -773    def except_(self, expression, distinct=True, dialect=None, **opts):
    -774        """
    -775        Builds an EXCEPT expression.
    -776
    -777        Example:
    -778            >>> import sqlglot
    -779            >>> sqlglot.parse_one("SELECT * FROM foo").except_("SELECT * FROM bla").sql()
    -780            'SELECT * FROM foo EXCEPT SELECT * FROM bla'
    -781
    -782        Args:
    -783            expression (str | Expression): the SQL code string.
    -784                If an `Expression` instance is passed, it will be used as-is.
    -785            distinct (bool): set the DISTINCT flag if and only if this is true.
    -786            dialect (str): the dialect used to parse the input expression.
    -787            opts (kwargs): other options to use to parse the input expressions.
    -788        Returns:
    -789            Except: the Except expression
    -790        """
    -791        return except_(left=self, right=expression, distinct=distinct, dialect=dialect, **opts)
    +            
    855class Unionable(Expression):
    +856    def union(self, expression, distinct=True, dialect=None, **opts):
    +857        """
    +858        Builds a UNION expression.
    +859
    +860        Example:
    +861            >>> import sqlglot
    +862            >>> sqlglot.parse_one("SELECT * FROM foo").union("SELECT * FROM bla").sql()
    +863            'SELECT * FROM foo UNION SELECT * FROM bla'
    +864
    +865        Args:
    +866            expression (str | Expression): the SQL code string.
    +867                If an `Expression` instance is passed, it will be used as-is.
    +868            distinct (bool): set the DISTINCT flag if and only if this is true.
    +869            dialect (str): the dialect used to parse the input expression.
    +870            opts (kwargs): other options to use to parse the input expressions.
    +871        Returns:
    +872            Union: the Union expression.
    +873        """
    +874        return union(left=self, right=expression, distinct=distinct, dialect=dialect, **opts)
    +875
    +876    def intersect(self, expression, distinct=True, dialect=None, **opts):
    +877        """
    +878        Builds an INTERSECT expression.
    +879
    +880        Example:
    +881            >>> import sqlglot
    +882            >>> sqlglot.parse_one("SELECT * FROM foo").intersect("SELECT * FROM bla").sql()
    +883            'SELECT * FROM foo INTERSECT SELECT * FROM bla'
    +884
    +885        Args:
    +886            expression (str | Expression): the SQL code string.
    +887                If an `Expression` instance is passed, it will be used as-is.
    +888            distinct (bool): set the DISTINCT flag if and only if this is true.
    +889            dialect (str): the dialect used to parse the input expression.
    +890            opts (kwargs): other options to use to parse the input expressions.
    +891        Returns:
    +892            Intersect: the Intersect expression
    +893        """
    +894        return intersect(left=self, right=expression, distinct=distinct, dialect=dialect, **opts)
    +895
    +896    def except_(self, expression, distinct=True, dialect=None, **opts):
    +897        """
    +898        Builds an EXCEPT expression.
    +899
    +900        Example:
    +901            >>> import sqlglot
    +902            >>> sqlglot.parse_one("SELECT * FROM foo").except_("SELECT * FROM bla").sql()
    +903            'SELECT * FROM foo EXCEPT SELECT * FROM bla'
    +904
    +905        Args:
    +906            expression (str | Expression): the SQL code string.
    +907                If an `Expression` instance is passed, it will be used as-is.
    +908            distinct (bool): set the DISTINCT flag if and only if this is true.
    +909            dialect (str): the dialect used to parse the input expression.
    +910            opts (kwargs): other options to use to parse the input expressions.
    +911        Returns:
    +912            Except: the Except expression
    +913        """
    +914        return except_(left=self, right=expression, distinct=distinct, dialect=dialect, **opts)
     
    @@ -10629,25 +11094,25 @@ If an Expression instance is passed, it w
    -
    733    def union(self, expression, distinct=True, dialect=None, **opts):
    -734        """
    -735        Builds a UNION expression.
    -736
    -737        Example:
    -738            >>> import sqlglot
    -739            >>> sqlglot.parse_one("SELECT * FROM foo").union("SELECT * FROM bla").sql()
    -740            'SELECT * FROM foo UNION SELECT * FROM bla'
    -741
    -742        Args:
    -743            expression (str | Expression): the SQL code string.
    -744                If an `Expression` instance is passed, it will be used as-is.
    -745            distinct (bool): set the DISTINCT flag if and only if this is true.
    -746            dialect (str): the dialect used to parse the input expression.
    -747            opts (kwargs): other options to use to parse the input expressions.
    -748        Returns:
    -749            Union: the Union expression.
    -750        """
    -751        return union(left=self, right=expression, distinct=distinct, dialect=dialect, **opts)
    +            
    856    def union(self, expression, distinct=True, dialect=None, **opts):
    +857        """
    +858        Builds a UNION expression.
    +859
    +860        Example:
    +861            >>> import sqlglot
    +862            >>> sqlglot.parse_one("SELECT * FROM foo").union("SELECT * FROM bla").sql()
    +863            'SELECT * FROM foo UNION SELECT * FROM bla'
    +864
    +865        Args:
    +866            expression (str | Expression): the SQL code string.
    +867                If an `Expression` instance is passed, it will be used as-is.
    +868            distinct (bool): set the DISTINCT flag if and only if this is true.
    +869            dialect (str): the dialect used to parse the input expression.
    +870            opts (kwargs): other options to use to parse the input expressions.
    +871        Returns:
    +872            Union: the Union expression.
    +873        """
    +874        return union(left=self, right=expression, distinct=distinct, dialect=dialect, **opts)
     
    @@ -10694,25 +11159,25 @@ If an Expression instance is passed, it w
    -
    753    def intersect(self, expression, distinct=True, dialect=None, **opts):
    -754        """
    -755        Builds an INTERSECT expression.
    -756
    -757        Example:
    -758            >>> import sqlglot
    -759            >>> sqlglot.parse_one("SELECT * FROM foo").intersect("SELECT * FROM bla").sql()
    -760            'SELECT * FROM foo INTERSECT SELECT * FROM bla'
    -761
    -762        Args:
    -763            expression (str | Expression): the SQL code string.
    -764                If an `Expression` instance is passed, it will be used as-is.
    -765            distinct (bool): set the DISTINCT flag if and only if this is true.
    -766            dialect (str): the dialect used to parse the input expression.
    -767            opts (kwargs): other options to use to parse the input expressions.
    -768        Returns:
    -769            Intersect: the Intersect expression
    -770        """
    -771        return intersect(left=self, right=expression, distinct=distinct, dialect=dialect, **opts)
    +            
    876    def intersect(self, expression, distinct=True, dialect=None, **opts):
    +877        """
    +878        Builds an INTERSECT expression.
    +879
    +880        Example:
    +881            >>> import sqlglot
    +882            >>> sqlglot.parse_one("SELECT * FROM foo").intersect("SELECT * FROM bla").sql()
    +883            'SELECT * FROM foo INTERSECT SELECT * FROM bla'
    +884
    +885        Args:
    +886            expression (str | Expression): the SQL code string.
    +887                If an `Expression` instance is passed, it will be used as-is.
    +888            distinct (bool): set the DISTINCT flag if and only if this is true.
    +889            dialect (str): the dialect used to parse the input expression.
    +890            opts (kwargs): other options to use to parse the input expressions.
    +891        Returns:
    +892            Intersect: the Intersect expression
    +893        """
    +894        return intersect(left=self, right=expression, distinct=distinct, dialect=dialect, **opts)
     
    @@ -10759,25 +11224,25 @@ If an Expression instance is passed, it w
    -
    773    def except_(self, expression, distinct=True, dialect=None, **opts):
    -774        """
    -775        Builds an EXCEPT expression.
    -776
    -777        Example:
    -778            >>> import sqlglot
    -779            >>> sqlglot.parse_one("SELECT * FROM foo").except_("SELECT * FROM bla").sql()
    -780            'SELECT * FROM foo EXCEPT SELECT * FROM bla'
    -781
    -782        Args:
    -783            expression (str | Expression): the SQL code string.
    -784                If an `Expression` instance is passed, it will be used as-is.
    -785            distinct (bool): set the DISTINCT flag if and only if this is true.
    -786            dialect (str): the dialect used to parse the input expression.
    -787            opts (kwargs): other options to use to parse the input expressions.
    -788        Returns:
    -789            Except: the Except expression
    -790        """
    -791        return except_(left=self, right=expression, distinct=distinct, dialect=dialect, **opts)
    +            
    896    def except_(self, expression, distinct=True, dialect=None, **opts):
    +897        """
    +898        Builds an EXCEPT expression.
    +899
    +900        Example:
    +901            >>> import sqlglot
    +902            >>> sqlglot.parse_one("SELECT * FROM foo").except_("SELECT * FROM bla").sql()
    +903            'SELECT * FROM foo EXCEPT SELECT * FROM bla'
    +904
    +905        Args:
    +906            expression (str | Expression): the SQL code string.
    +907                If an `Expression` instance is passed, it will be used as-is.
    +908            distinct (bool): set the DISTINCT flag if and only if this is true.
    +909            dialect (str): the dialect used to parse the input expression.
    +910            opts (kwargs): other options to use to parse the input expressions.
    +911        Returns:
    +912            Except: the Except expression
    +913        """
    +914        return except_(left=self, right=expression, distinct=distinct, dialect=dialect, **opts)
     
    @@ -10870,8 +11335,8 @@ If an Expression instance is passed, it w
    -
    794class UDTF(DerivedTable, Unionable):
    -795    pass
    +            
    917class UDTF(DerivedTable, Unionable):
    +918    pass
     
    @@ -10940,14 +11405,14 @@ If an Expression instance is passed, it w
    -
    798class Cache(Expression):
    -799    arg_types = {
    -800        "with": False,
    -801        "this": True,
    -802        "lazy": False,
    -803        "options": False,
    -804        "expression": False,
    -805    }
    +            
    921class Cache(Expression):
    +922    arg_types = {
    +923        "with": False,
    +924        "this": True,
    +925        "lazy": False,
    +926        "options": False,
    +927        "expression": False,
    +928    }
     
    @@ -11010,8 +11475,8 @@ If an Expression instance is passed, it w
    -
    808class Uncache(Expression):
    -809    arg_types = {"this": True, "exists": False}
    +            
    931class Uncache(Expression):
    +932    arg_types = {"this": True, "exists": False}
     
    @@ -11074,20 +11539,20 @@ If an Expression instance is passed, it w
    -
    812class Create(Expression):
    -813    arg_types = {
    -814        "with": False,
    -815        "this": True,
    -816        "kind": True,
    -817        "expression": False,
    -818        "exists": False,
    -819        "properties": False,
    -820        "replace": False,
    -821        "unique": False,
    -822        "indexes": False,
    -823        "no_schema_binding": False,
    -824        "begin": False,
    -825    }
    +            
    935class Create(Expression):
    +936    arg_types = {
    +937        "with": False,
    +938        "this": True,
    +939        "kind": True,
    +940        "expression": False,
    +941        "exists": False,
    +942        "properties": False,
    +943        "replace": False,
    +944        "unique": False,
    +945        "indexes": False,
    +946        "no_schema_binding": False,
    +947        "begin": False,
    +948    }
     
    @@ -11150,8 +11615,8 @@ If an Expression instance is passed, it w
    -
    828class Describe(Expression):
    -829    arg_types = {"this": True, "kind": False}
    +            
    951class Describe(Expression):
    +952    arg_types = {"this": True, "kind": False}
     
    @@ -11214,8 +11679,8 @@ If an Expression instance is passed, it w
    -
    832class Pragma(Expression):
    -833    pass
    +            
    955class Pragma(Expression):
    +956    pass
     
    @@ -11278,8 +11743,8 @@ If an Expression instance is passed, it w
    -
    836class Set(Expression):
    -837    arg_types = {"expressions": False}
    +            
    959class Set(Expression):
    +960    arg_types = {"expressions": False}
     
    @@ -11342,14 +11807,14 @@ If an Expression instance is passed, it w
    -
    840class SetItem(Expression):
    -841    arg_types = {
    -842        "this": False,
    -843        "expressions": False,
    -844        "kind": False,
    -845        "collate": False,  # MySQL SET NAMES statement
    -846        "global": False,
    -847    }
    +            
    963class SetItem(Expression):
    +964    arg_types = {
    +965        "this": False,
    +966        "expressions": False,
    +967        "kind": False,
    +968        "collate": False,  # MySQL SET NAMES statement
    +969        "global": False,
    +970    }
     
    @@ -11412,24 +11877,24 @@ If an Expression instance is passed, it w
    -
    850class Show(Expression):
    -851    arg_types = {
    -852        "this": True,
    -853        "target": False,
    -854        "offset": False,
    -855        "limit": False,
    -856        "like": False,
    -857        "where": False,
    -858        "db": False,
    -859        "full": False,
    -860        "mutex": False,
    -861        "query": False,
    -862        "channel": False,
    -863        "global": False,
    -864        "log": False,
    -865        "position": False,
    -866        "types": False,
    -867    }
    +            
    973class Show(Expression):
    +974    arg_types = {
    +975        "this": True,
    +976        "target": False,
    +977        "offset": False,
    +978        "limit": False,
    +979        "like": False,
    +980        "where": False,
    +981        "db": False,
    +982        "full": False,
    +983        "mutex": False,
    +984        "query": False,
    +985        "channel": False,
    +986        "global": False,
    +987        "log": False,
    +988        "position": False,
    +989        "types": False,
    +990    }
     
    @@ -11492,8 +11957,8 @@ If an Expression instance is passed, it w
    -
    870class UserDefinedFunction(Expression):
    -871    arg_types = {"this": True, "expressions": False, "wrapped": False}
    +            
    993class UserDefinedFunction(Expression):
    +994    arg_types = {"this": True, "expressions": False, "wrapped": False}
     
    @@ -11556,8 +12021,8 @@ If an Expression instance is passed, it w
    -
    874class CharacterSet(Expression):
    -875    arg_types = {"this": True, "default": False}
    +            
    997class CharacterSet(Expression):
    +998    arg_types = {"this": True, "default": False}
     
    @@ -11620,12 +12085,12 @@ If an Expression instance is passed, it w
    -
    878class With(Expression):
    -879    arg_types = {"expressions": True, "recursive": False}
    -880
    -881    @property
    -882    def recursive(self) -> bool:
    -883        return bool(self.args.get("recursive"))
    +            
    1001class With(Expression):
    +1002    arg_types = {"expressions": True, "recursive": False}
    +1003
    +1004    @property
    +1005    def recursive(self) -> bool:
    +1006        return bool(self.args.get("recursive"))
     
    @@ -11688,8 +12153,8 @@ If an Expression instance is passed, it w
    -
    886class WithinGroup(Expression):
    -887    arg_types = {"this": True, "expression": False}
    +            
    1009class WithinGroup(Expression):
    +1010    arg_types = {"this": True, "expression": False}
     
    @@ -11752,8 +12217,8 @@ If an Expression instance is passed, it w
    -
    890class CTE(DerivedTable):
    -891    arg_types = {"this": True, "alias": True}
    +            
    1013class CTE(DerivedTable):
    +1014    arg_types = {"this": True, "alias": True}
     
    @@ -11816,12 +12281,12 @@ If an Expression instance is passed, it w
    -
    894class TableAlias(Expression):
    -895    arg_types = {"this": False, "columns": False}
    -896
    -897    @property
    -898    def columns(self):
    -899        return self.args.get("columns") or []
    +            
    1017class TableAlias(Expression):
    +1018    arg_types = {"this": False, "columns": False}
    +1019
    +1020    @property
    +1021    def columns(self):
    +1022        return self.args.get("columns") or []
     
    @@ -11884,8 +12349,8 @@ If an Expression instance is passed, it w
    -
    902class BitString(Condition):
    -903    pass
    +            
    1025class BitString(Condition):
    +1026    pass
     
    @@ -11938,6 +12403,13 @@ If an Expression instance is passed, it w
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -11954,8 +12426,8 @@ If an Expression instance is passed, it w -
    906class HexString(Condition):
    -907    pass
    +            
    1029class HexString(Condition):
    +1030    pass
     
    @@ -12008,6 +12480,13 @@ If an Expression instance is passed, it w
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -12024,8 +12503,8 @@ If an Expression instance is passed, it w -
    910class ByteString(Condition):
    -911    pass
    +            
    1033class ByteString(Condition):
    +1034    pass
     
    @@ -12078,6 +12557,13 @@ If an Expression instance is passed, it w
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -12094,41 +12580,41 @@ If an Expression instance is passed, it w -
    914class Column(Condition):
    -915    arg_types = {"this": True, "table": False, "db": False, "catalog": False, "join_mark": False}
    -916
    -917    @property
    -918    def table(self) -> str:
    -919        return self.text("table")
    -920
    -921    @property
    -922    def db(self) -> str:
    -923        return self.text("db")
    -924
    -925    @property
    -926    def catalog(self) -> str:
    -927        return self.text("catalog")
    -928
    -929    @property
    -930    def output_name(self) -> str:
    -931        return self.name
    -932
    -933    @property
    -934    def parts(self) -> t.List[Identifier]:
    -935        """Return the parts of a column in order catalog, db, table, name."""
    -936        return [part for part in reversed(list(self.args.values())) if part]
    -937
    -938    def to_dot(self) -> Dot:
    -939        """Converts the column into a dot expression."""
    -940        parts = self.parts
    -941        parent = self.parent
    -942
    -943        while parent:
    -944            if isinstance(parent, Dot):
    -945                parts.append(parent.expression)
    -946            parent = parent.parent
    -947
    -948        return Dot.build(parts)
    +            
    1037class Column(Condition):
    +1038    arg_types = {"this": True, "table": False, "db": False, "catalog": False, "join_mark": False}
    +1039
    +1040    @property
    +1041    def table(self) -> str:
    +1042        return self.text("table")
    +1043
    +1044    @property
    +1045    def db(self) -> str:
    +1046        return self.text("db")
    +1047
    +1048    @property
    +1049    def catalog(self) -> str:
    +1050        return self.text("catalog")
    +1051
    +1052    @property
    +1053    def output_name(self) -> str:
    +1054        return self.name
    +1055
    +1056    @property
    +1057    def parts(self) -> t.List[Identifier]:
    +1058        """Return the parts of a column in order catalog, db, table, name."""
    +1059        return [part for part in reversed(list(self.args.values())) if part]
    +1060
    +1061    def to_dot(self) -> Dot:
    +1062        """Converts the column into a dot expression."""
    +1063        parts = self.parts
    +1064        parent = self.parent
    +1065
    +1066        while parent:
    +1067            if isinstance(parent, Dot):
    +1068                parts.append(parent.expression)
    +1069            parent = parent.parent
    +1070
    +1071        return Dot.build(parts)
     
    @@ -12188,17 +12674,17 @@ If an Expression instance is passed, it w
    -
    938    def to_dot(self) -> Dot:
    -939        """Converts the column into a dot expression."""
    -940        parts = self.parts
    -941        parent = self.parent
    -942
    -943        while parent:
    -944            if isinstance(parent, Dot):
    -945                parts.append(parent.expression)
    -946            parent = parent.parent
    -947
    -948        return Dot.build(parts)
    +            
    1061    def to_dot(self) -> Dot:
    +1062        """Converts the column into a dot expression."""
    +1063        parts = self.parts
    +1064        parent = self.parent
    +1065
    +1066        while parent:
    +1067            if isinstance(parent, Dot):
    +1068                parts.append(parent.expression)
    +1069            parent = parent.parent
    +1070
    +1071        return Dot.build(parts)
     
    @@ -12253,6 +12739,13 @@ If an Expression instance is passed, it w
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -12269,8 +12762,8 @@ If an Expression instance is passed, it w -
    951class ColumnPosition(Expression):
    -952    arg_types = {"this": False, "position": True}
    +            
    1074class ColumnPosition(Expression):
    +1075    arg_types = {"this": False, "position": True}
     
    @@ -12333,14 +12826,14 @@ If an Expression instance is passed, it w
    -
    955class ColumnDef(Expression):
    -956    arg_types = {
    -957        "this": True,
    -958        "kind": False,
    -959        "constraints": False,
    -960        "exists": False,
    -961        "position": False,
    -962    }
    +            
    1078class ColumnDef(Expression):
    +1079    arg_types = {
    +1080        "this": True,
    +1081        "kind": False,
    +1082        "constraints": False,
    +1083        "exists": False,
    +1084        "position": False,
    +1085    }
     
    @@ -12403,15 +12896,15 @@ If an Expression instance is passed, it w
    -
    965class AlterColumn(Expression):
    -966    arg_types = {
    -967        "this": True,
    -968        "dtype": False,
    -969        "collate": False,
    -970        "using": False,
    -971        "default": False,
    -972        "drop": False,
    -973    }
    +            
    1088class AlterColumn(Expression):
    +1089    arg_types = {
    +1090        "this": True,
    +1091        "dtype": False,
    +1092        "collate": False,
    +1093        "using": False,
    +1094        "default": False,
    +1095        "drop": False,
    +1096    }
     
    @@ -12474,8 +12967,8 @@ If an Expression instance is passed, it w
    -
    976class RenameTable(Expression):
    -977    pass
    +            
    1099class RenameTable(Expression):
    +1100    pass
     
    @@ -12538,8 +13031,8 @@ If an Expression instance is passed, it w
    -
    980class SetTag(Expression):
    -981    arg_types = {"expressions": True, "unset": False}
    +            
    1103class SetTag(Expression):
    +1104    arg_types = {"expressions": True, "unset": False}
     
    @@ -12602,8 +13095,8 @@ If an Expression instance is passed, it w
    -
    984class Comment(Expression):
    -985    arg_types = {"this": True, "kind": True, "expression": True, "exists": False}
    +            
    1107class Comment(Expression):
    +1108    arg_types = {"this": True, "kind": True, "expression": True, "exists": False}
     
    @@ -12666,8 +13159,8 @@ If an Expression instance is passed, it w
    -
    988class ColumnConstraint(Expression):
    -989    arg_types = {"this": False, "kind": True}
    +            
    1111class ColumnConstraint(Expression):
    +1112    arg_types = {"this": False, "kind": True}
     
    @@ -12730,8 +13223,8 @@ If an Expression instance is passed, it w
    -
    992class ColumnConstraintKind(Expression):
    -993    pass
    +            
    1115class ColumnConstraintKind(Expression):
    +1116    pass
     
    @@ -12794,8 +13287,8 @@ If an Expression instance is passed, it w
    -
    996class AutoIncrementColumnConstraint(ColumnConstraintKind):
    -997    pass
    +            
    1119class AutoIncrementColumnConstraint(ColumnConstraintKind):
    +1120    pass
     
    @@ -12858,8 +13351,8 @@ If an Expression instance is passed, it w
    -
    1000class CaseSpecificColumnConstraint(ColumnConstraintKind):
    -1001    arg_types = {"not_": True}
    +            
    1123class CaseSpecificColumnConstraint(ColumnConstraintKind):
    +1124    arg_types = {"not_": True}
     
    @@ -12922,8 +13415,8 @@ If an Expression instance is passed, it w
    -
    1004class CharacterSetColumnConstraint(ColumnConstraintKind):
    -1005    arg_types = {"this": True}
    +            
    1127class CharacterSetColumnConstraint(ColumnConstraintKind):
    +1128    arg_types = {"this": True}
     
    @@ -12986,8 +13479,8 @@ If an Expression instance is passed, it w
    -
    1008class CheckColumnConstraint(ColumnConstraintKind):
    -1009    pass
    +            
    1131class CheckColumnConstraint(ColumnConstraintKind):
    +1132    pass
     
    @@ -13050,8 +13543,8 @@ If an Expression instance is passed, it w
    -
    1012class CollateColumnConstraint(ColumnConstraintKind):
    -1013    pass
    +            
    1135class CollateColumnConstraint(ColumnConstraintKind):
    +1136    pass
     
    @@ -13114,8 +13607,8 @@ If an Expression instance is passed, it w
    -
    1016class CommentColumnConstraint(ColumnConstraintKind):
    -1017    pass
    +            
    1139class CommentColumnConstraint(ColumnConstraintKind):
    +1140    pass
     
    @@ -13178,8 +13671,8 @@ If an Expression instance is passed, it w
    -
    1020class CompressColumnConstraint(ColumnConstraintKind):
    -1021    pass
    +            
    1143class CompressColumnConstraint(ColumnConstraintKind):
    +1144    pass
     
    @@ -13242,8 +13735,8 @@ If an Expression instance is passed, it w
    -
    1024class DateFormatColumnConstraint(ColumnConstraintKind):
    -1025    arg_types = {"this": True}
    +            
    1147class DateFormatColumnConstraint(ColumnConstraintKind):
    +1148    arg_types = {"this": True}
     
    @@ -13306,8 +13799,8 @@ If an Expression instance is passed, it w
    -
    1028class DefaultColumnConstraint(ColumnConstraintKind):
    -1029    pass
    +            
    1151class DefaultColumnConstraint(ColumnConstraintKind):
    +1152    pass
     
    @@ -13370,8 +13863,8 @@ If an Expression instance is passed, it w
    -
    1032class EncodeColumnConstraint(ColumnConstraintKind):
    -1033    pass
    +            
    1155class EncodeColumnConstraint(ColumnConstraintKind):
    +1156    pass
     
    @@ -13434,16 +13927,16 @@ If an Expression instance is passed, it w
    -
    1036class GeneratedAsIdentityColumnConstraint(ColumnConstraintKind):
    -1037    # this: True -> ALWAYS, this: False -> BY DEFAULT
    -1038    arg_types = {
    -1039        "this": False,
    -1040        "start": False,
    -1041        "increment": False,
    -1042        "minvalue": False,
    -1043        "maxvalue": False,
    -1044        "cycle": False,
    -1045    }
    +            
    1159class GeneratedAsIdentityColumnConstraint(ColumnConstraintKind):
    +1160    # this: True -> ALWAYS, this: False -> BY DEFAULT
    +1161    arg_types = {
    +1162        "this": False,
    +1163        "start": False,
    +1164        "increment": False,
    +1165        "minvalue": False,
    +1166        "maxvalue": False,
    +1167        "cycle": False,
    +1168    }
     
    @@ -13506,8 +13999,8 @@ If an Expression instance is passed, it w
    -
    1048class InlineLengthColumnConstraint(ColumnConstraintKind):
    -1049    pass
    +            
    1171class InlineLengthColumnConstraint(ColumnConstraintKind):
    +1172    pass
     
    @@ -13570,8 +14063,8 @@ If an Expression instance is passed, it w
    -
    1052class NotNullColumnConstraint(ColumnConstraintKind):
    -1053    arg_types = {"allow_null": False}
    +            
    1175class NotNullColumnConstraint(ColumnConstraintKind):
    +1176    arg_types = {"allow_null": False}
     
    @@ -13634,8 +14127,8 @@ If an Expression instance is passed, it w
    -
    1057class OnUpdateColumnConstraint(ColumnConstraintKind):
    -1058    pass
    +            
    1180class OnUpdateColumnConstraint(ColumnConstraintKind):
    +1181    pass
     
    @@ -13698,8 +14191,8 @@ If an Expression instance is passed, it w
    -
    1061class PrimaryKeyColumnConstraint(ColumnConstraintKind):
    -1062    arg_types = {"desc": False}
    +            
    1184class PrimaryKeyColumnConstraint(ColumnConstraintKind):
    +1185    arg_types = {"desc": False}
     
    @@ -13762,8 +14255,8 @@ If an Expression instance is passed, it w
    -
    1065class TitleColumnConstraint(ColumnConstraintKind):
    -1066    pass
    +            
    1188class TitleColumnConstraint(ColumnConstraintKind):
    +1189    pass
     
    @@ -13826,8 +14319,8 @@ If an Expression instance is passed, it w
    -
    1069class UniqueColumnConstraint(ColumnConstraintKind):
    -1070    arg_types: t.Dict[str, t.Any] = {}
    +            
    1192class UniqueColumnConstraint(ColumnConstraintKind):
    +1193    arg_types: t.Dict[str, t.Any] = {}
     
    @@ -13890,8 +14383,8 @@ If an Expression instance is passed, it w
    -
    1073class UppercaseColumnConstraint(ColumnConstraintKind):
    -1074    arg_types: t.Dict[str, t.Any] = {}
    +            
    1196class UppercaseColumnConstraint(ColumnConstraintKind):
    +1197    arg_types: t.Dict[str, t.Any] = {}
     
    @@ -13954,8 +14447,8 @@ If an Expression instance is passed, it w
    -
    1077class PathColumnConstraint(ColumnConstraintKind):
    -1078    pass
    +            
    1200class PathColumnConstraint(ColumnConstraintKind):
    +1201    pass
     
    @@ -14018,8 +14511,8 @@ If an Expression instance is passed, it w
    -
    1081class Constraint(Expression):
    -1082    arg_types = {"this": True, "expressions": True}
    +            
    1204class Constraint(Expression):
    +1205    arg_types = {"this": True, "expressions": True}
     
    @@ -14082,115 +14575,115 @@ If an Expression instance is passed, it w
    -
    1085class Delete(Expression):
    -1086    arg_types = {"with": False, "this": False, "using": False, "where": False, "returning": False}
    -1087
    -1088    def delete(
    -1089        self,
    -1090        table: ExpOrStr,
    -1091        dialect: DialectType = None,
    -1092        copy: bool = True,
    -1093        **opts,
    -1094    ) -> Delete:
    -1095        """
    -1096        Create a DELETE expression or replace the table on an existing DELETE expression.
    -1097
    -1098        Example:
    -1099            >>> delete("tbl").sql()
    -1100            'DELETE FROM tbl'
    -1101
    -1102        Args:
    -1103            table: the table from which to delete.
    -1104            dialect: the dialect used to parse the input expression.
    -1105            copy: if `False`, modify this expression instance in-place.
    -1106            opts: other options to use to parse the input expressions.
    -1107
    -1108        Returns:
    -1109            Delete: the modified expression.
    -1110        """
    -1111        return _apply_builder(
    -1112            expression=table,
    -1113            instance=self,
    -1114            arg="this",
    -1115            dialect=dialect,
    -1116            into=Table,
    -1117            copy=copy,
    -1118            **opts,
    -1119        )
    -1120
    -1121    def where(
    -1122        self,
    -1123        *expressions: ExpOrStr,
    -1124        append: bool = True,
    -1125        dialect: DialectType = None,
    -1126        copy: bool = True,
    -1127        **opts,
    -1128    ) -> Delete:
    -1129        """
    -1130        Append to or set the WHERE expressions.
    -1131
    -1132        Example:
    -1133            >>> delete("tbl").where("x = 'a' OR x < 'b'").sql()
    -1134            "DELETE FROM tbl WHERE x = 'a' OR x < 'b'"
    -1135
    -1136        Args:
    -1137            *expressions: the SQL code strings to parse.
    -1138                If an `Expression` instance is passed, it will be used as-is.
    -1139                Multiple expressions are combined with an AND operator.
    -1140            append: if `True`, AND the new expressions to any existing expression.
    -1141                Otherwise, this resets the expression.
    -1142            dialect: the dialect used to parse the input expressions.
    -1143            copy: if `False`, modify this expression instance in-place.
    -1144            opts: other options to use to parse the input expressions.
    -1145
    -1146        Returns:
    -1147            Delete: the modified expression.
    -1148        """
    -1149        return _apply_conjunction_builder(
    -1150            *expressions,
    -1151            instance=self,
    -1152            arg="where",
    -1153            append=append,
    -1154            into=Where,
    -1155            dialect=dialect,
    -1156            copy=copy,
    -1157            **opts,
    -1158        )
    -1159
    -1160    def returning(
    -1161        self,
    -1162        expression: ExpOrStr,
    -1163        dialect: DialectType = None,
    -1164        copy: bool = True,
    -1165        **opts,
    -1166    ) -> Delete:
    -1167        """
    -1168        Set the RETURNING expression. Not supported by all dialects.
    -1169
    -1170        Example:
    -1171            >>> delete("tbl").returning("*", dialect="postgres").sql()
    -1172            'DELETE FROM tbl RETURNING *'
    -1173
    -1174        Args:
    -1175            expression: the SQL code strings to parse.
    -1176                If an `Expression` instance is passed, it will be used as-is.
    -1177            dialect: the dialect used to parse the input expressions.
    -1178            copy: if `False`, modify this expression instance in-place.
    -1179            opts: other options to use to parse the input expressions.
    -1180
    -1181        Returns:
    -1182            Delete: the modified expression.
    -1183        """
    -1184        return _apply_builder(
    -1185            expression=expression,
    -1186            instance=self,
    -1187            arg="returning",
    -1188            prefix="RETURNING",
    -1189            dialect=dialect,
    -1190            copy=copy,
    -1191            into=Returning,
    -1192            **opts,
    -1193        )
    +            
    1208class Delete(Expression):
    +1209    arg_types = {"with": False, "this": False, "using": False, "where": False, "returning": False}
    +1210
    +1211    def delete(
    +1212        self,
    +1213        table: ExpOrStr,
    +1214        dialect: DialectType = None,
    +1215        copy: bool = True,
    +1216        **opts,
    +1217    ) -> Delete:
    +1218        """
    +1219        Create a DELETE expression or replace the table on an existing DELETE expression.
    +1220
    +1221        Example:
    +1222            >>> delete("tbl").sql()
    +1223            'DELETE FROM tbl'
    +1224
    +1225        Args:
    +1226            table: the table from which to delete.
    +1227            dialect: the dialect used to parse the input expression.
    +1228            copy: if `False`, modify this expression instance in-place.
    +1229            opts: other options to use to parse the input expressions.
    +1230
    +1231        Returns:
    +1232            Delete: the modified expression.
    +1233        """
    +1234        return _apply_builder(
    +1235            expression=table,
    +1236            instance=self,
    +1237            arg="this",
    +1238            dialect=dialect,
    +1239            into=Table,
    +1240            copy=copy,
    +1241            **opts,
    +1242        )
    +1243
    +1244    def where(
    +1245        self,
    +1246        *expressions: ExpOrStr,
    +1247        append: bool = True,
    +1248        dialect: DialectType = None,
    +1249        copy: bool = True,
    +1250        **opts,
    +1251    ) -> Delete:
    +1252        """
    +1253        Append to or set the WHERE expressions.
    +1254
    +1255        Example:
    +1256            >>> delete("tbl").where("x = 'a' OR x < 'b'").sql()
    +1257            "DELETE FROM tbl WHERE x = 'a' OR x < 'b'"
    +1258
    +1259        Args:
    +1260            *expressions: the SQL code strings to parse.
    +1261                If an `Expression` instance is passed, it will be used as-is.
    +1262                Multiple expressions are combined with an AND operator.
    +1263            append: if `True`, AND the new expressions to any existing expression.
    +1264                Otherwise, this resets the expression.
    +1265            dialect: the dialect used to parse the input expressions.
    +1266            copy: if `False`, modify this expression instance in-place.
    +1267            opts: other options to use to parse the input expressions.
    +1268
    +1269        Returns:
    +1270            Delete: the modified expression.
    +1271        """
    +1272        return _apply_conjunction_builder(
    +1273            *expressions,
    +1274            instance=self,
    +1275            arg="where",
    +1276            append=append,
    +1277            into=Where,
    +1278            dialect=dialect,
    +1279            copy=copy,
    +1280            **opts,
    +1281        )
    +1282
    +1283    def returning(
    +1284        self,
    +1285        expression: ExpOrStr,
    +1286        dialect: DialectType = None,
    +1287        copy: bool = True,
    +1288        **opts,
    +1289    ) -> Delete:
    +1290        """
    +1291        Set the RETURNING expression. Not supported by all dialects.
    +1292
    +1293        Example:
    +1294            >>> delete("tbl").returning("*", dialect="postgres").sql()
    +1295            'DELETE FROM tbl RETURNING *'
    +1296
    +1297        Args:
    +1298            expression: the SQL code strings to parse.
    +1299                If an `Expression` instance is passed, it will be used as-is.
    +1300            dialect: the dialect used to parse the input expressions.
    +1301            copy: if `False`, modify this expression instance in-place.
    +1302            opts: other options to use to parse the input expressions.
    +1303
    +1304        Returns:
    +1305            Delete: the modified expression.
    +1306        """
    +1307        return _apply_builder(
    +1308            expression=expression,
    +1309            instance=self,
    +1310            arg="returning",
    +1311            prefix="RETURNING",
    +1312            dialect=dialect,
    +1313            copy=copy,
    +1314            into=Returning,
    +1315            **opts,
    +1316        )
     
    @@ -14207,38 +14700,38 @@ If an Expression instance is passed, it w
    -
    1088    def delete(
    -1089        self,
    -1090        table: ExpOrStr,
    -1091        dialect: DialectType = None,
    -1092        copy: bool = True,
    -1093        **opts,
    -1094    ) -> Delete:
    -1095        """
    -1096        Create a DELETE expression or replace the table on an existing DELETE expression.
    -1097
    -1098        Example:
    -1099            >>> delete("tbl").sql()
    -1100            'DELETE FROM tbl'
    -1101
    -1102        Args:
    -1103            table: the table from which to delete.
    -1104            dialect: the dialect used to parse the input expression.
    -1105            copy: if `False`, modify this expression instance in-place.
    -1106            opts: other options to use to parse the input expressions.
    -1107
    -1108        Returns:
    -1109            Delete: the modified expression.
    -1110        """
    -1111        return _apply_builder(
    -1112            expression=table,
    -1113            instance=self,
    -1114            arg="this",
    -1115            dialect=dialect,
    -1116            into=Table,
    -1117            copy=copy,
    -1118            **opts,
    -1119        )
    +            
    1211    def delete(
    +1212        self,
    +1213        table: ExpOrStr,
    +1214        dialect: DialectType = None,
    +1215        copy: bool = True,
    +1216        **opts,
    +1217    ) -> Delete:
    +1218        """
    +1219        Create a DELETE expression or replace the table on an existing DELETE expression.
    +1220
    +1221        Example:
    +1222            >>> delete("tbl").sql()
    +1223            'DELETE FROM tbl'
    +1224
    +1225        Args:
    +1226            table: the table from which to delete.
    +1227            dialect: the dialect used to parse the input expression.
    +1228            copy: if `False`, modify this expression instance in-place.
    +1229            opts: other options to use to parse the input expressions.
    +1230
    +1231        Returns:
    +1232            Delete: the modified expression.
    +1233        """
    +1234        return _apply_builder(
    +1235            expression=table,
    +1236            instance=self,
    +1237            arg="this",
    +1238            dialect=dialect,
    +1239            into=Table,
    +1240            copy=copy,
    +1241            **opts,
    +1242        )
     
    @@ -14283,44 +14776,44 @@ If an Expression instance is passed, it w
    -
    1121    def where(
    -1122        self,
    -1123        *expressions: ExpOrStr,
    -1124        append: bool = True,
    -1125        dialect: DialectType = None,
    -1126        copy: bool = True,
    -1127        **opts,
    -1128    ) -> Delete:
    -1129        """
    -1130        Append to or set the WHERE expressions.
    -1131
    -1132        Example:
    -1133            >>> delete("tbl").where("x = 'a' OR x < 'b'").sql()
    -1134            "DELETE FROM tbl WHERE x = 'a' OR x < 'b'"
    -1135
    -1136        Args:
    -1137            *expressions: the SQL code strings to parse.
    -1138                If an `Expression` instance is passed, it will be used as-is.
    -1139                Multiple expressions are combined with an AND operator.
    -1140            append: if `True`, AND the new expressions to any existing expression.
    -1141                Otherwise, this resets the expression.
    -1142            dialect: the dialect used to parse the input expressions.
    -1143            copy: if `False`, modify this expression instance in-place.
    -1144            opts: other options to use to parse the input expressions.
    -1145
    -1146        Returns:
    -1147            Delete: the modified expression.
    -1148        """
    -1149        return _apply_conjunction_builder(
    -1150            *expressions,
    -1151            instance=self,
    -1152            arg="where",
    -1153            append=append,
    -1154            into=Where,
    -1155            dialect=dialect,
    -1156            copy=copy,
    -1157            **opts,
    -1158        )
    +            
    1244    def where(
    +1245        self,
    +1246        *expressions: ExpOrStr,
    +1247        append: bool = True,
    +1248        dialect: DialectType = None,
    +1249        copy: bool = True,
    +1250        **opts,
    +1251    ) -> Delete:
    +1252        """
    +1253        Append to or set the WHERE expressions.
    +1254
    +1255        Example:
    +1256            >>> delete("tbl").where("x = 'a' OR x < 'b'").sql()
    +1257            "DELETE FROM tbl WHERE x = 'a' OR x < 'b'"
    +1258
    +1259        Args:
    +1260            *expressions: the SQL code strings to parse.
    +1261                If an `Expression` instance is passed, it will be used as-is.
    +1262                Multiple expressions are combined with an AND operator.
    +1263            append: if `True`, AND the new expressions to any existing expression.
    +1264                Otherwise, this resets the expression.
    +1265            dialect: the dialect used to parse the input expressions.
    +1266            copy: if `False`, modify this expression instance in-place.
    +1267            opts: other options to use to parse the input expressions.
    +1268
    +1269        Returns:
    +1270            Delete: the modified expression.
    +1271        """
    +1272        return _apply_conjunction_builder(
    +1273            *expressions,
    +1274            instance=self,
    +1275            arg="where",
    +1276            append=append,
    +1277            into=Where,
    +1278            dialect=dialect,
    +1279            copy=copy,
    +1280            **opts,
    +1281        )
     
    @@ -14369,40 +14862,40 @@ Otherwise, this resets the expression.
    -
    1160    def returning(
    -1161        self,
    -1162        expression: ExpOrStr,
    -1163        dialect: DialectType = None,
    -1164        copy: bool = True,
    -1165        **opts,
    -1166    ) -> Delete:
    -1167        """
    -1168        Set the RETURNING expression. Not supported by all dialects.
    -1169
    -1170        Example:
    -1171            >>> delete("tbl").returning("*", dialect="postgres").sql()
    -1172            'DELETE FROM tbl RETURNING *'
    -1173
    -1174        Args:
    -1175            expression: the SQL code strings to parse.
    -1176                If an `Expression` instance is passed, it will be used as-is.
    -1177            dialect: the dialect used to parse the input expressions.
    -1178            copy: if `False`, modify this expression instance in-place.
    -1179            opts: other options to use to parse the input expressions.
    -1180
    -1181        Returns:
    -1182            Delete: the modified expression.
    -1183        """
    -1184        return _apply_builder(
    -1185            expression=expression,
    -1186            instance=self,
    -1187            arg="returning",
    -1188            prefix="RETURNING",
    -1189            dialect=dialect,
    -1190            copy=copy,
    -1191            into=Returning,
    -1192            **opts,
    -1193        )
    +            
    1283    def returning(
    +1284        self,
    +1285        expression: ExpOrStr,
    +1286        dialect: DialectType = None,
    +1287        copy: bool = True,
    +1288        **opts,
    +1289    ) -> Delete:
    +1290        """
    +1291        Set the RETURNING expression. Not supported by all dialects.
    +1292
    +1293        Example:
    +1294            >>> delete("tbl").returning("*", dialect="postgres").sql()
    +1295            'DELETE FROM tbl RETURNING *'
    +1296
    +1297        Args:
    +1298            expression: the SQL code strings to parse.
    +1299                If an `Expression` instance is passed, it will be used as-is.
    +1300            dialect: the dialect used to parse the input expressions.
    +1301            copy: if `False`, modify this expression instance in-place.
    +1302            opts: other options to use to parse the input expressions.
    +1303
    +1304        Returns:
    +1305            Delete: the modified expression.
    +1306        """
    +1307        return _apply_builder(
    +1308            expression=expression,
    +1309            instance=self,
    +1310            arg="returning",
    +1311            prefix="RETURNING",
    +1312            dialect=dialect,
    +1313            copy=copy,
    +1314            into=Returning,
    +1315            **opts,
    +1316        )
     
    @@ -14494,17 +14987,17 @@ If an Expression instance is passed, it w
    -
    1196class Drop(Expression):
    -1197    arg_types = {
    -1198        "this": False,
    -1199        "kind": False,
    -1200        "exists": False,
    -1201        "temporary": False,
    -1202        "materialized": False,
    -1203        "cascade": False,
    -1204        "constraints": False,
    -1205        "purge": False,
    -1206    }
    +            
    1319class Drop(Expression):
    +1320    arg_types = {
    +1321        "this": False,
    +1322        "kind": False,
    +1323        "exists": False,
    +1324        "temporary": False,
    +1325        "materialized": False,
    +1326        "cascade": False,
    +1327        "constraints": False,
    +1328        "purge": False,
    +1329    }
     
    @@ -14567,8 +15060,8 @@ If an Expression instance is passed, it w
    -
    1209class Filter(Expression):
    -1210    arg_types = {"this": True, "expression": True}
    +            
    1332class Filter(Expression):
    +1333    arg_types = {"this": True, "expression": True}
     
    @@ -14631,8 +15124,8 @@ If an Expression instance is passed, it w
    -
    1213class Check(Expression):
    -1214    pass
    +            
    1336class Check(Expression):
    +1337    pass
     
    @@ -14695,9 +15188,9 @@ If an Expression instance is passed, it w
    -
    1217class Directory(Expression):
    -1218    # https://spark.apache.org/docs/3.0.0-preview/sql-ref-syntax-dml-insert-overwrite-directory-hive.html
    -1219    arg_types = {"this": True, "local": False, "row_format": False}
    +            
    1340class Directory(Expression):
    +1341    # https://spark.apache.org/docs/3.0.0-preview/sql-ref-syntax-dml-insert-overwrite-directory-hive.html
    +1342    arg_types = {"this": True, "local": False, "row_format": False}
     
    @@ -14760,13 +15253,13 @@ If an Expression instance is passed, it w
    -
    1222class ForeignKey(Expression):
    -1223    arg_types = {
    -1224        "expressions": True,
    -1225        "reference": False,
    -1226        "delete": False,
    -1227        "update": False,
    -1228    }
    +            
    1345class ForeignKey(Expression):
    +1346    arg_types = {
    +1347        "expressions": True,
    +1348        "reference": False,
    +1349        "delete": False,
    +1350        "update": False,
    +1351    }
     
    @@ -14829,8 +15322,8 @@ If an Expression instance is passed, it w
    -
    1231class PrimaryKey(Expression):
    -1232    arg_types = {"expressions": True, "options": False}
    +            
    1354class PrimaryKey(Expression):
    +1355    arg_types = {"expressions": True, "options": False}
     
    @@ -14893,8 +15386,8 @@ If an Expression instance is passed, it w
    -
    1235class Unique(Expression):
    -1236    arg_types = {"expressions": True}
    +            
    1358class Unique(Expression):
    +1359    arg_types = {"expressions": True}
     
    @@ -14957,8 +15450,8 @@ If an Expression instance is passed, it w
    -
    1241class Into(Expression):
    -1242    arg_types = {"this": True, "temporary": False, "unlogged": False}
    +            
    1364class Into(Expression):
    +1365    arg_types = {"this": True, "temporary": False, "unlogged": False}
     
    @@ -15021,8 +15514,8 @@ If an Expression instance is passed, it w
    -
    1245class From(Expression):
    -1246    arg_types = {"expressions": True}
    +            
    1368class From(Expression):
    +1369    arg_types = {"expressions": True}
     
    @@ -15085,8 +15578,8 @@ If an Expression instance is passed, it w
    -
    1249class Having(Expression):
    -1250    pass
    +            
    1372class Having(Expression):
    +1373    pass
     
    @@ -15149,8 +15642,8 @@ If an Expression instance is passed, it w
    -
    1253class Hint(Expression):
    -1254    arg_types = {"expressions": True}
    +            
    1376class Hint(Expression):
    +1377    arg_types = {"expressions": True}
     
    @@ -15213,8 +15706,8 @@ If an Expression instance is passed, it w
    -
    1257class JoinHint(Expression):
    -1258    arg_types = {"this": True, "expressions": True}
    +            
    1380class JoinHint(Expression):
    +1381    arg_types = {"this": True, "expressions": True}
     
    @@ -15277,22 +15770,22 @@ If an Expression instance is passed, it w
    -
    1261class Identifier(Expression):
    -1262    arg_types = {"this": True, "quoted": False}
    -1263
    -1264    @property
    -1265    def quoted(self):
    -1266        return bool(self.args.get("quoted"))
    -1267
    -1268    @property
    -1269    def hashable_args(self) -> t.Any:
    -1270        if self.quoted and any(char.isupper() for char in self.this):
    -1271            return (self.this, self.quoted)
    -1272        return self.this.lower()
    -1273
    -1274    @property
    -1275    def output_name(self):
    -1276        return self.name
    +            
    1384class Identifier(Expression):
    +1385    arg_types = {"this": True, "quoted": False}
    +1386
    +1387    @property
    +1388    def quoted(self):
    +1389        return bool(self.args.get("quoted"))
    +1390
    +1391    @property
    +1392    def hashable_args(self) -> t.Any:
    +1393        if self.quoted and any(char.isupper() for char in self.this):
    +1394            return (self.this, self.quoted)
    +1395        return self.this.lower()
    +1396
    +1397    @property
    +1398    def output_name(self):
    +1399        return self.name
     
    @@ -15384,16 +15877,16 @@ If an Expression instance is passed, it w
    -
    1279class Index(Expression):
    -1280    arg_types = {
    -1281        "this": False,
    -1282        "table": False,
    -1283        "where": False,
    -1284        "columns": False,
    -1285        "unique": False,
    -1286        "primary": False,
    -1287        "amp": False,  # teradata
    -1288    }
    +            
    1402class Index(Expression):
    +1403    arg_types = {
    +1404        "this": False,
    +1405        "table": False,
    +1406        "where": False,
    +1407        "columns": False,
    +1408        "unique": False,
    +1409        "primary": False,
    +1410        "amp": False,  # teradata
    +1411    }
     
    @@ -15456,18 +15949,18 @@ If an Expression instance is passed, it w
    -
    1291class Insert(Expression):
    -1292    arg_types = {
    -1293        "with": False,
    -1294        "this": True,
    -1295        "expression": False,
    -1296        "conflict": False,
    -1297        "returning": False,
    -1298        "overwrite": False,
    -1299        "exists": False,
    -1300        "partition": False,
    -1301        "alternative": False,
    -1302    }
    +            
    1414class Insert(Expression):
    +1415    arg_types = {
    +1416        "with": False,
    +1417        "this": True,
    +1418        "expression": False,
    +1419        "conflict": False,
    +1420        "returning": False,
    +1421        "overwrite": False,
    +1422        "exists": False,
    +1423        "partition": False,
    +1424        "alternative": False,
    +1425    }
     
    @@ -15530,14 +16023,14 @@ If an Expression instance is passed, it w
    -
    1305class OnConflict(Expression):
    -1306    arg_types = {
    -1307        "duplicate": False,
    -1308        "expressions": False,
    -1309        "nothing": False,
    -1310        "key": False,
    -1311        "constraint": False,
    -1312    }
    +            
    1428class OnConflict(Expression):
    +1429    arg_types = {
    +1430        "duplicate": False,
    +1431        "expressions": False,
    +1432        "nothing": False,
    +1433        "key": False,
    +1434        "constraint": False,
    +1435    }
     
    @@ -15600,8 +16093,8 @@ If an Expression instance is passed, it w
    -
    1315class Returning(Expression):
    -1316    arg_types = {"expressions": True}
    +            
    1438class Returning(Expression):
    +1439    arg_types = {"expressions": True}
     
    @@ -15664,8 +16157,8 @@ If an Expression instance is passed, it w
    -
    1320class Introducer(Expression):
    -1321    arg_types = {"this": True, "expression": True}
    +            
    1443class Introducer(Expression):
    +1444    arg_types = {"this": True, "expression": True}
     
    @@ -15728,8 +16221,8 @@ If an Expression instance is passed, it w
    -
    1325class National(Expression):
    -1326    pass
    +            
    1448class National(Expression):
    +1449    pass
     
    @@ -15792,16 +16285,16 @@ If an Expression instance is passed, it w
    -
    1329class LoadData(Expression):
    -1330    arg_types = {
    -1331        "this": True,
    -1332        "local": False,
    -1333        "overwrite": False,
    -1334        "inpath": True,
    -1335        "partition": False,
    -1336        "input_format": False,
    -1337        "serde": False,
    -1338    }
    +            
    1452class LoadData(Expression):
    +1453    arg_types = {
    +1454        "this": True,
    +1455        "local": False,
    +1456        "overwrite": False,
    +1457        "inpath": True,
    +1458        "partition": False,
    +1459        "input_format": False,
    +1460        "serde": False,
    +1461    }
     
    @@ -15864,8 +16357,8 @@ If an Expression instance is passed, it w
    -
    1341class Partition(Expression):
    -1342    arg_types = {"expressions": True}
    +            
    1464class Partition(Expression):
    +1465    arg_types = {"expressions": True}
     
    @@ -15928,13 +16421,13 @@ If an Expression instance is passed, it w
    -
    1345class Fetch(Expression):
    -1346    arg_types = {
    -1347        "direction": False,
    -1348        "count": False,
    -1349        "percent": False,
    -1350        "with_ties": False,
    -1351    }
    +            
    1468class Fetch(Expression):
    +1469    arg_types = {
    +1470        "direction": False,
    +1471        "count": False,
    +1472        "percent": False,
    +1473        "with_ties": False,
    +1474    }
     
    @@ -15997,13 +16490,13 @@ If an Expression instance is passed, it w
    -
    1354class Group(Expression):
    -1355    arg_types = {
    -1356        "expressions": False,
    -1357        "grouping_sets": False,
    -1358        "cube": False,
    -1359        "rollup": False,
    -1360    }
    +            
    1477class Group(Expression):
    +1478    arg_types = {
    +1479        "expressions": False,
    +1480        "grouping_sets": False,
    +1481        "cube": False,
    +1482        "rollup": False,
    +1483    }
     
    @@ -16066,8 +16559,8 @@ If an Expression instance is passed, it w
    -
    1363class Lambda(Expression):
    -1364    arg_types = {"this": True, "expressions": True}
    +            
    1486class Lambda(Expression):
    +1487    arg_types = {"this": True, "expressions": True}
     
    @@ -16130,8 +16623,8 @@ If an Expression instance is passed, it w
    -
    1367class Limit(Expression):
    -1368    arg_types = {"this": False, "expression": True}
    +            
    1490class Limit(Expression):
    +1491    arg_types = {"this": False, "expression": True}
     
    @@ -16194,24 +16687,24 @@ If an Expression instance is passed, it w
    -
    1371class Literal(Condition):
    -1372    arg_types = {"this": True, "is_string": True}
    -1373
    -1374    @property
    -1375    def hashable_args(self) -> t.Any:
    -1376        return (self.this, self.args.get("is_string"))
    -1377
    -1378    @classmethod
    -1379    def number(cls, number) -> Literal:
    -1380        return cls(this=str(number), is_string=False)
    -1381
    -1382    @classmethod
    -1383    def string(cls, string) -> Literal:
    -1384        return cls(this=str(string), is_string=True)
    -1385
    -1386    @property
    -1387    def output_name(self):
    -1388        return self.name
    +            
    1494class Literal(Condition):
    +1495    arg_types = {"this": True, "is_string": True}
    +1496
    +1497    @property
    +1498    def hashable_args(self) -> t.Any:
    +1499        return (self.this, self.args.get("is_string"))
    +1500
    +1501    @classmethod
    +1502    def number(cls, number) -> Literal:
    +1503        return cls(this=str(number), is_string=False)
    +1504
    +1505    @classmethod
    +1506    def string(cls, string) -> Literal:
    +1507        return cls(this=str(string), is_string=True)
    +1508
    +1509    @property
    +1510    def output_name(self):
    +1511        return self.name
     
    @@ -16229,9 +16722,9 @@ If an Expression instance is passed, it w
    -
    1378    @classmethod
    -1379    def number(cls, number) -> Literal:
    -1380        return cls(this=str(number), is_string=False)
    +            
    1501    @classmethod
    +1502    def number(cls, number) -> Literal:
    +1503        return cls(this=str(number), is_string=False)
     
    @@ -16250,9 +16743,9 @@ If an Expression instance is passed, it w
    -
    1382    @classmethod
    -1383    def string(cls, string) -> Literal:
    -1384        return cls(this=str(string), is_string=True)
    +            
    1505    @classmethod
    +1506    def string(cls, string) -> Literal:
    +1507        return cls(this=str(string), is_string=True)
     
    @@ -16335,6 +16828,13 @@ If an Expression instance is passed, it w
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -16351,105 +16851,105 @@ If an Expression instance is passed, it w -
    1391class Join(Expression):
    -1392    arg_types = {
    -1393        "this": True,
    -1394        "on": False,
    -1395        "side": False,
    -1396        "kind": False,
    -1397        "using": False,
    -1398        "natural": False,
    -1399        "hint": False,
    -1400    }
    -1401
    -1402    @property
    -1403    def kind(self):
    -1404        return self.text("kind").upper()
    -1405
    -1406    @property
    -1407    def side(self):
    -1408        return self.text("side").upper()
    -1409
    -1410    @property
    -1411    def hint(self):
    -1412        return self.text("hint").upper()
    -1413
    -1414    @property
    -1415    def alias_or_name(self):
    -1416        return self.this.alias_or_name
    -1417
    -1418    def on(self, *expressions, append=True, dialect=None, copy=True, **opts):
    -1419        """
    -1420        Append to or set the ON expressions.
    -1421
    -1422        Example:
    -1423            >>> import sqlglot
    -1424            >>> sqlglot.parse_one("JOIN x", into=Join).on("y = 1").sql()
    -1425            'JOIN x ON y = 1'
    -1426
    -1427        Args:
    -1428            *expressions (str | Expression): the SQL code strings to parse.
    -1429                If an `Expression` instance is passed, it will be used as-is.
    -1430                Multiple expressions are combined with an AND operator.
    -1431            append (bool): if `True`, AND the new expressions to any existing expression.
    -1432                Otherwise, this resets the expression.
    -1433            dialect (str): the dialect used to parse the input expressions.
    -1434            copy (bool): if `False`, modify this expression instance in-place.
    -1435            opts (kwargs): other options to use to parse the input expressions.
    -1436
    -1437        Returns:
    -1438            Join: the modified join expression.
    -1439        """
    -1440        join = _apply_conjunction_builder(
    -1441            *expressions,
    -1442            instance=self,
    -1443            arg="on",
    -1444            append=append,
    -1445            dialect=dialect,
    -1446            copy=copy,
    -1447            **opts,
    -1448        )
    -1449
    -1450        if join.kind == "CROSS":
    -1451            join.set("kind", None)
    -1452
    -1453        return join
    -1454
    -1455    def using(self, *expressions, append=True, dialect=None, copy=True, **opts):
    -1456        """
    -1457        Append to or set the USING expressions.
    -1458
    -1459        Example:
    -1460            >>> import sqlglot
    -1461            >>> sqlglot.parse_one("JOIN x", into=Join).using("foo", "bla").sql()
    -1462            'JOIN x USING (foo, bla)'
    -1463
    -1464        Args:
    -1465            *expressions (str | Expression): the SQL code strings to parse.
    -1466                If an `Expression` instance is passed, it will be used as-is.
    -1467            append (bool): if `True`, concatenate the new expressions to the existing "using" list.
    -1468                Otherwise, this resets the expression.
    -1469            dialect (str): the dialect used to parse the input expressions.
    -1470            copy (bool): if `False`, modify this expression instance in-place.
    -1471            opts (kwargs): other options to use to parse the input expressions.
    -1472
    -1473        Returns:
    -1474            Join: the modified join expression.
    -1475        """
    -1476        join = _apply_list_builder(
    -1477            *expressions,
    -1478            instance=self,
    -1479            arg="using",
    -1480            append=append,
    -1481            dialect=dialect,
    -1482            copy=copy,
    -1483            **opts,
    -1484        )
    -1485
    -1486        if join.kind == "CROSS":
    -1487            join.set("kind", None)
    -1488
    -1489        return join
    +            
    1514class Join(Expression):
    +1515    arg_types = {
    +1516        "this": True,
    +1517        "on": False,
    +1518        "side": False,
    +1519        "kind": False,
    +1520        "using": False,
    +1521        "natural": False,
    +1522        "hint": False,
    +1523    }
    +1524
    +1525    @property
    +1526    def kind(self):
    +1527        return self.text("kind").upper()
    +1528
    +1529    @property
    +1530    def side(self):
    +1531        return self.text("side").upper()
    +1532
    +1533    @property
    +1534    def hint(self):
    +1535        return self.text("hint").upper()
    +1536
    +1537    @property
    +1538    def alias_or_name(self):
    +1539        return self.this.alias_or_name
    +1540
    +1541    def on(self, *expressions, append=True, dialect=None, copy=True, **opts):
    +1542        """
    +1543        Append to or set the ON expressions.
    +1544
    +1545        Example:
    +1546            >>> import sqlglot
    +1547            >>> sqlglot.parse_one("JOIN x", into=Join).on("y = 1").sql()
    +1548            'JOIN x ON y = 1'
    +1549
    +1550        Args:
    +1551            *expressions (str | Expression): the SQL code strings to parse.
    +1552                If an `Expression` instance is passed, it will be used as-is.
    +1553                Multiple expressions are combined with an AND operator.
    +1554            append (bool): if `True`, AND the new expressions to any existing expression.
    +1555                Otherwise, this resets the expression.
    +1556            dialect (str): the dialect used to parse the input expressions.
    +1557            copy (bool): if `False`, modify this expression instance in-place.
    +1558            opts (kwargs): other options to use to parse the input expressions.
    +1559
    +1560        Returns:
    +1561            Join: the modified join expression.
    +1562        """
    +1563        join = _apply_conjunction_builder(
    +1564            *expressions,
    +1565            instance=self,
    +1566            arg="on",
    +1567            append=append,
    +1568            dialect=dialect,
    +1569            copy=copy,
    +1570            **opts,
    +1571        )
    +1572
    +1573        if join.kind == "CROSS":
    +1574            join.set("kind", None)
    +1575
    +1576        return join
    +1577
    +1578    def using(self, *expressions, append=True, dialect=None, copy=True, **opts):
    +1579        """
    +1580        Append to or set the USING expressions.
    +1581
    +1582        Example:
    +1583            >>> import sqlglot
    +1584            >>> sqlglot.parse_one("JOIN x", into=Join).using("foo", "bla").sql()
    +1585            'JOIN x USING (foo, bla)'
    +1586
    +1587        Args:
    +1588            *expressions (str | Expression): the SQL code strings to parse.
    +1589                If an `Expression` instance is passed, it will be used as-is.
    +1590            append (bool): if `True`, concatenate the new expressions to the existing "using" list.
    +1591                Otherwise, this resets the expression.
    +1592            dialect (str): the dialect used to parse the input expressions.
    +1593            copy (bool): if `False`, modify this expression instance in-place.
    +1594            opts (kwargs): other options to use to parse the input expressions.
    +1595
    +1596        Returns:
    +1597            Join: the modified join expression.
    +1598        """
    +1599        join = _apply_list_builder(
    +1600            *expressions,
    +1601            instance=self,
    +1602            arg="using",
    +1603            append=append,
    +1604            dialect=dialect,
    +1605            copy=copy,
    +1606            **opts,
    +1607        )
    +1608
    +1609        if join.kind == "CROSS":
    +1610            join.set("kind", None)
    +1611
    +1612        return join
     
    @@ -16466,42 +16966,42 @@ If an Expression instance is passed, it w
    -
    1418    def on(self, *expressions, append=True, dialect=None, copy=True, **opts):
    -1419        """
    -1420        Append to or set the ON expressions.
    -1421
    -1422        Example:
    -1423            >>> import sqlglot
    -1424            >>> sqlglot.parse_one("JOIN x", into=Join).on("y = 1").sql()
    -1425            'JOIN x ON y = 1'
    -1426
    -1427        Args:
    -1428            *expressions (str | Expression): the SQL code strings to parse.
    -1429                If an `Expression` instance is passed, it will be used as-is.
    -1430                Multiple expressions are combined with an AND operator.
    -1431            append (bool): if `True`, AND the new expressions to any existing expression.
    -1432                Otherwise, this resets the expression.
    -1433            dialect (str): the dialect used to parse the input expressions.
    -1434            copy (bool): if `False`, modify this expression instance in-place.
    -1435            opts (kwargs): other options to use to parse the input expressions.
    -1436
    -1437        Returns:
    -1438            Join: the modified join expression.
    -1439        """
    -1440        join = _apply_conjunction_builder(
    -1441            *expressions,
    -1442            instance=self,
    -1443            arg="on",
    -1444            append=append,
    -1445            dialect=dialect,
    -1446            copy=copy,
    -1447            **opts,
    -1448        )
    -1449
    -1450        if join.kind == "CROSS":
    -1451            join.set("kind", None)
    -1452
    -1453        return join
    +            
    1541    def on(self, *expressions, append=True, dialect=None, copy=True, **opts):
    +1542        """
    +1543        Append to or set the ON expressions.
    +1544
    +1545        Example:
    +1546            >>> import sqlglot
    +1547            >>> sqlglot.parse_one("JOIN x", into=Join).on("y = 1").sql()
    +1548            'JOIN x ON y = 1'
    +1549
    +1550        Args:
    +1551            *expressions (str | Expression): the SQL code strings to parse.
    +1552                If an `Expression` instance is passed, it will be used as-is.
    +1553                Multiple expressions are combined with an AND operator.
    +1554            append (bool): if `True`, AND the new expressions to any existing expression.
    +1555                Otherwise, this resets the expression.
    +1556            dialect (str): the dialect used to parse the input expressions.
    +1557            copy (bool): if `False`, modify this expression instance in-place.
    +1558            opts (kwargs): other options to use to parse the input expressions.
    +1559
    +1560        Returns:
    +1561            Join: the modified join expression.
    +1562        """
    +1563        join = _apply_conjunction_builder(
    +1564            *expressions,
    +1565            instance=self,
    +1566            arg="on",
    +1567            append=append,
    +1568            dialect=dialect,
    +1569            copy=copy,
    +1570            **opts,
    +1571        )
    +1572
    +1573        if join.kind == "CROSS":
    +1574            join.set("kind", None)
    +1575
    +1576        return join
     
    @@ -16551,41 +17051,41 @@ Otherwise, this resets the expression.
    -
    1455    def using(self, *expressions, append=True, dialect=None, copy=True, **opts):
    -1456        """
    -1457        Append to or set the USING expressions.
    -1458
    -1459        Example:
    -1460            >>> import sqlglot
    -1461            >>> sqlglot.parse_one("JOIN x", into=Join).using("foo", "bla").sql()
    -1462            'JOIN x USING (foo, bla)'
    -1463
    -1464        Args:
    -1465            *expressions (str | Expression): the SQL code strings to parse.
    -1466                If an `Expression` instance is passed, it will be used as-is.
    -1467            append (bool): if `True`, concatenate the new expressions to the existing "using" list.
    -1468                Otherwise, this resets the expression.
    -1469            dialect (str): the dialect used to parse the input expressions.
    -1470            copy (bool): if `False`, modify this expression instance in-place.
    -1471            opts (kwargs): other options to use to parse the input expressions.
    -1472
    -1473        Returns:
    -1474            Join: the modified join expression.
    -1475        """
    -1476        join = _apply_list_builder(
    -1477            *expressions,
    -1478            instance=self,
    -1479            arg="using",
    -1480            append=append,
    -1481            dialect=dialect,
    -1482            copy=copy,
    -1483            **opts,
    -1484        )
    -1485
    -1486        if join.kind == "CROSS":
    -1487            join.set("kind", None)
    -1488
    -1489        return join
    +            
    1578    def using(self, *expressions, append=True, dialect=None, copy=True, **opts):
    +1579        """
    +1580        Append to or set the USING expressions.
    +1581
    +1582        Example:
    +1583            >>> import sqlglot
    +1584            >>> sqlglot.parse_one("JOIN x", into=Join).using("foo", "bla").sql()
    +1585            'JOIN x USING (foo, bla)'
    +1586
    +1587        Args:
    +1588            *expressions (str | Expression): the SQL code strings to parse.
    +1589                If an `Expression` instance is passed, it will be used as-is.
    +1590            append (bool): if `True`, concatenate the new expressions to the existing "using" list.
    +1591                Otherwise, this resets the expression.
    +1592            dialect (str): the dialect used to parse the input expressions.
    +1593            copy (bool): if `False`, modify this expression instance in-place.
    +1594            opts (kwargs): other options to use to parse the input expressions.
    +1595
    +1596        Returns:
    +1597            Join: the modified join expression.
    +1598        """
    +1599        join = _apply_list_builder(
    +1600            *expressions,
    +1601            instance=self,
    +1602            arg="using",
    +1603            append=append,
    +1604            dialect=dialect,
    +1605            copy=copy,
    +1606            **opts,
    +1607        )
    +1608
    +1609        if join.kind == "CROSS":
    +1610            join.set("kind", None)
    +1611
    +1612        return join
     
    @@ -16680,8 +17180,8 @@ Otherwise, this resets the expression.
    -
    1492class Lateral(UDTF):
    -1493    arg_types = {"this": True, "view": False, "outer": False, "alias": False}
    +            
    1615class Lateral(UDTF):
    +1616    arg_types = {"this": True, "view": False, "outer": False, "alias": False}
     
    @@ -16750,17 +17250,17 @@ Otherwise, this resets the expression.
    -
    1496class MatchRecognize(Expression):
    -1497    arg_types = {
    -1498        "partition_by": False,
    -1499        "order": False,
    -1500        "measures": False,
    -1501        "rows": False,
    -1502        "after": False,
    -1503        "pattern": False,
    -1504        "define": False,
    -1505        "alias": False,
    -1506    }
    +            
    1619class MatchRecognize(Expression):
    +1620    arg_types = {
    +1621        "partition_by": False,
    +1622        "order": False,
    +1623        "measures": False,
    +1624        "rows": False,
    +1625        "after": False,
    +1626        "pattern": False,
    +1627        "define": False,
    +1628        "alias": False,
    +1629    }
     
    @@ -16823,8 +17323,8 @@ Otherwise, this resets the expression.
    -
    1511class Final(Expression):
    -1512    pass
    +            
    1634class Final(Expression):
    +1635    pass
     
    @@ -16887,8 +17387,8 @@ Otherwise, this resets the expression.
    -
    1515class Offset(Expression):
    -1516    arg_types = {"this": False, "expression": True}
    +            
    1638class Offset(Expression):
    +1639    arg_types = {"this": False, "expression": True}
     
    @@ -16951,8 +17451,8 @@ Otherwise, this resets the expression.
    -
    1519class Order(Expression):
    -1520    arg_types = {"this": False, "expressions": True}
    +            
    1642class Order(Expression):
    +1643    arg_types = {"this": False, "expressions": True}
     
    @@ -17015,8 +17515,8 @@ Otherwise, this resets the expression.
    -
    1525class Cluster(Order):
    -1526    pass
    +            
    1648class Cluster(Order):
    +1649    pass
     
    @@ -17079,8 +17579,8 @@ Otherwise, this resets the expression.
    -
    1529class Distribute(Order):
    -1530    pass
    +            
    1652class Distribute(Order):
    +1653    pass
     
    @@ -17143,8 +17643,8 @@ Otherwise, this resets the expression.
    -
    1533class Sort(Order):
    -1534    pass
    +            
    1656class Sort(Order):
    +1657    pass
     
    @@ -17207,8 +17707,8 @@ Otherwise, this resets the expression.
    -
    1537class Ordered(Expression):
    -1538    arg_types = {"this": True, "desc": True, "nulls_first": True}
    +            
    1660class Ordered(Expression):
    +1661    arg_types = {"this": True, "desc": True, "nulls_first": True}
     
    @@ -17271,8 +17771,8 @@ Otherwise, this resets the expression.
    -
    1541class Property(Expression):
    -1542    arg_types = {"this": True, "value": True}
    +            
    1664class Property(Expression):
    +1665    arg_types = {"this": True, "value": True}
     
    @@ -17335,8 +17835,8 @@ Otherwise, this resets the expression.
    -
    1545class AfterJournalProperty(Property):
    -1546    arg_types = {"no": True, "dual": False, "local": False}
    +            
    1668class AfterJournalProperty(Property):
    +1669    arg_types = {"no": True, "dual": False, "local": False}
     
    @@ -17399,8 +17899,8 @@ Otherwise, this resets the expression.
    -
    1549class AlgorithmProperty(Property):
    -1550    arg_types = {"this": True}
    +            
    1672class AlgorithmProperty(Property):
    +1673    arg_types = {"this": True}
     
    @@ -17463,8 +17963,8 @@ Otherwise, this resets the expression.
    -
    1553class AutoIncrementProperty(Property):
    -1554    arg_types = {"this": True}
    +            
    1676class AutoIncrementProperty(Property):
    +1677    arg_types = {"this": True}
     
    @@ -17527,8 +18027,8 @@ Otherwise, this resets the expression.
    -
    1557class BlockCompressionProperty(Property):
    -1558    arg_types = {"autotemp": False, "always": False, "default": True, "manual": True, "never": True}
    +            
    1680class BlockCompressionProperty(Property):
    +1681    arg_types = {"autotemp": False, "always": False, "default": True, "manual": True, "never": True}
     
    @@ -17591,8 +18091,8 @@ Otherwise, this resets the expression.
    -
    1561class CharacterSetProperty(Property):
    -1562    arg_types = {"this": True, "default": True}
    +            
    1684class CharacterSetProperty(Property):
    +1685    arg_types = {"this": True, "default": True}
     
    @@ -17655,8 +18155,8 @@ Otherwise, this resets the expression.
    -
    1565class ChecksumProperty(Property):
    -1566    arg_types = {"on": False, "default": False}
    +            
    1688class ChecksumProperty(Property):
    +1689    arg_types = {"on": False, "default": False}
     
    @@ -17719,8 +18219,8 @@ Otherwise, this resets the expression.
    -
    1569class CollateProperty(Property):
    -1570    arg_types = {"this": True}
    +            
    1692class CollateProperty(Property):
    +1693    arg_types = {"this": True}
     
    @@ -17783,8 +18283,8 @@ Otherwise, this resets the expression.
    -
    1573class DataBlocksizeProperty(Property):
    -1574    arg_types = {"size": False, "units": False, "min": False, "default": False}
    +            
    1696class DataBlocksizeProperty(Property):
    +1697    arg_types = {"size": False, "units": False, "min": False, "default": False}
     
    @@ -17847,8 +18347,8 @@ Otherwise, this resets the expression.
    -
    1577class DefinerProperty(Property):
    -1578    arg_types = {"this": True}
    +            
    1700class DefinerProperty(Property):
    +1701    arg_types = {"this": True}
     
    @@ -17911,8 +18411,8 @@ Otherwise, this resets the expression.
    -
    1581class DistKeyProperty(Property):
    -1582    arg_types = {"this": True}
    +            
    1704class DistKeyProperty(Property):
    +1705    arg_types = {"this": True}
     
    @@ -17975,8 +18475,8 @@ Otherwise, this resets the expression.
    -
    1585class DistStyleProperty(Property):
    -1586    arg_types = {"this": True}
    +            
    1708class DistStyleProperty(Property):
    +1709    arg_types = {"this": True}
     
    @@ -18039,8 +18539,8 @@ Otherwise, this resets the expression.
    -
    1589class EngineProperty(Property):
    -1590    arg_types = {"this": True}
    +            
    1712class EngineProperty(Property):
    +1713    arg_types = {"this": True}
     
    @@ -18103,8 +18603,8 @@ Otherwise, this resets the expression.
    -
    1593class ExecuteAsProperty(Property):
    -1594    arg_types = {"this": True}
    +            
    1716class ExecuteAsProperty(Property):
    +1717    arg_types = {"this": True}
     
    @@ -18167,8 +18667,8 @@ Otherwise, this resets the expression.
    -
    1597class ExternalProperty(Property):
    -1598    arg_types = {"this": False}
    +            
    1720class ExternalProperty(Property):
    +1721    arg_types = {"this": False}
     
    @@ -18231,8 +18731,8 @@ Otherwise, this resets the expression.
    -
    1601class FallbackProperty(Property):
    -1602    arg_types = {"no": True, "protection": False}
    +            
    1724class FallbackProperty(Property):
    +1725    arg_types = {"no": True, "protection": False}
     
    @@ -18295,8 +18795,8 @@ Otherwise, this resets the expression.
    -
    1605class FileFormatProperty(Property):
    -1606    arg_types = {"this": True}
    +            
    1728class FileFormatProperty(Property):
    +1729    arg_types = {"this": True}
     
    @@ -18359,8 +18859,8 @@ Otherwise, this resets the expression.
    -
    1609class FreespaceProperty(Property):
    -1610    arg_types = {"this": True, "percent": False}
    +            
    1732class FreespaceProperty(Property):
    +1733    arg_types = {"this": True, "percent": False}
     
    @@ -18423,8 +18923,8 @@ Otherwise, this resets the expression.
    -
    1613class InputOutputFormat(Expression):
    -1614    arg_types = {"input_format": False, "output_format": False}
    +            
    1736class InputOutputFormat(Expression):
    +1737    arg_types = {"input_format": False, "output_format": False}
     
    @@ -18487,14 +18987,14 @@ Otherwise, this resets the expression.
    -
    1617class IsolatedLoadingProperty(Property):
    -1618    arg_types = {
    -1619        "no": True,
    -1620        "concurrent": True,
    -1621        "for_all": True,
    -1622        "for_insert": True,
    -1623        "for_none": True,
    -1624    }
    +            
    1740class IsolatedLoadingProperty(Property):
    +1741    arg_types = {
    +1742        "no": True,
    +1743        "concurrent": True,
    +1744        "for_all": True,
    +1745        "for_insert": True,
    +1746        "for_none": True,
    +1747    }
     
    @@ -18557,8 +19057,8 @@ Otherwise, this resets the expression.
    -
    1627class JournalProperty(Property):
    -1628    arg_types = {"no": True, "dual": False, "before": False}
    +            
    1750class JournalProperty(Property):
    +1751    arg_types = {"no": True, "dual": False, "before": False}
     
    @@ -18621,8 +19121,8 @@ Otherwise, this resets the expression.
    -
    1631class LanguageProperty(Property):
    -1632    arg_types = {"this": True}
    +            
    1754class LanguageProperty(Property):
    +1755    arg_types = {"this": True}
     
    @@ -18685,8 +19185,8 @@ Otherwise, this resets the expression.
    -
    1635class LikeProperty(Property):
    -1636    arg_types = {"this": True, "expressions": False}
    +            
    1758class LikeProperty(Property):
    +1759    arg_types = {"this": True, "expressions": False}
     
    @@ -18749,8 +19249,8 @@ Otherwise, this resets the expression.
    -
    1639class LocationProperty(Property):
    -1640    arg_types = {"this": True}
    +            
    1762class LocationProperty(Property):
    +1763    arg_types = {"this": True}
     
    @@ -18813,14 +19313,14 @@ Otherwise, this resets the expression.
    -
    1643class LockingProperty(Property):
    -1644    arg_types = {
    -1645        "this": False,
    -1646        "kind": True,
    -1647        "for_or_in": True,
    -1648        "lock_type": True,
    -1649        "override": False,
    -1650    }
    +            
    1766class LockingProperty(Property):
    +1767    arg_types = {
    +1768        "this": False,
    +1769        "kind": True,
    +1770        "for_or_in": True,
    +1771        "lock_type": True,
    +1772        "override": False,
    +1773    }
     
    @@ -18883,8 +19383,8 @@ Otherwise, this resets the expression.
    -
    1653class LogProperty(Property):
    -1654    arg_types = {"no": True}
    +            
    1776class LogProperty(Property):
    +1777    arg_types = {"no": True}
     
    @@ -18947,8 +19447,8 @@ Otherwise, this resets the expression.
    -
    1657class MaterializedProperty(Property):
    -1658    arg_types = {"this": False}
    +            
    1780class MaterializedProperty(Property):
    +1781    arg_types = {"this": False}
     
    @@ -19011,8 +19511,8 @@ Otherwise, this resets the expression.
    -
    1661class MergeBlockRatioProperty(Property):
    -1662    arg_types = {"this": False, "no": False, "default": False, "percent": False}
    +            
    1784class MergeBlockRatioProperty(Property):
    +1785    arg_types = {"this": False, "no": False, "default": False, "percent": False}
     
    @@ -19075,8 +19575,8 @@ Otherwise, this resets the expression.
    -
    1665class NoPrimaryIndexProperty(Property):
    -1666    arg_types = {"this": False}
    +            
    1788class NoPrimaryIndexProperty(Property):
    +1789    arg_types = {"this": False}
     
    @@ -19139,8 +19639,8 @@ Otherwise, this resets the expression.
    -
    1669class OnCommitProperty(Property):
    -1670    arg_type = {"this": False}
    +            
    1792class OnCommitProperty(Property):
    +1793    arg_type = {"this": False}
     
    @@ -19203,8 +19703,8 @@ Otherwise, this resets the expression.
    -
    1673class PartitionedByProperty(Property):
    -1674    arg_types = {"this": True}
    +            
    1796class PartitionedByProperty(Property):
    +1797    arg_types = {"this": True}
     
    @@ -19267,8 +19767,8 @@ Otherwise, this resets the expression.
    -
    1677class ReturnsProperty(Property):
    -1678    arg_types = {"this": True, "is_table": False, "table": False}
    +            
    1800class ReturnsProperty(Property):
    +1801    arg_types = {"this": True, "is_table": False, "table": False}
     
    @@ -19331,8 +19831,8 @@ Otherwise, this resets the expression.
    -
    1681class RowFormatProperty(Property):
    -1682    arg_types = {"this": True}
    +            
    1804class RowFormatProperty(Property):
    +1805    arg_types = {"this": True}
     
    @@ -19395,17 +19895,17 @@ Otherwise, this resets the expression.
    -
    1685class RowFormatDelimitedProperty(Property):
    -1686    # https://cwiki.apache.org/confluence/display/hive/languagemanual+dml
    -1687    arg_types = {
    -1688        "fields": False,
    -1689        "escaped": False,
    -1690        "collection_items": False,
    -1691        "map_keys": False,
    -1692        "lines": False,
    -1693        "null": False,
    -1694        "serde": False,
    -1695    }
    +            
    1808class RowFormatDelimitedProperty(Property):
    +1809    # https://cwiki.apache.org/confluence/display/hive/languagemanual+dml
    +1810    arg_types = {
    +1811        "fields": False,
    +1812        "escaped": False,
    +1813        "collection_items": False,
    +1814        "map_keys": False,
    +1815        "lines": False,
    +1816        "null": False,
    +1817        "serde": False,
    +1818    }
     
    @@ -19468,8 +19968,8 @@ Otherwise, this resets the expression.
    -
    1698class RowFormatSerdeProperty(Property):
    -1699    arg_types = {"this": True}
    +            
    1821class RowFormatSerdeProperty(Property):
    +1822    arg_types = {"this": True}
     
    @@ -19532,8 +20032,8 @@ Otherwise, this resets the expression.
    -
    1702class SchemaCommentProperty(Property):
    -1703    arg_types = {"this": True}
    +            
    1825class SchemaCommentProperty(Property):
    +1826    arg_types = {"this": True}
     
    @@ -19596,8 +20096,8 @@ Otherwise, this resets the expression.
    -
    1706class SerdeProperties(Property):
    -1707    arg_types = {"expressions": True}
    +            
    1829class SerdeProperties(Property):
    +1830    arg_types = {"expressions": True}
     
    @@ -19660,8 +20160,8 @@ Otherwise, this resets the expression.
    -
    1710class SetProperty(Property):
    -1711    arg_types = {"multi": True}
    +            
    1833class SetProperty(Property):
    +1834    arg_types = {"multi": True}
     
    @@ -19724,8 +20224,8 @@ Otherwise, this resets the expression.
    -
    1714class SortKeyProperty(Property):
    -1715    arg_types = {"this": True, "compound": False}
    +            
    1837class SortKeyProperty(Property):
    +1838    arg_types = {"this": True, "compound": False}
     
    @@ -19788,8 +20288,8 @@ Otherwise, this resets the expression.
    -
    1718class SqlSecurityProperty(Property):
    -1719    arg_types = {"definer": True}
    +            
    1841class SqlSecurityProperty(Property):
    +1842    arg_types = {"definer": True}
     
    @@ -19852,8 +20352,8 @@ Otherwise, this resets the expression.
    -
    1722class StabilityProperty(Property):
    -1723    arg_types = {"this": True}
    +            
    1845class StabilityProperty(Property):
    +1846    arg_types = {"this": True}
     
    @@ -19916,8 +20416,8 @@ Otherwise, this resets the expression.
    -
    1726class TableFormatProperty(Property):
    -1727    arg_types = {"this": True}
    +            
    1849class TableFormatProperty(Property):
    +1850    arg_types = {"this": True}
     
    @@ -19980,8 +20480,8 @@ Otherwise, this resets the expression.
    -
    1730class TemporaryProperty(Property):
    -1731    arg_types = {"global_": True}
    +            
    1853class TemporaryProperty(Property):
    +1854    arg_types = {"global_": True}
     
    @@ -20044,8 +20544,8 @@ Otherwise, this resets the expression.
    -
    1734class TransientProperty(Property):
    -1735    arg_types = {"this": False}
    +            
    1857class TransientProperty(Property):
    +1858    arg_types = {"this": False}
     
    @@ -20108,8 +20608,8 @@ Otherwise, this resets the expression.
    -
    1738class VolatileProperty(Property):
    -1739    arg_types = {"this": False}
    +            
    1861class VolatileProperty(Property):
    +1862    arg_types = {"this": False}
     
    @@ -20172,8 +20672,8 @@ Otherwise, this resets the expression.
    -
    1742class WithDataProperty(Property):
    -1743    arg_types = {"no": True, "statistics": False}
    +            
    1865class WithDataProperty(Property):
    +1866    arg_types = {"no": True, "statistics": False}
     
    @@ -20236,8 +20736,8 @@ Otherwise, this resets the expression.
    -
    1746class WithJournalTableProperty(Property):
    -1747    arg_types = {"this": True}
    +            
    1869class WithJournalTableProperty(Property):
    +1870    arg_types = {"this": True}
     
    @@ -20300,66 +20800,66 @@ Otherwise, this resets the expression.
    -
    1750class Properties(Expression):
    -1751    arg_types = {"expressions": True}
    -1752
    -1753    NAME_TO_PROPERTY = {
    -1754        "ALGORITHM": AlgorithmProperty,
    -1755        "AUTO_INCREMENT": AutoIncrementProperty,
    -1756        "CHARACTER SET": CharacterSetProperty,
    -1757        "COLLATE": CollateProperty,
    -1758        "COMMENT": SchemaCommentProperty,
    -1759        "DEFINER": DefinerProperty,
    -1760        "DISTKEY": DistKeyProperty,
    -1761        "DISTSTYLE": DistStyleProperty,
    -1762        "ENGINE": EngineProperty,
    -1763        "EXECUTE AS": ExecuteAsProperty,
    -1764        "FORMAT": FileFormatProperty,
    -1765        "LANGUAGE": LanguageProperty,
    -1766        "LOCATION": LocationProperty,
    -1767        "PARTITIONED_BY": PartitionedByProperty,
    -1768        "RETURNS": ReturnsProperty,
    -1769        "ROW_FORMAT": RowFormatProperty,
    -1770        "SORTKEY": SortKeyProperty,
    -1771        "TABLE_FORMAT": TableFormatProperty,
    -1772    }
    -1773
    -1774    PROPERTY_TO_NAME = {v: k for k, v in NAME_TO_PROPERTY.items()}
    -1775
    -1776    # CREATE property locations
    -1777    # Form: schema specified
    -1778    #   create [POST_CREATE]
    -1779    #     table a [POST_NAME]
    -1780    #     (b int) [POST_SCHEMA]
    -1781    #     with ([POST_WITH])
    -1782    #     index (b) [POST_INDEX]
    -1783    #
    -1784    # Form: alias selection
    -1785    #   create [POST_CREATE]
    -1786    #     table a [POST_NAME]
    -1787    #     as [POST_ALIAS] (select * from b) [POST_EXPRESSION]
    -1788    #     index (c) [POST_INDEX]
    -1789    class Location(AutoName):
    -1790        POST_CREATE = auto()
    -1791        POST_NAME = auto()
    -1792        POST_SCHEMA = auto()
    -1793        POST_WITH = auto()
    -1794        POST_ALIAS = auto()
    -1795        POST_EXPRESSION = auto()
    -1796        POST_INDEX = auto()
    -1797        UNSUPPORTED = auto()
    -1798
    -1799    @classmethod
    -1800    def from_dict(cls, properties_dict) -> Properties:
    -1801        expressions = []
    -1802        for key, value in properties_dict.items():
    -1803            property_cls = cls.NAME_TO_PROPERTY.get(key.upper())
    -1804            if property_cls:
    -1805                expressions.append(property_cls(this=convert(value)))
    -1806            else:
    -1807                expressions.append(Property(this=Literal.string(key), value=convert(value)))
    -1808
    -1809        return cls(expressions=expressions)
    +            
    1873class Properties(Expression):
    +1874    arg_types = {"expressions": True}
    +1875
    +1876    NAME_TO_PROPERTY = {
    +1877        "ALGORITHM": AlgorithmProperty,
    +1878        "AUTO_INCREMENT": AutoIncrementProperty,
    +1879        "CHARACTER SET": CharacterSetProperty,
    +1880        "COLLATE": CollateProperty,
    +1881        "COMMENT": SchemaCommentProperty,
    +1882        "DEFINER": DefinerProperty,
    +1883        "DISTKEY": DistKeyProperty,
    +1884        "DISTSTYLE": DistStyleProperty,
    +1885        "ENGINE": EngineProperty,
    +1886        "EXECUTE AS": ExecuteAsProperty,
    +1887        "FORMAT": FileFormatProperty,
    +1888        "LANGUAGE": LanguageProperty,
    +1889        "LOCATION": LocationProperty,
    +1890        "PARTITIONED_BY": PartitionedByProperty,
    +1891        "RETURNS": ReturnsProperty,
    +1892        "ROW_FORMAT": RowFormatProperty,
    +1893        "SORTKEY": SortKeyProperty,
    +1894        "TABLE_FORMAT": TableFormatProperty,
    +1895    }
    +1896
    +1897    PROPERTY_TO_NAME = {v: k for k, v in NAME_TO_PROPERTY.items()}
    +1898
    +1899    # CREATE property locations
    +1900    # Form: schema specified
    +1901    #   create [POST_CREATE]
    +1902    #     table a [POST_NAME]
    +1903    #     (b int) [POST_SCHEMA]
    +1904    #     with ([POST_WITH])
    +1905    #     index (b) [POST_INDEX]
    +1906    #
    +1907    # Form: alias selection
    +1908    #   create [POST_CREATE]
    +1909    #     table a [POST_NAME]
    +1910    #     as [POST_ALIAS] (select * from b) [POST_EXPRESSION]
    +1911    #     index (c) [POST_INDEX]
    +1912    class Location(AutoName):
    +1913        POST_CREATE = auto()
    +1914        POST_NAME = auto()
    +1915        POST_SCHEMA = auto()
    +1916        POST_WITH = auto()
    +1917        POST_ALIAS = auto()
    +1918        POST_EXPRESSION = auto()
    +1919        POST_INDEX = auto()
    +1920        UNSUPPORTED = auto()
    +1921
    +1922    @classmethod
    +1923    def from_dict(cls, properties_dict) -> Properties:
    +1924        expressions = []
    +1925        for key, value in properties_dict.items():
    +1926            property_cls = cls.NAME_TO_PROPERTY.get(key.upper())
    +1927            if property_cls:
    +1928                expressions.append(property_cls(this=convert(value)))
    +1929            else:
    +1930                expressions.append(Property(this=Literal.string(key), value=convert(value)))
    +1931
    +1932        return cls(expressions=expressions)
     
    @@ -20377,17 +20877,17 @@ Otherwise, this resets the expression.
    -
    1799    @classmethod
    -1800    def from_dict(cls, properties_dict) -> Properties:
    -1801        expressions = []
    -1802        for key, value in properties_dict.items():
    -1803            property_cls = cls.NAME_TO_PROPERTY.get(key.upper())
    -1804            if property_cls:
    -1805                expressions.append(property_cls(this=convert(value)))
    -1806            else:
    -1807                expressions.append(Property(this=Literal.string(key), value=convert(value)))
    -1808
    -1809        return cls(expressions=expressions)
    +            
    1922    @classmethod
    +1923    def from_dict(cls, properties_dict) -> Properties:
    +1924        expressions = []
    +1925        for key, value in properties_dict.items():
    +1926            property_cls = cls.NAME_TO_PROPERTY.get(key.upper())
    +1927            if property_cls:
    +1928                expressions.append(property_cls(this=convert(value)))
    +1929            else:
    +1930                expressions.append(Property(this=Literal.string(key), value=convert(value)))
    +1931
    +1932        return cls(expressions=expressions)
     
    @@ -20451,15 +20951,15 @@ Otherwise, this resets the expression.
    -
    1789    class Location(AutoName):
    -1790        POST_CREATE = auto()
    -1791        POST_NAME = auto()
    -1792        POST_SCHEMA = auto()
    -1793        POST_WITH = auto()
    -1794        POST_ALIAS = auto()
    -1795        POST_EXPRESSION = auto()
    -1796        POST_INDEX = auto()
    -1797        UNSUPPORTED = auto()
    +            
    1912    class Location(AutoName):
    +1913        POST_CREATE = auto()
    +1914        POST_NAME = auto()
    +1915        POST_SCHEMA = auto()
    +1916        POST_WITH = auto()
    +1917        POST_ALIAS = auto()
    +1918        POST_EXPRESSION = auto()
    +1919        POST_INDEX = auto()
    +1920        UNSUPPORTED = auto()
     
    @@ -20585,8 +21085,8 @@ Otherwise, this resets the expression.
    -
    1812class Qualify(Expression):
    -1813    pass
    +            
    1935class Qualify(Expression):
    +1936    pass
     
    @@ -20649,8 +21149,8 @@ Otherwise, this resets the expression.
    -
    1817class Return(Expression):
    -1818    pass
    +            
    1940class Return(Expression):
    +1941    pass
     
    @@ -20713,8 +21213,8 @@ Otherwise, this resets the expression.
    -
    1821class Reference(Expression):
    -1822    arg_types = {"this": True, "expressions": False, "options": False}
    +            
    1944class Reference(Expression):
    +1945    arg_types = {"this": True, "expressions": False, "options": False}
     
    @@ -20777,8 +21277,8 @@ Otherwise, this resets the expression.
    -
    1825class Tuple(Expression):
    -1826    arg_types = {"expressions": False}
    +            
    1948class Tuple(Expression):
    +1949    arg_types = {"expressions": False}
     
    @@ -20841,103 +21341,103 @@ Otherwise, this resets the expression.
    -
    1829class Subqueryable(Unionable):
    -1830    def subquery(self, alias=None, copy=True) -> Subquery:
    -1831        """
    -1832        Convert this expression to an aliased expression that can be used as a Subquery.
    -1833
    -1834        Example:
    -1835            >>> subquery = Select().select("x").from_("tbl").subquery()
    -1836            >>> Select().select("x").from_(subquery).sql()
    -1837            'SELECT x FROM (SELECT x FROM tbl)'
    -1838
    -1839        Args:
    -1840            alias (str | Identifier): an optional alias for the subquery
    -1841            copy (bool): if `False`, modify this expression instance in-place.
    -1842
    -1843        Returns:
    -1844            Alias: the subquery
    -1845        """
    -1846        instance = _maybe_copy(self, copy)
    -1847        return Subquery(
    -1848            this=instance,
    -1849            alias=TableAlias(this=to_identifier(alias)) if alias else None,
    -1850        )
    -1851
    -1852    def limit(self, expression, dialect=None, copy=True, **opts) -> Select:
    -1853        raise NotImplementedError
    -1854
    -1855    @property
    -1856    def ctes(self):
    -1857        with_ = self.args.get("with")
    -1858        if not with_:
    -1859            return []
    -1860        return with_.expressions
    -1861
    -1862    @property
    -1863    def selects(self):
    -1864        raise NotImplementedError("Subqueryable objects must implement `selects`")
    -1865
    -1866    @property
    -1867    def named_selects(self):
    -1868        raise NotImplementedError("Subqueryable objects must implement `named_selects`")
    -1869
    -1870    def with_(
    -1871        self,
    -1872        alias,
    -1873        as_,
    -1874        recursive=None,
    -1875        append=True,
    -1876        dialect=None,
    -1877        copy=True,
    -1878        **opts,
    -1879    ):
    -1880        """
    -1881        Append to or set the common table expressions.
    -1882
    -1883        Example:
    -1884            >>> Select().with_("tbl2", as_="SELECT * FROM tbl").select("x").from_("tbl2").sql()
    -1885            'WITH tbl2 AS (SELECT * FROM tbl) SELECT x FROM tbl2'
    -1886
    -1887        Args:
    -1888            alias (str | Expression): the SQL code string to parse as the table name.
    -1889                If an `Expression` instance is passed, this is used as-is.
    -1890            as_ (str | Expression): the SQL code string to parse as the table expression.
    -1891                If an `Expression` instance is passed, it will be used as-is.
    -1892            recursive (bool): set the RECURSIVE part of the expression. Defaults to `False`.
    -1893            append (bool): if `True`, add to any existing expressions.
    -1894                Otherwise, this resets the expressions.
    -1895            dialect (str): the dialect used to parse the input expression.
    -1896            copy (bool): if `False`, modify this expression instance in-place.
    -1897            opts (kwargs): other options to use to parse the input expressions.
    -1898
    -1899        Returns:
    -1900            Select: the modified expression.
    -1901        """
    -1902        alias_expression = maybe_parse(
    -1903            alias,
    -1904            dialect=dialect,
    -1905            into=TableAlias,
    -1906            **opts,
    -1907        )
    -1908        as_expression = maybe_parse(
    -1909            as_,
    -1910            dialect=dialect,
    -1911            **opts,
    -1912        )
    -1913        cte = CTE(
    -1914            this=as_expression,
    -1915            alias=alias_expression,
    -1916        )
    -1917        return _apply_child_list_builder(
    -1918            cte,
    -1919            instance=self,
    -1920            arg="with",
    -1921            append=append,
    -1922            copy=copy,
    -1923            into=With,
    -1924            properties={"recursive": recursive or False},
    -1925        )
    +            
    1952class Subqueryable(Unionable):
    +1953    def subquery(self, alias=None, copy=True) -> Subquery:
    +1954        """
    +1955        Convert this expression to an aliased expression that can be used as a Subquery.
    +1956
    +1957        Example:
    +1958            >>> subquery = Select().select("x").from_("tbl").subquery()
    +1959            >>> Select().select("x").from_(subquery).sql()
    +1960            'SELECT x FROM (SELECT x FROM tbl)'
    +1961
    +1962        Args:
    +1963            alias (str | Identifier): an optional alias for the subquery
    +1964            copy (bool): if `False`, modify this expression instance in-place.
    +1965
    +1966        Returns:
    +1967            Alias: the subquery
    +1968        """
    +1969        instance = _maybe_copy(self, copy)
    +1970        return Subquery(
    +1971            this=instance,
    +1972            alias=TableAlias(this=to_identifier(alias)) if alias else None,
    +1973        )
    +1974
    +1975    def limit(self, expression, dialect=None, copy=True, **opts) -> Select:
    +1976        raise NotImplementedError
    +1977
    +1978    @property
    +1979    def ctes(self):
    +1980        with_ = self.args.get("with")
    +1981        if not with_:
    +1982            return []
    +1983        return with_.expressions
    +1984
    +1985    @property
    +1986    def selects(self):
    +1987        raise NotImplementedError("Subqueryable objects must implement `selects`")
    +1988
    +1989    @property
    +1990    def named_selects(self):
    +1991        raise NotImplementedError("Subqueryable objects must implement `named_selects`")
    +1992
    +1993    def with_(
    +1994        self,
    +1995        alias,
    +1996        as_,
    +1997        recursive=None,
    +1998        append=True,
    +1999        dialect=None,
    +2000        copy=True,
    +2001        **opts,
    +2002    ):
    +2003        """
    +2004        Append to or set the common table expressions.
    +2005
    +2006        Example:
    +2007            >>> Select().with_("tbl2", as_="SELECT * FROM tbl").select("x").from_("tbl2").sql()
    +2008            'WITH tbl2 AS (SELECT * FROM tbl) SELECT x FROM tbl2'
    +2009
    +2010        Args:
    +2011            alias (str | Expression): the SQL code string to parse as the table name.
    +2012                If an `Expression` instance is passed, this is used as-is.
    +2013            as_ (str | Expression): the SQL code string to parse as the table expression.
    +2014                If an `Expression` instance is passed, it will be used as-is.
    +2015            recursive (bool): set the RECURSIVE part of the expression. Defaults to `False`.
    +2016            append (bool): if `True`, add to any existing expressions.
    +2017                Otherwise, this resets the expressions.
    +2018            dialect (str): the dialect used to parse the input expression.
    +2019            copy (bool): if `False`, modify this expression instance in-place.
    +2020            opts (kwargs): other options to use to parse the input expressions.
    +2021
    +2022        Returns:
    +2023            Select: the modified expression.
    +2024        """
    +2025        alias_expression = maybe_parse(
    +2026            alias,
    +2027            dialect=dialect,
    +2028            into=TableAlias,
    +2029            **opts,
    +2030        )
    +2031        as_expression = maybe_parse(
    +2032            as_,
    +2033            dialect=dialect,
    +2034            **opts,
    +2035        )
    +2036        cte = CTE(
    +2037            this=as_expression,
    +2038            alias=alias_expression,
    +2039        )
    +2040        return _apply_child_list_builder(
    +2041            cte,
    +2042            instance=self,
    +2043            arg="with",
    +2044            append=append,
    +2045            copy=copy,
    +2046            into=With,
    +2047            properties={"recursive": recursive or False},
    +2048        )
     
    @@ -20954,27 +21454,27 @@ Otherwise, this resets the expression.
    -
    1830    def subquery(self, alias=None, copy=True) -> Subquery:
    -1831        """
    -1832        Convert this expression to an aliased expression that can be used as a Subquery.
    -1833
    -1834        Example:
    -1835            >>> subquery = Select().select("x").from_("tbl").subquery()
    -1836            >>> Select().select("x").from_(subquery).sql()
    -1837            'SELECT x FROM (SELECT x FROM tbl)'
    -1838
    -1839        Args:
    -1840            alias (str | Identifier): an optional alias for the subquery
    -1841            copy (bool): if `False`, modify this expression instance in-place.
    -1842
    -1843        Returns:
    -1844            Alias: the subquery
    -1845        """
    -1846        instance = _maybe_copy(self, copy)
    -1847        return Subquery(
    -1848            this=instance,
    -1849            alias=TableAlias(this=to_identifier(alias)) if alias else None,
    -1850        )
    +            
    1953    def subquery(self, alias=None, copy=True) -> Subquery:
    +1954        """
    +1955        Convert this expression to an aliased expression that can be used as a Subquery.
    +1956
    +1957        Example:
    +1958            >>> subquery = Select().select("x").from_("tbl").subquery()
    +1959            >>> Select().select("x").from_(subquery).sql()
    +1960            'SELECT x FROM (SELECT x FROM tbl)'
    +1961
    +1962        Args:
    +1963            alias (str | Identifier): an optional alias for the subquery
    +1964            copy (bool): if `False`, modify this expression instance in-place.
    +1965
    +1966        Returns:
    +1967            Alias: the subquery
    +1968        """
    +1969        instance = _maybe_copy(self, copy)
    +1970        return Subquery(
    +1971            this=instance,
    +1972            alias=TableAlias(this=to_identifier(alias)) if alias else None,
    +1973        )
     
    @@ -21018,8 +21518,8 @@ Otherwise, this resets the expression.
    -
    1852    def limit(self, expression, dialect=None, copy=True, **opts) -> Select:
    -1853        raise NotImplementedError
    +            
    1975    def limit(self, expression, dialect=None, copy=True, **opts) -> Select:
    +1976        raise NotImplementedError
     
    @@ -21037,62 +21537,62 @@ Otherwise, this resets the expression.
    -
    1870    def with_(
    -1871        self,
    -1872        alias,
    -1873        as_,
    -1874        recursive=None,
    -1875        append=True,
    -1876        dialect=None,
    -1877        copy=True,
    -1878        **opts,
    -1879    ):
    -1880        """
    -1881        Append to or set the common table expressions.
    -1882
    -1883        Example:
    -1884            >>> Select().with_("tbl2", as_="SELECT * FROM tbl").select("x").from_("tbl2").sql()
    -1885            'WITH tbl2 AS (SELECT * FROM tbl) SELECT x FROM tbl2'
    -1886
    -1887        Args:
    -1888            alias (str | Expression): the SQL code string to parse as the table name.
    -1889                If an `Expression` instance is passed, this is used as-is.
    -1890            as_ (str | Expression): the SQL code string to parse as the table expression.
    -1891                If an `Expression` instance is passed, it will be used as-is.
    -1892            recursive (bool): set the RECURSIVE part of the expression. Defaults to `False`.
    -1893            append (bool): if `True`, add to any existing expressions.
    -1894                Otherwise, this resets the expressions.
    -1895            dialect (str): the dialect used to parse the input expression.
    -1896            copy (bool): if `False`, modify this expression instance in-place.
    -1897            opts (kwargs): other options to use to parse the input expressions.
    -1898
    -1899        Returns:
    -1900            Select: the modified expression.
    -1901        """
    -1902        alias_expression = maybe_parse(
    -1903            alias,
    -1904            dialect=dialect,
    -1905            into=TableAlias,
    -1906            **opts,
    -1907        )
    -1908        as_expression = maybe_parse(
    -1909            as_,
    -1910            dialect=dialect,
    -1911            **opts,
    -1912        )
    -1913        cte = CTE(
    -1914            this=as_expression,
    -1915            alias=alias_expression,
    -1916        )
    -1917        return _apply_child_list_builder(
    -1918            cte,
    -1919            instance=self,
    -1920            arg="with",
    -1921            append=append,
    -1922            copy=copy,
    -1923            into=With,
    -1924            properties={"recursive": recursive or False},
    -1925        )
    +            
    1993    def with_(
    +1994        self,
    +1995        alias,
    +1996        as_,
    +1997        recursive=None,
    +1998        append=True,
    +1999        dialect=None,
    +2000        copy=True,
    +2001        **opts,
    +2002    ):
    +2003        """
    +2004        Append to or set the common table expressions.
    +2005
    +2006        Example:
    +2007            >>> Select().with_("tbl2", as_="SELECT * FROM tbl").select("x").from_("tbl2").sql()
    +2008            'WITH tbl2 AS (SELECT * FROM tbl) SELECT x FROM tbl2'
    +2009
    +2010        Args:
    +2011            alias (str | Expression): the SQL code string to parse as the table name.
    +2012                If an `Expression` instance is passed, this is used as-is.
    +2013            as_ (str | Expression): the SQL code string to parse as the table expression.
    +2014                If an `Expression` instance is passed, it will be used as-is.
    +2015            recursive (bool): set the RECURSIVE part of the expression. Defaults to `False`.
    +2016            append (bool): if `True`, add to any existing expressions.
    +2017                Otherwise, this resets the expressions.
    +2018            dialect (str): the dialect used to parse the input expression.
    +2019            copy (bool): if `False`, modify this expression instance in-place.
    +2020            opts (kwargs): other options to use to parse the input expressions.
    +2021
    +2022        Returns:
    +2023            Select: the modified expression.
    +2024        """
    +2025        alias_expression = maybe_parse(
    +2026            alias,
    +2027            dialect=dialect,
    +2028            into=TableAlias,
    +2029            **opts,
    +2030        )
    +2031        as_expression = maybe_parse(
    +2032            as_,
    +2033            dialect=dialect,
    +2034            **opts,
    +2035        )
    +2036        cte = CTE(
    +2037            this=as_expression,
    +2038            alias=alias_expression,
    +2039        )
    +2040        return _apply_child_list_builder(
    +2041            cte,
    +2042            instance=self,
    +2043            arg="with",
    +2044            append=append,
    +2045            copy=copy,
    +2046            into=With,
    +2047            properties={"recursive": recursive or False},
    +2048        )
     
    @@ -21195,26 +21695,26 @@ Otherwise, this resets the expressions.
    -
    1949class Table(Expression):
    -1950    arg_types = {
    -1951        "this": True,
    -1952        "alias": False,
    -1953        "db": False,
    -1954        "catalog": False,
    -1955        "laterals": False,
    -1956        "joins": False,
    -1957        "pivots": False,
    -1958        "hints": False,
    -1959        "system_time": False,
    -1960    }
    -1961
    -1962    @property
    -1963    def db(self) -> str:
    -1964        return self.text("db")
    -1965
    -1966    @property
    -1967    def catalog(self) -> str:
    -1968        return self.text("catalog")
    +            
    2072class Table(Expression):
    +2073    arg_types = {
    +2074        "this": True,
    +2075        "alias": False,
    +2076        "db": False,
    +2077        "catalog": False,
    +2078        "laterals": False,
    +2079        "joins": False,
    +2080        "pivots": False,
    +2081        "hints": False,
    +2082        "system_time": False,
    +2083    }
    +2084
    +2085    @property
    +2086    def db(self) -> str:
    +2087        return self.text("db")
    +2088
    +2089    @property
    +2090    def catalog(self) -> str:
    +2091        return self.text("catalog")
     
    @@ -21277,12 +21777,12 @@ Otherwise, this resets the expressions.
    -
    1972class SystemTime(Expression):
    -1973    arg_types = {
    -1974        "this": False,
    -1975        "expression": False,
    -1976        "kind": True,
    -1977    }
    +            
    2095class SystemTime(Expression):
    +2096    arg_types = {
    +2097        "this": False,
    +2098        "expression": False,
    +2099        "kind": True,
    +2100    }
     
    @@ -21345,94 +21845,94 @@ Otherwise, this resets the expressions.
    -
    1980class Union(Subqueryable):
    -1981    arg_types = {
    -1982        "with": False,
    -1983        "this": True,
    -1984        "expression": True,
    -1985        "distinct": False,
    -1986        **QUERY_MODIFIERS,
    -1987    }
    -1988
    -1989    def limit(self, expression, dialect=None, copy=True, **opts) -> Select:
    -1990        """
    -1991        Set the LIMIT expression.
    -1992
    -1993        Example:
    -1994            >>> select("1").union(select("1")).limit(1).sql()
    -1995            'SELECT * FROM (SELECT 1 UNION SELECT 1) AS _l_0 LIMIT 1'
    -1996
    -1997        Args:
    -1998            expression (str | int | Expression): the SQL code string to parse.
    -1999                This can also be an integer.
    -2000                If a `Limit` instance is passed, this is used as-is.
    -2001                If another `Expression` instance is passed, it will be wrapped in a `Limit`.
    -2002            dialect (str): the dialect used to parse the input expression.
    -2003            copy (bool): if `False`, modify this expression instance in-place.
    -2004            opts (kwargs): other options to use to parse the input expressions.
    -2005
    -2006        Returns:
    -2007            Select: The limited subqueryable.
    -2008        """
    -2009        return (
    -2010            select("*")
    -2011            .from_(self.subquery(alias="_l_0", copy=copy))
    -2012            .limit(expression, dialect=dialect, copy=False, **opts)
    -2013        )
    -2014
    -2015    def select(
    -2016        self,
    -2017        *expressions: ExpOrStr,
    -2018        append: bool = True,
    -2019        dialect: DialectType = None,
    -2020        copy: bool = True,
    -2021        **opts,
    -2022    ) -> Union:
    -2023        """Append to or set the SELECT of the union recursively.
    -2024
    -2025        Example:
    -2026            >>> from sqlglot import parse_one
    -2027            >>> parse_one("select a from x union select a from y union select a from z").select("b").sql()
    -2028            'SELECT a, b FROM x UNION SELECT a, b FROM y UNION SELECT a, b FROM z'
    -2029
    -2030        Args:
    -2031            *expressions: the SQL code strings to parse.
    -2032                If an `Expression` instance is passed, it will be used as-is.
    -2033            append: if `True`, add to any existing expressions.
    -2034                Otherwise, this resets the expressions.
    -2035            dialect: the dialect used to parse the input expressions.
    -2036            copy: if `False`, modify this expression instance in-place.
    -2037            opts: other options to use to parse the input expressions.
    -2038
    -2039        Returns:
    -2040            Union: the modified expression.
    -2041        """
    -2042        this = self.copy() if copy else self
    -2043        this.this.unnest().select(*expressions, append=append, dialect=dialect, copy=False, **opts)
    -2044        this.expression.unnest().select(
    -2045            *expressions, append=append, dialect=dialect, copy=False, **opts
    -2046        )
    -2047        return this
    -2048
    -2049    @property
    -2050    def named_selects(self):
    -2051        return self.this.unnest().named_selects
    -2052
    -2053    @property
    -2054    def is_star(self) -> bool:
    -2055        return self.this.is_star or self.expression.is_star
    -2056
    -2057    @property
    -2058    def selects(self):
    -2059        return self.this.unnest().selects
    -2060
    -2061    @property
    -2062    def left(self):
    -2063        return self.this
    -2064
    -2065    @property
    -2066    def right(self):
    -2067        return self.expression
    +            
    2103class Union(Subqueryable):
    +2104    arg_types = {
    +2105        "with": False,
    +2106        "this": True,
    +2107        "expression": True,
    +2108        "distinct": False,
    +2109        **QUERY_MODIFIERS,
    +2110    }
    +2111
    +2112    def limit(self, expression, dialect=None, copy=True, **opts) -> Select:
    +2113        """
    +2114        Set the LIMIT expression.
    +2115
    +2116        Example:
    +2117            >>> select("1").union(select("1")).limit(1).sql()
    +2118            'SELECT * FROM (SELECT 1 UNION SELECT 1) AS _l_0 LIMIT 1'
    +2119
    +2120        Args:
    +2121            expression (str | int | Expression): the SQL code string to parse.
    +2122                This can also be an integer.
    +2123                If a `Limit` instance is passed, this is used as-is.
    +2124                If another `Expression` instance is passed, it will be wrapped in a `Limit`.
    +2125            dialect (str): the dialect used to parse the input expression.
    +2126            copy (bool): if `False`, modify this expression instance in-place.
    +2127            opts (kwargs): other options to use to parse the input expressions.
    +2128
    +2129        Returns:
    +2130            Select: The limited subqueryable.
    +2131        """
    +2132        return (
    +2133            select("*")
    +2134            .from_(self.subquery(alias="_l_0", copy=copy))
    +2135            .limit(expression, dialect=dialect, copy=False, **opts)
    +2136        )
    +2137
    +2138    def select(
    +2139        self,
    +2140        *expressions: ExpOrStr,
    +2141        append: bool = True,
    +2142        dialect: DialectType = None,
    +2143        copy: bool = True,
    +2144        **opts,
    +2145    ) -> Union:
    +2146        """Append to or set the SELECT of the union recursively.
    +2147
    +2148        Example:
    +2149            >>> from sqlglot import parse_one
    +2150            >>> parse_one("select a from x union select a from y union select a from z").select("b").sql()
    +2151            'SELECT a, b FROM x UNION SELECT a, b FROM y UNION SELECT a, b FROM z'
    +2152
    +2153        Args:
    +2154            *expressions: the SQL code strings to parse.
    +2155                If an `Expression` instance is passed, it will be used as-is.
    +2156            append: if `True`, add to any existing expressions.
    +2157                Otherwise, this resets the expressions.
    +2158            dialect: the dialect used to parse the input expressions.
    +2159            copy: if `False`, modify this expression instance in-place.
    +2160            opts: other options to use to parse the input expressions.
    +2161
    +2162        Returns:
    +2163            Union: the modified expression.
    +2164        """
    +2165        this = self.copy() if copy else self
    +2166        this.this.unnest().select(*expressions, append=append, dialect=dialect, copy=False, **opts)
    +2167        this.expression.unnest().select(
    +2168            *expressions, append=append, dialect=dialect, copy=False, **opts
    +2169        )
    +2170        return this
    +2171
    +2172    @property
    +2173    def named_selects(self):
    +2174        return self.this.unnest().named_selects
    +2175
    +2176    @property
    +2177    def is_star(self) -> bool:
    +2178        return self.this.is_star or self.expression.is_star
    +2179
    +2180    @property
    +2181    def selects(self):
    +2182        return self.this.unnest().selects
    +2183
    +2184    @property
    +2185    def left(self):
    +2186        return self.this
    +2187
    +2188    @property
    +2189    def right(self):
    +2190        return self.expression
     
    @@ -21449,31 +21949,31 @@ Otherwise, this resets the expressions.
    -
    1989    def limit(self, expression, dialect=None, copy=True, **opts) -> Select:
    -1990        """
    -1991        Set the LIMIT expression.
    -1992
    -1993        Example:
    -1994            >>> select("1").union(select("1")).limit(1).sql()
    -1995            'SELECT * FROM (SELECT 1 UNION SELECT 1) AS _l_0 LIMIT 1'
    -1996
    -1997        Args:
    -1998            expression (str | int | Expression): the SQL code string to parse.
    -1999                This can also be an integer.
    -2000                If a `Limit` instance is passed, this is used as-is.
    -2001                If another `Expression` instance is passed, it will be wrapped in a `Limit`.
    -2002            dialect (str): the dialect used to parse the input expression.
    -2003            copy (bool): if `False`, modify this expression instance in-place.
    -2004            opts (kwargs): other options to use to parse the input expressions.
    -2005
    -2006        Returns:
    -2007            Select: The limited subqueryable.
    -2008        """
    -2009        return (
    -2010            select("*")
    -2011            .from_(self.subquery(alias="_l_0", copy=copy))
    -2012            .limit(expression, dialect=dialect, copy=False, **opts)
    -2013        )
    +            
    2112    def limit(self, expression, dialect=None, copy=True, **opts) -> Select:
    +2113        """
    +2114        Set the LIMIT expression.
    +2115
    +2116        Example:
    +2117            >>> select("1").union(select("1")).limit(1).sql()
    +2118            'SELECT * FROM (SELECT 1 UNION SELECT 1) AS _l_0 LIMIT 1'
    +2119
    +2120        Args:
    +2121            expression (str | int | Expression): the SQL code string to parse.
    +2122                This can also be an integer.
    +2123                If a `Limit` instance is passed, this is used as-is.
    +2124                If another `Expression` instance is passed, it will be wrapped in a `Limit`.
    +2125            dialect (str): the dialect used to parse the input expression.
    +2126            copy (bool): if `False`, modify this expression instance in-place.
    +2127            opts (kwargs): other options to use to parse the input expressions.
    +2128
    +2129        Returns:
    +2130            Select: The limited subqueryable.
    +2131        """
    +2132        return (
    +2133            select("*")
    +2134            .from_(self.subquery(alias="_l_0", copy=copy))
    +2135            .limit(expression, dialect=dialect, copy=False, **opts)
    +2136        )
     
    @@ -21521,39 +22021,39 @@ If another Expression instance is passed,
    -
    2015    def select(
    -2016        self,
    -2017        *expressions: ExpOrStr,
    -2018        append: bool = True,
    -2019        dialect: DialectType = None,
    -2020        copy: bool = True,
    -2021        **opts,
    -2022    ) -> Union:
    -2023        """Append to or set the SELECT of the union recursively.
    -2024
    -2025        Example:
    -2026            >>> from sqlglot import parse_one
    -2027            >>> parse_one("select a from x union select a from y union select a from z").select("b").sql()
    -2028            'SELECT a, b FROM x UNION SELECT a, b FROM y UNION SELECT a, b FROM z'
    -2029
    -2030        Args:
    -2031            *expressions: the SQL code strings to parse.
    -2032                If an `Expression` instance is passed, it will be used as-is.
    -2033            append: if `True`, add to any existing expressions.
    -2034                Otherwise, this resets the expressions.
    -2035            dialect: the dialect used to parse the input expressions.
    -2036            copy: if `False`, modify this expression instance in-place.
    -2037            opts: other options to use to parse the input expressions.
    -2038
    -2039        Returns:
    -2040            Union: the modified expression.
    -2041        """
    -2042        this = self.copy() if copy else self
    -2043        this.this.unnest().select(*expressions, append=append, dialect=dialect, copy=False, **opts)
    -2044        this.expression.unnest().select(
    -2045            *expressions, append=append, dialect=dialect, copy=False, **opts
    -2046        )
    -2047        return this
    +            
    2138    def select(
    +2139        self,
    +2140        *expressions: ExpOrStr,
    +2141        append: bool = True,
    +2142        dialect: DialectType = None,
    +2143        copy: bool = True,
    +2144        **opts,
    +2145    ) -> Union:
    +2146        """Append to or set the SELECT of the union recursively.
    +2147
    +2148        Example:
    +2149            >>> from sqlglot import parse_one
    +2150            >>> parse_one("select a from x union select a from y union select a from z").select("b").sql()
    +2151            'SELECT a, b FROM x UNION SELECT a, b FROM y UNION SELECT a, b FROM z'
    +2152
    +2153        Args:
    +2154            *expressions: the SQL code strings to parse.
    +2155                If an `Expression` instance is passed, it will be used as-is.
    +2156            append: if `True`, add to any existing expressions.
    +2157                Otherwise, this resets the expressions.
    +2158            dialect: the dialect used to parse the input expressions.
    +2159            copy: if `False`, modify this expression instance in-place.
    +2160            opts: other options to use to parse the input expressions.
    +2161
    +2162        Returns:
    +2163            Union: the modified expression.
    +2164        """
    +2165        this = self.copy() if copy else self
    +2166        this.this.unnest().select(*expressions, append=append, dialect=dialect, copy=False, **opts)
    +2167        this.expression.unnest().select(
    +2168            *expressions, append=append, dialect=dialect, copy=False, **opts
    +2169        )
    +2170        return this
     
    @@ -21671,8 +22171,8 @@ Otherwise, this resets the expressions.
    -
    2070class Except(Union):
    -2071    pass
    +            
    2193class Except(Union):
    +2194    pass
     
    @@ -21751,8 +22251,8 @@ Otherwise, this resets the expressions.
    -
    2074class Intersect(Union):
    -2075    pass
    +            
    2197class Intersect(Union):
    +2198    pass
     
    @@ -21831,13 +22331,13 @@ Otherwise, this resets the expressions.
    -
    2078class Unnest(UDTF):
    -2079    arg_types = {
    -2080        "expressions": True,
    -2081        "ordinality": False,
    -2082        "alias": False,
    -2083        "offset": False,
    -2084    }
    +            
    2201class Unnest(UDTF):
    +2202    arg_types = {
    +2203        "expressions": True,
    +2204        "ordinality": False,
    +2205        "alias": False,
    +2206        "offset": False,
    +2207    }
     
    @@ -21906,15 +22406,15 @@ Otherwise, this resets the expressions.
    -
    2087class Update(Expression):
    -2088    arg_types = {
    -2089        "with": False,
    -2090        "this": False,
    -2091        "expressions": True,
    -2092        "from": False,
    -2093        "where": False,
    -2094        "returning": False,
    -2095    }
    +            
    2210class Update(Expression):
    +2211    arg_types = {
    +2212        "with": False,
    +2213        "this": False,
    +2214        "expressions": True,
    +2215        "from": False,
    +2216        "where": False,
    +2217        "returning": False,
    +2218    }
     
    @@ -21977,12 +22477,12 @@ Otherwise, this resets the expressions.
    -
    2098class Values(UDTF):
    -2099    arg_types = {
    -2100        "expressions": True,
    -2101        "ordinality": False,
    -2102        "alias": False,
    -2103    }
    +            
    2221class Values(UDTF):
    +2222    arg_types = {
    +2223        "expressions": True,
    +2224        "ordinality": False,
    +2225        "alias": False,
    +2226    }
     
    @@ -22051,8 +22551,8 @@ Otherwise, this resets the expressions.
    -
    2106class Var(Expression):
    -2107    pass
    +            
    2229class Var(Expression):
    +2230    pass
     
    @@ -22115,8 +22615,8 @@ Otherwise, this resets the expressions.
    -
    2110class Schema(Expression):
    -2111    arg_types = {"this": False, "expressions": False}
    +            
    2233class Schema(Expression):
    +2234    arg_types = {"this": False, "expressions": False}
     
    @@ -22179,8 +22679,8 @@ Otherwise, this resets the expressions.
    -
    2116class Lock(Expression):
    -2117    arg_types = {"update": True}
    +            
    2239class Lock(Expression):
    +2240    arg_types = {"update": True}
     
    @@ -22243,591 +22743,593 @@ Otherwise, this resets the expressions.
    -
    2120class Select(Subqueryable):
    -2121    arg_types = {
    -2122        "with": False,
    -2123        "kind": False,
    -2124        "expressions": False,
    -2125        "hint": False,
    -2126        "distinct": False,
    -2127        "into": False,
    -2128        "from": False,
    -2129        **QUERY_MODIFIERS,
    -2130    }
    -2131
    -2132    def from_(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2133        """
    -2134        Set the FROM expression.
    -2135
    -2136        Example:
    -2137            >>> Select().from_("tbl").select("x").sql()
    -2138            'SELECT x FROM tbl'
    -2139
    -2140        Args:
    -2141            *expressions (str | Expression): the SQL code strings to parse.
    -2142                If a `From` instance is passed, this is used as-is.
    -2143                If another `Expression` instance is passed, it will be wrapped in a `From`.
    -2144            append (bool): if `True`, add to any existing expressions.
    -2145                Otherwise, this flattens all the `From` expression into a single expression.
    -2146            dialect (str): the dialect used to parse the input expression.
    -2147            copy (bool): if `False`, modify this expression instance in-place.
    -2148            opts (kwargs): other options to use to parse the input expressions.
    -2149
    -2150        Returns:
    -2151            Select: the modified expression.
    -2152        """
    -2153        return _apply_child_list_builder(
    -2154            *expressions,
    -2155            instance=self,
    -2156            arg="from",
    -2157            append=append,
    -2158            copy=copy,
    -2159            prefix="FROM",
    -2160            into=From,
    -2161            dialect=dialect,
    -2162            **opts,
    -2163        )
    -2164
    -2165    def group_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2166        """
    -2167        Set the GROUP BY expression.
    -2168
    -2169        Example:
    -2170            >>> Select().from_("tbl").select("x", "COUNT(1)").group_by("x").sql()
    -2171            'SELECT x, COUNT(1) FROM tbl GROUP BY x'
    -2172
    -2173        Args:
    -2174            *expressions (str | Expression): the SQL code strings to parse.
    -2175                If a `Group` instance is passed, this is used as-is.
    -2176                If another `Expression` instance is passed, it will be wrapped in a `Group`.
    -2177                If nothing is passed in then a group by is not applied to the expression
    -2178            append (bool): if `True`, add to any existing expressions.
    -2179                Otherwise, this flattens all the `Group` expression into a single expression.
    -2180            dialect (str): the dialect used to parse the input expression.
    -2181            copy (bool): if `False`, modify this expression instance in-place.
    -2182            opts (kwargs): other options to use to parse the input expressions.
    -2183
    -2184        Returns:
    -2185            Select: the modified expression.
    -2186        """
    -2187        if not expressions:
    -2188            return self if not copy else self.copy()
    -2189        return _apply_child_list_builder(
    -2190            *expressions,
    -2191            instance=self,
    -2192            arg="group",
    -2193            append=append,
    -2194            copy=copy,
    -2195            prefix="GROUP BY",
    -2196            into=Group,
    -2197            dialect=dialect,
    -2198            **opts,
    -2199        )
    -2200
    -2201    def order_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2202        """
    -2203        Set the ORDER BY expression.
    -2204
    -2205        Example:
    -2206            >>> Select().from_("tbl").select("x").order_by("x DESC").sql()
    -2207            'SELECT x FROM tbl ORDER BY x DESC'
    -2208
    -2209        Args:
    -2210            *expressions (str | Expression): the SQL code strings to parse.
    -2211                If a `Group` instance is passed, this is used as-is.
    -2212                If another `Expression` instance is passed, it will be wrapped in a `Order`.
    -2213            append (bool): if `True`, add to any existing expressions.
    -2214                Otherwise, this flattens all the `Order` expression into a single expression.
    -2215            dialect (str): the dialect used to parse the input expression.
    -2216            copy (bool): if `False`, modify this expression instance in-place.
    -2217            opts (kwargs): other options to use to parse the input expressions.
    -2218
    -2219        Returns:
    -2220            Select: the modified expression.
    -2221        """
    -2222        return _apply_child_list_builder(
    -2223            *expressions,
    -2224            instance=self,
    -2225            arg="order",
    -2226            append=append,
    -2227            copy=copy,
    -2228            prefix="ORDER BY",
    -2229            into=Order,
    -2230            dialect=dialect,
    -2231            **opts,
    -2232        )
    -2233
    -2234    def sort_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2235        """
    -2236        Set the SORT BY expression.
    -2237
    -2238        Example:
    -2239            >>> Select().from_("tbl").select("x").sort_by("x DESC").sql()
    -2240            'SELECT x FROM tbl SORT BY x DESC'
    -2241
    -2242        Args:
    -2243            *expressions (str | Expression): the SQL code strings to parse.
    -2244                If a `Group` instance is passed, this is used as-is.
    -2245                If another `Expression` instance is passed, it will be wrapped in a `SORT`.
    -2246            append (bool): if `True`, add to any existing expressions.
    -2247                Otherwise, this flattens all the `Order` expression into a single expression.
    -2248            dialect (str): the dialect used to parse the input expression.
    -2249            copy (bool): if `False`, modify this expression instance in-place.
    -2250            opts (kwargs): other options to use to parse the input expressions.
    -2251
    -2252        Returns:
    -2253            Select: the modified expression.
    -2254        """
    -2255        return _apply_child_list_builder(
    -2256            *expressions,
    -2257            instance=self,
    -2258            arg="sort",
    -2259            append=append,
    -2260            copy=copy,
    -2261            prefix="SORT BY",
    -2262            into=Sort,
    -2263            dialect=dialect,
    -2264            **opts,
    -2265        )
    -2266
    -2267    def cluster_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2268        """
    -2269        Set the CLUSTER BY expression.
    -2270
    -2271        Example:
    -2272            >>> Select().from_("tbl").select("x").cluster_by("x DESC").sql()
    -2273            'SELECT x FROM tbl CLUSTER BY x DESC'
    -2274
    -2275        Args:
    -2276            *expressions (str | Expression): the SQL code strings to parse.
    -2277                If a `Group` instance is passed, this is used as-is.
    -2278                If another `Expression` instance is passed, it will be wrapped in a `Cluster`.
    -2279            append (bool): if `True`, add to any existing expressions.
    -2280                Otherwise, this flattens all the `Order` expression into a single expression.
    -2281            dialect (str): the dialect used to parse the input expression.
    -2282            copy (bool): if `False`, modify this expression instance in-place.
    -2283            opts (kwargs): other options to use to parse the input expressions.
    -2284
    -2285        Returns:
    -2286            Select: the modified expression.
    -2287        """
    -2288        return _apply_child_list_builder(
    -2289            *expressions,
    -2290            instance=self,
    -2291            arg="cluster",
    -2292            append=append,
    -2293            copy=copy,
    -2294            prefix="CLUSTER BY",
    -2295            into=Cluster,
    -2296            dialect=dialect,
    -2297            **opts,
    -2298        )
    -2299
    -2300    def limit(self, expression, dialect=None, copy=True, **opts) -> Select:
    -2301        """
    -2302        Set the LIMIT expression.
    -2303
    -2304        Example:
    -2305            >>> Select().from_("tbl").select("x").limit(10).sql()
    -2306            'SELECT x FROM tbl LIMIT 10'
    -2307
    -2308        Args:
    -2309            expression (str | int | Expression): the SQL code string to parse.
    -2310                This can also be an integer.
    -2311                If a `Limit` instance is passed, this is used as-is.
    -2312                If another `Expression` instance is passed, it will be wrapped in a `Limit`.
    -2313            dialect (str): the dialect used to parse the input expression.
    -2314            copy (bool): if `False`, modify this expression instance in-place.
    -2315            opts (kwargs): other options to use to parse the input expressions.
    -2316
    -2317        Returns:
    -2318            Select: the modified expression.
    -2319        """
    -2320        return _apply_builder(
    -2321            expression=expression,
    -2322            instance=self,
    -2323            arg="limit",
    -2324            into=Limit,
    -2325            prefix="LIMIT",
    -2326            dialect=dialect,
    -2327            copy=copy,
    -2328            **opts,
    -2329        )
    -2330
    -2331    def offset(self, expression, dialect=None, copy=True, **opts) -> Select:
    -2332        """
    -2333        Set the OFFSET expression.
    -2334
    -2335        Example:
    -2336            >>> Select().from_("tbl").select("x").offset(10).sql()
    -2337            'SELECT x FROM tbl OFFSET 10'
    -2338
    -2339        Args:
    -2340            expression (str | int | Expression): the SQL code string to parse.
    -2341                This can also be an integer.
    -2342                If a `Offset` instance is passed, this is used as-is.
    -2343                If another `Expression` instance is passed, it will be wrapped in a `Offset`.
    -2344            dialect (str): the dialect used to parse the input expression.
    -2345            copy (bool): if `False`, modify this expression instance in-place.
    -2346            opts (kwargs): other options to use to parse the input expressions.
    -2347
    -2348        Returns:
    -2349            Select: the modified expression.
    -2350        """
    -2351        return _apply_builder(
    -2352            expression=expression,
    -2353            instance=self,
    -2354            arg="offset",
    -2355            into=Offset,
    -2356            prefix="OFFSET",
    -2357            dialect=dialect,
    -2358            copy=copy,
    -2359            **opts,
    -2360        )
    -2361
    -2362    def select(
    -2363        self,
    -2364        *expressions: ExpOrStr,
    -2365        append: bool = True,
    -2366        dialect: DialectType = None,
    -2367        copy: bool = True,
    -2368        **opts,
    -2369    ) -> Select:
    -2370        """
    -2371        Append to or set the SELECT expressions.
    -2372
    -2373        Example:
    -2374            >>> Select().select("x", "y").sql()
    -2375            'SELECT x, y'
    -2376
    -2377        Args:
    -2378            *expressions: the SQL code strings to parse.
    -2379                If an `Expression` instance is passed, it will be used as-is.
    -2380            append: if `True`, add to any existing expressions.
    -2381                Otherwise, this resets the expressions.
    -2382            dialect: the dialect used to parse the input expressions.
    -2383            copy: if `False`, modify this expression instance in-place.
    -2384            opts: other options to use to parse the input expressions.
    -2385
    -2386        Returns:
    -2387            Select: the modified expression.
    -2388        """
    -2389        return _apply_list_builder(
    -2390            *expressions,
    -2391            instance=self,
    -2392            arg="expressions",
    -2393            append=append,
    -2394            dialect=dialect,
    -2395            copy=copy,
    -2396            **opts,
    -2397        )
    -2398
    -2399    def lateral(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2400        """
    -2401        Append to or set the LATERAL expressions.
    -2402
    -2403        Example:
    -2404            >>> Select().select("x").lateral("OUTER explode(y) tbl2 AS z").from_("tbl").sql()
    -2405            'SELECT x FROM tbl LATERAL VIEW OUTER EXPLODE(y) tbl2 AS z'
    -2406
    -2407        Args:
    -2408            *expressions (str | Expression): the SQL code strings to parse.
    -2409                If an `Expression` instance is passed, it will be used as-is.
    -2410            append (bool): if `True`, add to any existing expressions.
    -2411                Otherwise, this resets the expressions.
    -2412            dialect (str): the dialect used to parse the input expressions.
    -2413            copy (bool): if `False`, modify this expression instance in-place.
    -2414            opts (kwargs): other options to use to parse the input expressions.
    -2415
    -2416        Returns:
    -2417            Select: the modified expression.
    -2418        """
    -2419        return _apply_list_builder(
    -2420            *expressions,
    -2421            instance=self,
    -2422            arg="laterals",
    -2423            append=append,
    -2424            into=Lateral,
    -2425            prefix="LATERAL VIEW",
    -2426            dialect=dialect,
    -2427            copy=copy,
    -2428            **opts,
    -2429        )
    +            
    2243class Select(Subqueryable):
    +2244    arg_types = {
    +2245        "with": False,
    +2246        "kind": False,
    +2247        "expressions": False,
    +2248        "hint": False,
    +2249        "distinct": False,
    +2250        "into": False,
    +2251        "from": False,
    +2252        **QUERY_MODIFIERS,
    +2253    }
    +2254
    +2255    def from_(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2256        """
    +2257        Set the FROM expression.
    +2258
    +2259        Example:
    +2260            >>> Select().from_("tbl").select("x").sql()
    +2261            'SELECT x FROM tbl'
    +2262
    +2263        Args:
    +2264            *expressions (str | Expression): the SQL code strings to parse.
    +2265                If a `From` instance is passed, this is used as-is.
    +2266                If another `Expression` instance is passed, it will be wrapped in a `From`.
    +2267            append (bool): if `True`, add to any existing expressions.
    +2268                Otherwise, this flattens all the `From` expression into a single expression.
    +2269            dialect (str): the dialect used to parse the input expression.
    +2270            copy (bool): if `False`, modify this expression instance in-place.
    +2271            opts (kwargs): other options to use to parse the input expressions.
    +2272
    +2273        Returns:
    +2274            Select: the modified expression.
    +2275        """
    +2276        return _apply_child_list_builder(
    +2277            *expressions,
    +2278            instance=self,
    +2279            arg="from",
    +2280            append=append,
    +2281            copy=copy,
    +2282            prefix="FROM",
    +2283            into=From,
    +2284            dialect=dialect,
    +2285            **opts,
    +2286        )
    +2287
    +2288    def group_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2289        """
    +2290        Set the GROUP BY expression.
    +2291
    +2292        Example:
    +2293            >>> Select().from_("tbl").select("x", "COUNT(1)").group_by("x").sql()
    +2294            'SELECT x, COUNT(1) FROM tbl GROUP BY x'
    +2295
    +2296        Args:
    +2297            *expressions (str | Expression): the SQL code strings to parse.
    +2298                If a `Group` instance is passed, this is used as-is.
    +2299                If another `Expression` instance is passed, it will be wrapped in a `Group`.
    +2300                If nothing is passed in then a group by is not applied to the expression
    +2301            append (bool): if `True`, add to any existing expressions.
    +2302                Otherwise, this flattens all the `Group` expression into a single expression.
    +2303            dialect (str): the dialect used to parse the input expression.
    +2304            copy (bool): if `False`, modify this expression instance in-place.
    +2305            opts (kwargs): other options to use to parse the input expressions.
    +2306
    +2307        Returns:
    +2308            Select: the modified expression.
    +2309        """
    +2310        if not expressions:
    +2311            return self if not copy else self.copy()
    +2312        return _apply_child_list_builder(
    +2313            *expressions,
    +2314            instance=self,
    +2315            arg="group",
    +2316            append=append,
    +2317            copy=copy,
    +2318            prefix="GROUP BY",
    +2319            into=Group,
    +2320            dialect=dialect,
    +2321            **opts,
    +2322        )
    +2323
    +2324    def order_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2325        """
    +2326        Set the ORDER BY expression.
    +2327
    +2328        Example:
    +2329            >>> Select().from_("tbl").select("x").order_by("x DESC").sql()
    +2330            'SELECT x FROM tbl ORDER BY x DESC'
    +2331
    +2332        Args:
    +2333            *expressions (str | Expression): the SQL code strings to parse.
    +2334                If a `Group` instance is passed, this is used as-is.
    +2335                If another `Expression` instance is passed, it will be wrapped in a `Order`.
    +2336            append (bool): if `True`, add to any existing expressions.
    +2337                Otherwise, this flattens all the `Order` expression into a single expression.
    +2338            dialect (str): the dialect used to parse the input expression.
    +2339            copy (bool): if `False`, modify this expression instance in-place.
    +2340            opts (kwargs): other options to use to parse the input expressions.
    +2341
    +2342        Returns:
    +2343            Select: the modified expression.
    +2344        """
    +2345        return _apply_child_list_builder(
    +2346            *expressions,
    +2347            instance=self,
    +2348            arg="order",
    +2349            append=append,
    +2350            copy=copy,
    +2351            prefix="ORDER BY",
    +2352            into=Order,
    +2353            dialect=dialect,
    +2354            **opts,
    +2355        )
    +2356
    +2357    def sort_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2358        """
    +2359        Set the SORT BY expression.
    +2360
    +2361        Example:
    +2362            >>> Select().from_("tbl").select("x").sort_by("x DESC").sql()
    +2363            'SELECT x FROM tbl SORT BY x DESC'
    +2364
    +2365        Args:
    +2366            *expressions (str | Expression): the SQL code strings to parse.
    +2367                If a `Group` instance is passed, this is used as-is.
    +2368                If another `Expression` instance is passed, it will be wrapped in a `SORT`.
    +2369            append (bool): if `True`, add to any existing expressions.
    +2370                Otherwise, this flattens all the `Order` expression into a single expression.
    +2371            dialect (str): the dialect used to parse the input expression.
    +2372            copy (bool): if `False`, modify this expression instance in-place.
    +2373            opts (kwargs): other options to use to parse the input expressions.
    +2374
    +2375        Returns:
    +2376            Select: the modified expression.
    +2377        """
    +2378        return _apply_child_list_builder(
    +2379            *expressions,
    +2380            instance=self,
    +2381            arg="sort",
    +2382            append=append,
    +2383            copy=copy,
    +2384            prefix="SORT BY",
    +2385            into=Sort,
    +2386            dialect=dialect,
    +2387            **opts,
    +2388        )
    +2389
    +2390    def cluster_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2391        """
    +2392        Set the CLUSTER BY expression.
    +2393
    +2394        Example:
    +2395            >>> Select().from_("tbl").select("x").cluster_by("x DESC").sql()
    +2396            'SELECT x FROM tbl CLUSTER BY x DESC'
    +2397
    +2398        Args:
    +2399            *expressions (str | Expression): the SQL code strings to parse.
    +2400                If a `Group` instance is passed, this is used as-is.
    +2401                If another `Expression` instance is passed, it will be wrapped in a `Cluster`.
    +2402            append (bool): if `True`, add to any existing expressions.
    +2403                Otherwise, this flattens all the `Order` expression into a single expression.
    +2404            dialect (str): the dialect used to parse the input expression.
    +2405            copy (bool): if `False`, modify this expression instance in-place.
    +2406            opts (kwargs): other options to use to parse the input expressions.
    +2407
    +2408        Returns:
    +2409            Select: the modified expression.
    +2410        """
    +2411        return _apply_child_list_builder(
    +2412            *expressions,
    +2413            instance=self,
    +2414            arg="cluster",
    +2415            append=append,
    +2416            copy=copy,
    +2417            prefix="CLUSTER BY",
    +2418            into=Cluster,
    +2419            dialect=dialect,
    +2420            **opts,
    +2421        )
    +2422
    +2423    def limit(self, expression, dialect=None, copy=True, **opts) -> Select:
    +2424        """
    +2425        Set the LIMIT expression.
    +2426
    +2427        Example:
    +2428            >>> Select().from_("tbl").select("x").limit(10).sql()
    +2429            'SELECT x FROM tbl LIMIT 10'
     2430
    -2431    def join(
    -2432        self,
    -2433        expression,
    -2434        on=None,
    -2435        using=None,
    -2436        append=True,
    -2437        join_type=None,
    -2438        join_alias=None,
    -2439        dialect=None,
    -2440        copy=True,
    -2441        **opts,
    -2442    ) -> Select:
    -2443        """
    -2444        Append to or set the JOIN expressions.
    -2445
    -2446        Example:
    -2447            >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y").sql()
    -2448            'SELECT * FROM tbl JOIN tbl2 ON tbl1.y = tbl2.y'
    -2449
    -2450            >>> Select().select("1").from_("a").join("b", using=["x", "y", "z"]).sql()
    -2451            'SELECT 1 FROM a JOIN b USING (x, y, z)'
    -2452
    -2453            Use `join_type` to change the type of join:
    -2454
    -2455            >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y", join_type="left outer").sql()
    -2456            'SELECT * FROM tbl LEFT OUTER JOIN tbl2 ON tbl1.y = tbl2.y'
    +2431        Args:
    +2432            expression (str | int | Expression): the SQL code string to parse.
    +2433                This can also be an integer.
    +2434                If a `Limit` instance is passed, this is used as-is.
    +2435                If another `Expression` instance is passed, it will be wrapped in a `Limit`.
    +2436            dialect (str): the dialect used to parse the input expression.
    +2437            copy (bool): if `False`, modify this expression instance in-place.
    +2438            opts (kwargs): other options to use to parse the input expressions.
    +2439
    +2440        Returns:
    +2441            Select: the modified expression.
    +2442        """
    +2443        return _apply_builder(
    +2444            expression=expression,
    +2445            instance=self,
    +2446            arg="limit",
    +2447            into=Limit,
    +2448            prefix="LIMIT",
    +2449            dialect=dialect,
    +2450            copy=copy,
    +2451            **opts,
    +2452        )
    +2453
    +2454    def offset(self, expression, dialect=None, copy=True, **opts) -> Select:
    +2455        """
    +2456        Set the OFFSET expression.
     2457
    -2458        Args:
    -2459            expression (str | Expression): the SQL code string to parse.
    -2460                If an `Expression` instance is passed, it will be used as-is.
    -2461            on (str | Expression): optionally specify the join "on" criteria as a SQL string.
    -2462                If an `Expression` instance is passed, it will be used as-is.
    -2463            using (str | Expression): optionally specify the join "using" criteria as a SQL string.
    -2464                If an `Expression` instance is passed, it will be used as-is.
    -2465            append (bool): if `True`, add to any existing expressions.
    -2466                Otherwise, this resets the expressions.
    -2467            join_type (str): If set, alter the parsed join type
    -2468            dialect (str): the dialect used to parse the input expressions.
    -2469            copy (bool): if `False`, modify this expression instance in-place.
    -2470            opts (kwargs): other options to use to parse the input expressions.
    -2471
    -2472        Returns:
    -2473            Select: the modified expression.
    -2474        """
    -2475        parse_args = {"dialect": dialect, **opts}
    -2476
    -2477        try:
    -2478            expression = maybe_parse(expression, into=Join, prefix="JOIN", **parse_args)
    -2479        except ParseError:
    -2480            expression = maybe_parse(expression, into=(Join, Expression), **parse_args)
    -2481
    -2482        join = expression if isinstance(expression, Join) else Join(this=expression)
    -2483
    -2484        if isinstance(join.this, Select):
    -2485            join.this.replace(join.this.subquery())
    -2486
    -2487        if join_type:
    -2488            natural: t.Optional[Token]
    -2489            side: t.Optional[Token]
    -2490            kind: t.Optional[Token]
    -2491
    -2492            natural, side, kind = maybe_parse(join_type, into="JOIN_TYPE", **parse_args)  # type: ignore
    -2493
    -2494            if natural:
    -2495                join.set("natural", True)
    -2496            if side:
    -2497                join.set("side", side.text)
    -2498            if kind:
    -2499                join.set("kind", kind.text)
    -2500
    -2501        if on:
    -2502            on = and_(*ensure_collection(on), dialect=dialect, **opts)
    -2503            join.set("on", on)
    -2504
    -2505        if using:
    -2506            join = _apply_list_builder(
    -2507                *ensure_collection(using),
    -2508                instance=join,
    -2509                arg="using",
    -2510                append=append,
    -2511                copy=copy,
    -2512                **opts,
    -2513            )
    -2514
    -2515        if join_alias:
    -2516            join.set("this", alias_(join.this, join_alias, table=True))
    -2517        return _apply_list_builder(
    -2518            join,
    -2519            instance=self,
    -2520            arg="joins",
    -2521            append=append,
    -2522            copy=copy,
    -2523            **opts,
    -2524        )
    +2458        Example:
    +2459            >>> Select().from_("tbl").select("x").offset(10).sql()
    +2460            'SELECT x FROM tbl OFFSET 10'
    +2461
    +2462        Args:
    +2463            expression (str | int | Expression): the SQL code string to parse.
    +2464                This can also be an integer.
    +2465                If a `Offset` instance is passed, this is used as-is.
    +2466                If another `Expression` instance is passed, it will be wrapped in a `Offset`.
    +2467            dialect (str): the dialect used to parse the input expression.
    +2468            copy (bool): if `False`, modify this expression instance in-place.
    +2469            opts (kwargs): other options to use to parse the input expressions.
    +2470
    +2471        Returns:
    +2472            Select: the modified expression.
    +2473        """
    +2474        return _apply_builder(
    +2475            expression=expression,
    +2476            instance=self,
    +2477            arg="offset",
    +2478            into=Offset,
    +2479            prefix="OFFSET",
    +2480            dialect=dialect,
    +2481            copy=copy,
    +2482            **opts,
    +2483        )
    +2484
    +2485    def select(
    +2486        self,
    +2487        *expressions: ExpOrStr,
    +2488        append: bool = True,
    +2489        dialect: DialectType = None,
    +2490        copy: bool = True,
    +2491        **opts,
    +2492    ) -> Select:
    +2493        """
    +2494        Append to or set the SELECT expressions.
    +2495
    +2496        Example:
    +2497            >>> Select().select("x", "y").sql()
    +2498            'SELECT x, y'
    +2499
    +2500        Args:
    +2501            *expressions: the SQL code strings to parse.
    +2502                If an `Expression` instance is passed, it will be used as-is.
    +2503            append: if `True`, add to any existing expressions.
    +2504                Otherwise, this resets the expressions.
    +2505            dialect: the dialect used to parse the input expressions.
    +2506            copy: if `False`, modify this expression instance in-place.
    +2507            opts: other options to use to parse the input expressions.
    +2508
    +2509        Returns:
    +2510            Select: the modified expression.
    +2511        """
    +2512        return _apply_list_builder(
    +2513            *expressions,
    +2514            instance=self,
    +2515            arg="expressions",
    +2516            append=append,
    +2517            dialect=dialect,
    +2518            copy=copy,
    +2519            **opts,
    +2520        )
    +2521
    +2522    def lateral(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2523        """
    +2524        Append to or set the LATERAL expressions.
     2525
    -2526    def where(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2527        """
    -2528        Append to or set the WHERE expressions.
    +2526        Example:
    +2527            >>> Select().select("x").lateral("OUTER explode(y) tbl2 AS z").from_("tbl").sql()
    +2528            'SELECT x FROM tbl LATERAL VIEW OUTER EXPLODE(y) tbl2 AS z'
     2529
    -2530        Example:
    -2531            >>> Select().select("x").from_("tbl").where("x = 'a' OR x < 'b'").sql()
    -2532            "SELECT x FROM tbl WHERE x = 'a' OR x < 'b'"
    -2533
    -2534        Args:
    -2535            *expressions (str | Expression): the SQL code strings to parse.
    -2536                If an `Expression` instance is passed, it will be used as-is.
    -2537                Multiple expressions are combined with an AND operator.
    -2538            append (bool): if `True`, AND the new expressions to any existing expression.
    -2539                Otherwise, this resets the expression.
    -2540            dialect (str): the dialect used to parse the input expressions.
    -2541            copy (bool): if `False`, modify this expression instance in-place.
    -2542            opts (kwargs): other options to use to parse the input expressions.
    -2543
    -2544        Returns:
    -2545            Select: the modified expression.
    -2546        """
    -2547        return _apply_conjunction_builder(
    -2548            *expressions,
    -2549            instance=self,
    -2550            arg="where",
    -2551            append=append,
    -2552            into=Where,
    -2553            dialect=dialect,
    -2554            copy=copy,
    -2555            **opts,
    -2556        )
    -2557
    -2558    def having(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2559        """
    -2560        Append to or set the HAVING expressions.
    -2561
    -2562        Example:
    -2563            >>> Select().select("x", "COUNT(y)").from_("tbl").group_by("x").having("COUNT(y) > 3").sql()
    -2564            'SELECT x, COUNT(y) FROM tbl GROUP BY x HAVING COUNT(y) > 3'
    -2565
    -2566        Args:
    -2567            *expressions (str | Expression): the SQL code strings to parse.
    -2568                If an `Expression` instance is passed, it will be used as-is.
    -2569                Multiple expressions are combined with an AND operator.
    -2570            append (bool): if `True`, AND the new expressions to any existing expression.
    -2571                Otherwise, this resets the expression.
    -2572            dialect (str): the dialect used to parse the input expressions.
    -2573            copy (bool): if `False`, modify this expression instance in-place.
    -2574            opts (kwargs): other options to use to parse the input expressions.
    +2530        Args:
    +2531            *expressions (str | Expression): the SQL code strings to parse.
    +2532                If an `Expression` instance is passed, it will be used as-is.
    +2533            append (bool): if `True`, add to any existing expressions.
    +2534                Otherwise, this resets the expressions.
    +2535            dialect (str): the dialect used to parse the input expressions.
    +2536            copy (bool): if `False`, modify this expression instance in-place.
    +2537            opts (kwargs): other options to use to parse the input expressions.
    +2538
    +2539        Returns:
    +2540            Select: the modified expression.
    +2541        """
    +2542        return _apply_list_builder(
    +2543            *expressions,
    +2544            instance=self,
    +2545            arg="laterals",
    +2546            append=append,
    +2547            into=Lateral,
    +2548            prefix="LATERAL VIEW",
    +2549            dialect=dialect,
    +2550            copy=copy,
    +2551            **opts,
    +2552        )
    +2553
    +2554    def join(
    +2555        self,
    +2556        expression,
    +2557        on=None,
    +2558        using=None,
    +2559        append=True,
    +2560        join_type=None,
    +2561        join_alias=None,
    +2562        dialect=None,
    +2563        copy=True,
    +2564        **opts,
    +2565    ) -> Select:
    +2566        """
    +2567        Append to or set the JOIN expressions.
    +2568
    +2569        Example:
    +2570            >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y").sql()
    +2571            'SELECT * FROM tbl JOIN tbl2 ON tbl1.y = tbl2.y'
    +2572
    +2573            >>> Select().select("1").from_("a").join("b", using=["x", "y", "z"]).sql()
    +2574            'SELECT 1 FROM a JOIN b USING (x, y, z)'
     2575
    -2576        Returns:
    -2577            Select: the modified expression.
    -2578        """
    -2579        return _apply_conjunction_builder(
    -2580            *expressions,
    -2581            instance=self,
    -2582            arg="having",
    -2583            append=append,
    -2584            into=Having,
    -2585            dialect=dialect,
    -2586            copy=copy,
    -2587            **opts,
    -2588        )
    -2589
    -2590    def window(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2591        return _apply_list_builder(
    -2592            *expressions,
    -2593            instance=self,
    -2594            arg="windows",
    -2595            append=append,
    -2596            into=Window,
    -2597            dialect=dialect,
    -2598            copy=copy,
    -2599            **opts,
    -2600        )
    -2601
    -2602    def qualify(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2603        return _apply_conjunction_builder(
    -2604            *expressions,
    -2605            instance=self,
    -2606            arg="qualify",
    -2607            append=append,
    -2608            into=Qualify,
    -2609            dialect=dialect,
    -2610            copy=copy,
    -2611            **opts,
    -2612        )
    -2613
    -2614    def distinct(self, distinct=True, copy=True) -> Select:
    -2615        """
    -2616        Set the OFFSET expression.
    -2617
    -2618        Example:
    -2619            >>> Select().from_("tbl").select("x").distinct().sql()
    -2620            'SELECT DISTINCT x FROM tbl'
    -2621
    -2622        Args:
    -2623            distinct (bool): whether the Select should be distinct
    -2624            copy (bool): if `False`, modify this expression instance in-place.
    -2625
    -2626        Returns:
    -2627            Select: the modified expression.
    -2628        """
    -2629        instance = _maybe_copy(self, copy)
    -2630        instance.set("distinct", Distinct() if distinct else None)
    -2631        return instance
    -2632
    -2633    def ctas(self, table, properties=None, dialect=None, copy=True, **opts) -> Create:
    -2634        """
    -2635        Convert this expression to a CREATE TABLE AS statement.
    -2636
    -2637        Example:
    -2638            >>> Select().select("*").from_("tbl").ctas("x").sql()
    -2639            'CREATE TABLE x AS SELECT * FROM tbl'
    -2640
    -2641        Args:
    -2642            table (str | Expression): the SQL code string to parse as the table name.
    -2643                If another `Expression` instance is passed, it will be used as-is.
    -2644            properties (dict): an optional mapping of table properties
    -2645            dialect (str): the dialect used to parse the input table.
    -2646            copy (bool): if `False`, modify this expression instance in-place.
    -2647            opts (kwargs): other options to use to parse the input table.
    +2576            Use `join_type` to change the type of join:
    +2577
    +2578            >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y", join_type="left outer").sql()
    +2579            'SELECT * FROM tbl LEFT OUTER JOIN tbl2 ON tbl1.y = tbl2.y'
    +2580
    +2581        Args:
    +2582            expression (str | Expression): the SQL code string to parse.
    +2583                If an `Expression` instance is passed, it will be used as-is.
    +2584            on (str | Expression): optionally specify the join "on" criteria as a SQL string.
    +2585                If an `Expression` instance is passed, it will be used as-is.
    +2586            using (str | Expression): optionally specify the join "using" criteria as a SQL string.
    +2587                If an `Expression` instance is passed, it will be used as-is.
    +2588            append (bool): if `True`, add to any existing expressions.
    +2589                Otherwise, this resets the expressions.
    +2590            join_type (str): If set, alter the parsed join type
    +2591            dialect (str): the dialect used to parse the input expressions.
    +2592            copy (bool): if `False`, modify this expression instance in-place.
    +2593            opts (kwargs): other options to use to parse the input expressions.
    +2594
    +2595        Returns:
    +2596            Select: the modified expression.
    +2597        """
    +2598        parse_args = {"dialect": dialect, **opts}
    +2599
    +2600        try:
    +2601            expression = maybe_parse(expression, into=Join, prefix="JOIN", **parse_args)
    +2602        except ParseError:
    +2603            expression = maybe_parse(expression, into=(Join, Expression), **parse_args)
    +2604
    +2605        join = expression if isinstance(expression, Join) else Join(this=expression)
    +2606
    +2607        if isinstance(join.this, Select):
    +2608            join.this.replace(join.this.subquery())
    +2609
    +2610        if join_type:
    +2611            natural: t.Optional[Token]
    +2612            side: t.Optional[Token]
    +2613            kind: t.Optional[Token]
    +2614
    +2615            natural, side, kind = maybe_parse(join_type, into="JOIN_TYPE", **parse_args)  # type: ignore
    +2616
    +2617            if natural:
    +2618                join.set("natural", True)
    +2619            if side:
    +2620                join.set("side", side.text)
    +2621            if kind:
    +2622                join.set("kind", kind.text)
    +2623
    +2624        if on:
    +2625            on = and_(*ensure_collection(on), dialect=dialect, copy=copy, **opts)
    +2626            join.set("on", on)
    +2627
    +2628        if using:
    +2629            join = _apply_list_builder(
    +2630                *ensure_collection(using),
    +2631                instance=join,
    +2632                arg="using",
    +2633                append=append,
    +2634                copy=copy,
    +2635                **opts,
    +2636            )
    +2637
    +2638        if join_alias:
    +2639            join.set("this", alias_(join.this, join_alias, table=True))
    +2640        return _apply_list_builder(
    +2641            join,
    +2642            instance=self,
    +2643            arg="joins",
    +2644            append=append,
    +2645            copy=copy,
    +2646            **opts,
    +2647        )
     2648
    -2649        Returns:
    -2650            Create: the CREATE TABLE AS expression
    -2651        """
    -2652        instance = _maybe_copy(self, copy)
    -2653        table_expression = maybe_parse(
    -2654            table,
    -2655            into=Table,
    -2656            dialect=dialect,
    -2657            **opts,
    -2658        )
    -2659        properties_expression = None
    -2660        if properties:
    -2661            properties_expression = Properties.from_dict(properties)
    -2662
    -2663        return Create(
    -2664            this=table_expression,
    -2665            kind="table",
    -2666            expression=instance,
    -2667            properties=properties_expression,
    -2668        )
    -2669
    -2670    def lock(self, update: bool = True, copy: bool = True) -> Select:
    -2671        """
    -2672        Set the locking read mode for this expression.
    -2673
    -2674        Examples:
    -2675            >>> Select().select("x").from_("tbl").where("x = 'a'").lock().sql("mysql")
    -2676            "SELECT x FROM tbl WHERE x = 'a' FOR UPDATE"
    -2677
    -2678            >>> Select().select("x").from_("tbl").where("x = 'a'").lock(update=False).sql("mysql")
    -2679            "SELECT x FROM tbl WHERE x = 'a' FOR SHARE"
    +2649    def where(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2650        """
    +2651        Append to or set the WHERE expressions.
    +2652
    +2653        Example:
    +2654            >>> Select().select("x").from_("tbl").where("x = 'a' OR x < 'b'").sql()
    +2655            "SELECT x FROM tbl WHERE x = 'a' OR x < 'b'"
    +2656
    +2657        Args:
    +2658            *expressions (str | Expression): the SQL code strings to parse.
    +2659                If an `Expression` instance is passed, it will be used as-is.
    +2660                Multiple expressions are combined with an AND operator.
    +2661            append (bool): if `True`, AND the new expressions to any existing expression.
    +2662                Otherwise, this resets the expression.
    +2663            dialect (str): the dialect used to parse the input expressions.
    +2664            copy (bool): if `False`, modify this expression instance in-place.
    +2665            opts (kwargs): other options to use to parse the input expressions.
    +2666
    +2667        Returns:
    +2668            Select: the modified expression.
    +2669        """
    +2670        return _apply_conjunction_builder(
    +2671            *expressions,
    +2672            instance=self,
    +2673            arg="where",
    +2674            append=append,
    +2675            into=Where,
    +2676            dialect=dialect,
    +2677            copy=copy,
    +2678            **opts,
    +2679        )
     2680
    -2681        Args:
    -2682            update: if `True`, the locking type will be `FOR UPDATE`, else it will be `FOR SHARE`.
    -2683            copy: if `False`, modify this expression instance in-place.
    +2681    def having(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2682        """
    +2683        Append to or set the HAVING expressions.
     2684
    -2685        Returns:
    -2686            The modified expression.
    -2687        """
    +2685        Example:
    +2686            >>> Select().select("x", "COUNT(y)").from_("tbl").group_by("x").having("COUNT(y) > 3").sql()
    +2687            'SELECT x, COUNT(y) FROM tbl GROUP BY x HAVING COUNT(y) > 3'
     2688
    -2689        inst = _maybe_copy(self, copy)
    -2690        inst.set("lock", Lock(update=update))
    -2691
    -2692        return inst
    -2693
    -2694    @property
    -2695    def named_selects(self) -> t.List[str]:
    -2696        return [e.output_name for e in self.expressions if e.alias_or_name]
    -2697
    -2698    @property
    -2699    def is_star(self) -> bool:
    -2700        return any(expression.is_star for expression in self.expressions)
    -2701
    -2702    @property
    -2703    def selects(self) -> t.List[Expression]:
    -2704        return self.expressions
    +2689        Args:
    +2690            *expressions (str | Expression): the SQL code strings to parse.
    +2691                If an `Expression` instance is passed, it will be used as-is.
    +2692                Multiple expressions are combined with an AND operator.
    +2693            append (bool): if `True`, AND the new expressions to any existing expression.
    +2694                Otherwise, this resets the expression.
    +2695            dialect (str): the dialect used to parse the input expressions.
    +2696            copy (bool): if `False`, modify this expression instance in-place.
    +2697            opts (kwargs): other options to use to parse the input expressions.
    +2698
    +2699        Returns:
    +2700            Select: the modified expression.
    +2701        """
    +2702        return _apply_conjunction_builder(
    +2703            *expressions,
    +2704            instance=self,
    +2705            arg="having",
    +2706            append=append,
    +2707            into=Having,
    +2708            dialect=dialect,
    +2709            copy=copy,
    +2710            **opts,
    +2711        )
    +2712
    +2713    def window(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2714        return _apply_list_builder(
    +2715            *expressions,
    +2716            instance=self,
    +2717            arg="windows",
    +2718            append=append,
    +2719            into=Window,
    +2720            dialect=dialect,
    +2721            copy=copy,
    +2722            **opts,
    +2723        )
    +2724
    +2725    def qualify(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2726        return _apply_conjunction_builder(
    +2727            *expressions,
    +2728            instance=self,
    +2729            arg="qualify",
    +2730            append=append,
    +2731            into=Qualify,
    +2732            dialect=dialect,
    +2733            copy=copy,
    +2734            **opts,
    +2735        )
    +2736
    +2737    def distinct(self, *ons: ExpOrStr, distinct: bool = True, copy: bool = True) -> Select:
    +2738        """
    +2739        Set the OFFSET expression.
    +2740
    +2741        Example:
    +2742            >>> Select().from_("tbl").select("x").distinct().sql()
    +2743            'SELECT DISTINCT x FROM tbl'
    +2744
    +2745        Args:
    +2746            ons: the expressions to distinct on
    +2747            distinct: whether the Select should be distinct
    +2748            copy: if `False`, modify this expression instance in-place.
    +2749
    +2750        Returns:
    +2751            Select: the modified expression.
    +2752        """
    +2753        instance = _maybe_copy(self, copy)
    +2754        on = Tuple(expressions=[maybe_parse(on, copy=copy) for on in ons]) if ons else None
    +2755        instance.set("distinct", Distinct(on=on) if distinct else None)
    +2756        return instance
    +2757
    +2758    def ctas(self, table, properties=None, dialect=None, copy=True, **opts) -> Create:
    +2759        """
    +2760        Convert this expression to a CREATE TABLE AS statement.
    +2761
    +2762        Example:
    +2763            >>> Select().select("*").from_("tbl").ctas("x").sql()
    +2764            'CREATE TABLE x AS SELECT * FROM tbl'
    +2765
    +2766        Args:
    +2767            table (str | Expression): the SQL code string to parse as the table name.
    +2768                If another `Expression` instance is passed, it will be used as-is.
    +2769            properties (dict): an optional mapping of table properties
    +2770            dialect (str): the dialect used to parse the input table.
    +2771            copy (bool): if `False`, modify this expression instance in-place.
    +2772            opts (kwargs): other options to use to parse the input table.
    +2773
    +2774        Returns:
    +2775            Create: the CREATE TABLE AS expression
    +2776        """
    +2777        instance = _maybe_copy(self, copy)
    +2778        table_expression = maybe_parse(
    +2779            table,
    +2780            into=Table,
    +2781            dialect=dialect,
    +2782            **opts,
    +2783        )
    +2784        properties_expression = None
    +2785        if properties:
    +2786            properties_expression = Properties.from_dict(properties)
    +2787
    +2788        return Create(
    +2789            this=table_expression,
    +2790            kind="table",
    +2791            expression=instance,
    +2792            properties=properties_expression,
    +2793        )
    +2794
    +2795    def lock(self, update: bool = True, copy: bool = True) -> Select:
    +2796        """
    +2797        Set the locking read mode for this expression.
    +2798
    +2799        Examples:
    +2800            >>> Select().select("x").from_("tbl").where("x = 'a'").lock().sql("mysql")
    +2801            "SELECT x FROM tbl WHERE x = 'a' FOR UPDATE"
    +2802
    +2803            >>> Select().select("x").from_("tbl").where("x = 'a'").lock(update=False).sql("mysql")
    +2804            "SELECT x FROM tbl WHERE x = 'a' FOR SHARE"
    +2805
    +2806        Args:
    +2807            update: if `True`, the locking type will be `FOR UPDATE`, else it will be `FOR SHARE`.
    +2808            copy: if `False`, modify this expression instance in-place.
    +2809
    +2810        Returns:
    +2811            The modified expression.
    +2812        """
    +2813
    +2814        inst = _maybe_copy(self, copy)
    +2815        inst.set("lock", Lock(update=update))
    +2816
    +2817        return inst
    +2818
    +2819    @property
    +2820    def named_selects(self) -> t.List[str]:
    +2821        return [e.output_name for e in self.expressions if e.alias_or_name]
    +2822
    +2823    @property
    +2824    def is_star(self) -> bool:
    +2825        return any(expression.is_star for expression in self.expressions)
    +2826
    +2827    @property
    +2828    def selects(self) -> t.List[Expression]:
    +2829        return self.expressions
     
    @@ -22844,38 +23346,38 @@ Otherwise, this resets the expressions.
    -
    2132    def from_(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2133        """
    -2134        Set the FROM expression.
    -2135
    -2136        Example:
    -2137            >>> Select().from_("tbl").select("x").sql()
    -2138            'SELECT x FROM tbl'
    -2139
    -2140        Args:
    -2141            *expressions (str | Expression): the SQL code strings to parse.
    -2142                If a `From` instance is passed, this is used as-is.
    -2143                If another `Expression` instance is passed, it will be wrapped in a `From`.
    -2144            append (bool): if `True`, add to any existing expressions.
    -2145                Otherwise, this flattens all the `From` expression into a single expression.
    -2146            dialect (str): the dialect used to parse the input expression.
    -2147            copy (bool): if `False`, modify this expression instance in-place.
    -2148            opts (kwargs): other options to use to parse the input expressions.
    -2149
    -2150        Returns:
    -2151            Select: the modified expression.
    -2152        """
    -2153        return _apply_child_list_builder(
    -2154            *expressions,
    -2155            instance=self,
    -2156            arg="from",
    -2157            append=append,
    -2158            copy=copy,
    -2159            prefix="FROM",
    -2160            into=From,
    -2161            dialect=dialect,
    -2162            **opts,
    -2163        )
    +            
    2255    def from_(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2256        """
    +2257        Set the FROM expression.
    +2258
    +2259        Example:
    +2260            >>> Select().from_("tbl").select("x").sql()
    +2261            'SELECT x FROM tbl'
    +2262
    +2263        Args:
    +2264            *expressions (str | Expression): the SQL code strings to parse.
    +2265                If a `From` instance is passed, this is used as-is.
    +2266                If another `Expression` instance is passed, it will be wrapped in a `From`.
    +2267            append (bool): if `True`, add to any existing expressions.
    +2268                Otherwise, this flattens all the `From` expression into a single expression.
    +2269            dialect (str): the dialect used to parse the input expression.
    +2270            copy (bool): if `False`, modify this expression instance in-place.
    +2271            opts (kwargs): other options to use to parse the input expressions.
    +2272
    +2273        Returns:
    +2274            Select: the modified expression.
    +2275        """
    +2276        return _apply_child_list_builder(
    +2277            *expressions,
    +2278            instance=self,
    +2279            arg="from",
    +2280            append=append,
    +2281            copy=copy,
    +2282            prefix="FROM",
    +2283            into=From,
    +2284            dialect=dialect,
    +2285            **opts,
    +2286        )
     
    @@ -22924,41 +23426,41 @@ Otherwise, this flattens all the From expressio
    -
    2165    def group_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2166        """
    -2167        Set the GROUP BY expression.
    -2168
    -2169        Example:
    -2170            >>> Select().from_("tbl").select("x", "COUNT(1)").group_by("x").sql()
    -2171            'SELECT x, COUNT(1) FROM tbl GROUP BY x'
    -2172
    -2173        Args:
    -2174            *expressions (str | Expression): the SQL code strings to parse.
    -2175                If a `Group` instance is passed, this is used as-is.
    -2176                If another `Expression` instance is passed, it will be wrapped in a `Group`.
    -2177                If nothing is passed in then a group by is not applied to the expression
    -2178            append (bool): if `True`, add to any existing expressions.
    -2179                Otherwise, this flattens all the `Group` expression into a single expression.
    -2180            dialect (str): the dialect used to parse the input expression.
    -2181            copy (bool): if `False`, modify this expression instance in-place.
    -2182            opts (kwargs): other options to use to parse the input expressions.
    -2183
    -2184        Returns:
    -2185            Select: the modified expression.
    -2186        """
    -2187        if not expressions:
    -2188            return self if not copy else self.copy()
    -2189        return _apply_child_list_builder(
    -2190            *expressions,
    -2191            instance=self,
    -2192            arg="group",
    -2193            append=append,
    -2194            copy=copy,
    -2195            prefix="GROUP BY",
    -2196            into=Group,
    -2197            dialect=dialect,
    -2198            **opts,
    -2199        )
    +            
    2288    def group_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2289        """
    +2290        Set the GROUP BY expression.
    +2291
    +2292        Example:
    +2293            >>> Select().from_("tbl").select("x", "COUNT(1)").group_by("x").sql()
    +2294            'SELECT x, COUNT(1) FROM tbl GROUP BY x'
    +2295
    +2296        Args:
    +2297            *expressions (str | Expression): the SQL code strings to parse.
    +2298                If a `Group` instance is passed, this is used as-is.
    +2299                If another `Expression` instance is passed, it will be wrapped in a `Group`.
    +2300                If nothing is passed in then a group by is not applied to the expression
    +2301            append (bool): if `True`, add to any existing expressions.
    +2302                Otherwise, this flattens all the `Group` expression into a single expression.
    +2303            dialect (str): the dialect used to parse the input expression.
    +2304            copy (bool): if `False`, modify this expression instance in-place.
    +2305            opts (kwargs): other options to use to parse the input expressions.
    +2306
    +2307        Returns:
    +2308            Select: the modified expression.
    +2309        """
    +2310        if not expressions:
    +2311            return self if not copy else self.copy()
    +2312        return _apply_child_list_builder(
    +2313            *expressions,
    +2314            instance=self,
    +2315            arg="group",
    +2316            append=append,
    +2317            copy=copy,
    +2318            prefix="GROUP BY",
    +2319            into=Group,
    +2320            dialect=dialect,
    +2321            **opts,
    +2322        )
     
    @@ -23008,38 +23510,38 @@ Otherwise, this flattens all the Group express
    -
    2201    def order_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2202        """
    -2203        Set the ORDER BY expression.
    -2204
    -2205        Example:
    -2206            >>> Select().from_("tbl").select("x").order_by("x DESC").sql()
    -2207            'SELECT x FROM tbl ORDER BY x DESC'
    -2208
    -2209        Args:
    -2210            *expressions (str | Expression): the SQL code strings to parse.
    -2211                If a `Group` instance is passed, this is used as-is.
    -2212                If another `Expression` instance is passed, it will be wrapped in a `Order`.
    -2213            append (bool): if `True`, add to any existing expressions.
    -2214                Otherwise, this flattens all the `Order` expression into a single expression.
    -2215            dialect (str): the dialect used to parse the input expression.
    -2216            copy (bool): if `False`, modify this expression instance in-place.
    -2217            opts (kwargs): other options to use to parse the input expressions.
    -2218
    -2219        Returns:
    -2220            Select: the modified expression.
    -2221        """
    -2222        return _apply_child_list_builder(
    -2223            *expressions,
    -2224            instance=self,
    -2225            arg="order",
    -2226            append=append,
    -2227            copy=copy,
    -2228            prefix="ORDER BY",
    -2229            into=Order,
    -2230            dialect=dialect,
    -2231            **opts,
    -2232        )
    +            
    2324    def order_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2325        """
    +2326        Set the ORDER BY expression.
    +2327
    +2328        Example:
    +2329            >>> Select().from_("tbl").select("x").order_by("x DESC").sql()
    +2330            'SELECT x FROM tbl ORDER BY x DESC'
    +2331
    +2332        Args:
    +2333            *expressions (str | Expression): the SQL code strings to parse.
    +2334                If a `Group` instance is passed, this is used as-is.
    +2335                If another `Expression` instance is passed, it will be wrapped in a `Order`.
    +2336            append (bool): if `True`, add to any existing expressions.
    +2337                Otherwise, this flattens all the `Order` expression into a single expression.
    +2338            dialect (str): the dialect used to parse the input expression.
    +2339            copy (bool): if `False`, modify this expression instance in-place.
    +2340            opts (kwargs): other options to use to parse the input expressions.
    +2341
    +2342        Returns:
    +2343            Select: the modified expression.
    +2344        """
    +2345        return _apply_child_list_builder(
    +2346            *expressions,
    +2347            instance=self,
    +2348            arg="order",
    +2349            append=append,
    +2350            copy=copy,
    +2351            prefix="ORDER BY",
    +2352            into=Order,
    +2353            dialect=dialect,
    +2354            **opts,
    +2355        )
     
    @@ -23088,38 +23590,38 @@ Otherwise, this flattens all the Order express
    -
    2234    def sort_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2235        """
    -2236        Set the SORT BY expression.
    -2237
    -2238        Example:
    -2239            >>> Select().from_("tbl").select("x").sort_by("x DESC").sql()
    -2240            'SELECT x FROM tbl SORT BY x DESC'
    -2241
    -2242        Args:
    -2243            *expressions (str | Expression): the SQL code strings to parse.
    -2244                If a `Group` instance is passed, this is used as-is.
    -2245                If another `Expression` instance is passed, it will be wrapped in a `SORT`.
    -2246            append (bool): if `True`, add to any existing expressions.
    -2247                Otherwise, this flattens all the `Order` expression into a single expression.
    -2248            dialect (str): the dialect used to parse the input expression.
    -2249            copy (bool): if `False`, modify this expression instance in-place.
    -2250            opts (kwargs): other options to use to parse the input expressions.
    -2251
    -2252        Returns:
    -2253            Select: the modified expression.
    -2254        """
    -2255        return _apply_child_list_builder(
    -2256            *expressions,
    -2257            instance=self,
    -2258            arg="sort",
    -2259            append=append,
    -2260            copy=copy,
    -2261            prefix="SORT BY",
    -2262            into=Sort,
    -2263            dialect=dialect,
    -2264            **opts,
    -2265        )
    +            
    2357    def sort_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2358        """
    +2359        Set the SORT BY expression.
    +2360
    +2361        Example:
    +2362            >>> Select().from_("tbl").select("x").sort_by("x DESC").sql()
    +2363            'SELECT x FROM tbl SORT BY x DESC'
    +2364
    +2365        Args:
    +2366            *expressions (str | Expression): the SQL code strings to parse.
    +2367                If a `Group` instance is passed, this is used as-is.
    +2368                If another `Expression` instance is passed, it will be wrapped in a `SORT`.
    +2369            append (bool): if `True`, add to any existing expressions.
    +2370                Otherwise, this flattens all the `Order` expression into a single expression.
    +2371            dialect (str): the dialect used to parse the input expression.
    +2372            copy (bool): if `False`, modify this expression instance in-place.
    +2373            opts (kwargs): other options to use to parse the input expressions.
    +2374
    +2375        Returns:
    +2376            Select: the modified expression.
    +2377        """
    +2378        return _apply_child_list_builder(
    +2379            *expressions,
    +2380            instance=self,
    +2381            arg="sort",
    +2382            append=append,
    +2383            copy=copy,
    +2384            prefix="SORT BY",
    +2385            into=Sort,
    +2386            dialect=dialect,
    +2387            **opts,
    +2388        )
     
    @@ -23168,38 +23670,38 @@ Otherwise, this flattens all the Order express
    -
    2267    def cluster_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2268        """
    -2269        Set the CLUSTER BY expression.
    -2270
    -2271        Example:
    -2272            >>> Select().from_("tbl").select("x").cluster_by("x DESC").sql()
    -2273            'SELECT x FROM tbl CLUSTER BY x DESC'
    -2274
    -2275        Args:
    -2276            *expressions (str | Expression): the SQL code strings to parse.
    -2277                If a `Group` instance is passed, this is used as-is.
    -2278                If another `Expression` instance is passed, it will be wrapped in a `Cluster`.
    -2279            append (bool): if `True`, add to any existing expressions.
    -2280                Otherwise, this flattens all the `Order` expression into a single expression.
    -2281            dialect (str): the dialect used to parse the input expression.
    -2282            copy (bool): if `False`, modify this expression instance in-place.
    -2283            opts (kwargs): other options to use to parse the input expressions.
    -2284
    -2285        Returns:
    -2286            Select: the modified expression.
    -2287        """
    -2288        return _apply_child_list_builder(
    -2289            *expressions,
    -2290            instance=self,
    -2291            arg="cluster",
    -2292            append=append,
    -2293            copy=copy,
    -2294            prefix="CLUSTER BY",
    -2295            into=Cluster,
    -2296            dialect=dialect,
    -2297            **opts,
    -2298        )
    +            
    2390    def cluster_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2391        """
    +2392        Set the CLUSTER BY expression.
    +2393
    +2394        Example:
    +2395            >>> Select().from_("tbl").select("x").cluster_by("x DESC").sql()
    +2396            'SELECT x FROM tbl CLUSTER BY x DESC'
    +2397
    +2398        Args:
    +2399            *expressions (str | Expression): the SQL code strings to parse.
    +2400                If a `Group` instance is passed, this is used as-is.
    +2401                If another `Expression` instance is passed, it will be wrapped in a `Cluster`.
    +2402            append (bool): if `True`, add to any existing expressions.
    +2403                Otherwise, this flattens all the `Order` expression into a single expression.
    +2404            dialect (str): the dialect used to parse the input expression.
    +2405            copy (bool): if `False`, modify this expression instance in-place.
    +2406            opts (kwargs): other options to use to parse the input expressions.
    +2407
    +2408        Returns:
    +2409            Select: the modified expression.
    +2410        """
    +2411        return _apply_child_list_builder(
    +2412            *expressions,
    +2413            instance=self,
    +2414            arg="cluster",
    +2415            append=append,
    +2416            copy=copy,
    +2417            prefix="CLUSTER BY",
    +2418            into=Cluster,
    +2419            dialect=dialect,
    +2420            **opts,
    +2421        )
     
    @@ -23248,36 +23750,36 @@ Otherwise, this flattens all the Order express
    -
    2300    def limit(self, expression, dialect=None, copy=True, **opts) -> Select:
    -2301        """
    -2302        Set the LIMIT expression.
    -2303
    -2304        Example:
    -2305            >>> Select().from_("tbl").select("x").limit(10).sql()
    -2306            'SELECT x FROM tbl LIMIT 10'
    -2307
    -2308        Args:
    -2309            expression (str | int | Expression): the SQL code string to parse.
    -2310                This can also be an integer.
    -2311                If a `Limit` instance is passed, this is used as-is.
    -2312                If another `Expression` instance is passed, it will be wrapped in a `Limit`.
    -2313            dialect (str): the dialect used to parse the input expression.
    -2314            copy (bool): if `False`, modify this expression instance in-place.
    -2315            opts (kwargs): other options to use to parse the input expressions.
    -2316
    -2317        Returns:
    -2318            Select: the modified expression.
    -2319        """
    -2320        return _apply_builder(
    -2321            expression=expression,
    -2322            instance=self,
    -2323            arg="limit",
    -2324            into=Limit,
    -2325            prefix="LIMIT",
    -2326            dialect=dialect,
    -2327            copy=copy,
    -2328            **opts,
    -2329        )
    +            
    2423    def limit(self, expression, dialect=None, copy=True, **opts) -> Select:
    +2424        """
    +2425        Set the LIMIT expression.
    +2426
    +2427        Example:
    +2428            >>> Select().from_("tbl").select("x").limit(10).sql()
    +2429            'SELECT x FROM tbl LIMIT 10'
    +2430
    +2431        Args:
    +2432            expression (str | int | Expression): the SQL code string to parse.
    +2433                This can also be an integer.
    +2434                If a `Limit` instance is passed, this is used as-is.
    +2435                If another `Expression` instance is passed, it will be wrapped in a `Limit`.
    +2436            dialect (str): the dialect used to parse the input expression.
    +2437            copy (bool): if `False`, modify this expression instance in-place.
    +2438            opts (kwargs): other options to use to parse the input expressions.
    +2439
    +2440        Returns:
    +2441            Select: the modified expression.
    +2442        """
    +2443        return _apply_builder(
    +2444            expression=expression,
    +2445            instance=self,
    +2446            arg="limit",
    +2447            into=Limit,
    +2448            prefix="LIMIT",
    +2449            dialect=dialect,
    +2450            copy=copy,
    +2451            **opts,
    +2452        )
     
    @@ -23325,36 +23827,36 @@ If another Expression instance is passed,
    -
    2331    def offset(self, expression, dialect=None, copy=True, **opts) -> Select:
    -2332        """
    -2333        Set the OFFSET expression.
    -2334
    -2335        Example:
    -2336            >>> Select().from_("tbl").select("x").offset(10).sql()
    -2337            'SELECT x FROM tbl OFFSET 10'
    -2338
    -2339        Args:
    -2340            expression (str | int | Expression): the SQL code string to parse.
    -2341                This can also be an integer.
    -2342                If a `Offset` instance is passed, this is used as-is.
    -2343                If another `Expression` instance is passed, it will be wrapped in a `Offset`.
    -2344            dialect (str): the dialect used to parse the input expression.
    -2345            copy (bool): if `False`, modify this expression instance in-place.
    -2346            opts (kwargs): other options to use to parse the input expressions.
    -2347
    -2348        Returns:
    -2349            Select: the modified expression.
    -2350        """
    -2351        return _apply_builder(
    -2352            expression=expression,
    -2353            instance=self,
    -2354            arg="offset",
    -2355            into=Offset,
    -2356            prefix="OFFSET",
    -2357            dialect=dialect,
    -2358            copy=copy,
    -2359            **opts,
    -2360        )
    +            
    2454    def offset(self, expression, dialect=None, copy=True, **opts) -> Select:
    +2455        """
    +2456        Set the OFFSET expression.
    +2457
    +2458        Example:
    +2459            >>> Select().from_("tbl").select("x").offset(10).sql()
    +2460            'SELECT x FROM tbl OFFSET 10'
    +2461
    +2462        Args:
    +2463            expression (str | int | Expression): the SQL code string to parse.
    +2464                This can also be an integer.
    +2465                If a `Offset` instance is passed, this is used as-is.
    +2466                If another `Expression` instance is passed, it will be wrapped in a `Offset`.
    +2467            dialect (str): the dialect used to parse the input expression.
    +2468            copy (bool): if `False`, modify this expression instance in-place.
    +2469            opts (kwargs): other options to use to parse the input expressions.
    +2470
    +2471        Returns:
    +2472            Select: the modified expression.
    +2473        """
    +2474        return _apply_builder(
    +2475            expression=expression,
    +2476            instance=self,
    +2477            arg="offset",
    +2478            into=Offset,
    +2479            prefix="OFFSET",
    +2480            dialect=dialect,
    +2481            copy=copy,
    +2482            **opts,
    +2483        )
     
    @@ -23402,42 +23904,42 @@ If another Expression instance is passed,
    -
    2362    def select(
    -2363        self,
    -2364        *expressions: ExpOrStr,
    -2365        append: bool = True,
    -2366        dialect: DialectType = None,
    -2367        copy: bool = True,
    -2368        **opts,
    -2369    ) -> Select:
    -2370        """
    -2371        Append to or set the SELECT expressions.
    -2372
    -2373        Example:
    -2374            >>> Select().select("x", "y").sql()
    -2375            'SELECT x, y'
    -2376
    -2377        Args:
    -2378            *expressions: the SQL code strings to parse.
    -2379                If an `Expression` instance is passed, it will be used as-is.
    -2380            append: if `True`, add to any existing expressions.
    -2381                Otherwise, this resets the expressions.
    -2382            dialect: the dialect used to parse the input expressions.
    -2383            copy: if `False`, modify this expression instance in-place.
    -2384            opts: other options to use to parse the input expressions.
    -2385
    -2386        Returns:
    -2387            Select: the modified expression.
    -2388        """
    -2389        return _apply_list_builder(
    -2390            *expressions,
    -2391            instance=self,
    -2392            arg="expressions",
    -2393            append=append,
    -2394            dialect=dialect,
    -2395            copy=copy,
    -2396            **opts,
    -2397        )
    +            
    2485    def select(
    +2486        self,
    +2487        *expressions: ExpOrStr,
    +2488        append: bool = True,
    +2489        dialect: DialectType = None,
    +2490        copy: bool = True,
    +2491        **opts,
    +2492    ) -> Select:
    +2493        """
    +2494        Append to or set the SELECT expressions.
    +2495
    +2496        Example:
    +2497            >>> Select().select("x", "y").sql()
    +2498            'SELECT x, y'
    +2499
    +2500        Args:
    +2501            *expressions: the SQL code strings to parse.
    +2502                If an `Expression` instance is passed, it will be used as-is.
    +2503            append: if `True`, add to any existing expressions.
    +2504                Otherwise, this resets the expressions.
    +2505            dialect: the dialect used to parse the input expressions.
    +2506            copy: if `False`, modify this expression instance in-place.
    +2507            opts: other options to use to parse the input expressions.
    +2508
    +2509        Returns:
    +2510            Select: the modified expression.
    +2511        """
    +2512        return _apply_list_builder(
    +2513            *expressions,
    +2514            instance=self,
    +2515            arg="expressions",
    +2516            append=append,
    +2517            dialect=dialect,
    +2518            copy=copy,
    +2519            **opts,
    +2520        )
     
    @@ -23485,37 +23987,37 @@ Otherwise, this resets the expressions.
    -
    2399    def lateral(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2400        """
    -2401        Append to or set the LATERAL expressions.
    -2402
    -2403        Example:
    -2404            >>> Select().select("x").lateral("OUTER explode(y) tbl2 AS z").from_("tbl").sql()
    -2405            'SELECT x FROM tbl LATERAL VIEW OUTER EXPLODE(y) tbl2 AS z'
    -2406
    -2407        Args:
    -2408            *expressions (str | Expression): the SQL code strings to parse.
    -2409                If an `Expression` instance is passed, it will be used as-is.
    -2410            append (bool): if `True`, add to any existing expressions.
    -2411                Otherwise, this resets the expressions.
    -2412            dialect (str): the dialect used to parse the input expressions.
    -2413            copy (bool): if `False`, modify this expression instance in-place.
    -2414            opts (kwargs): other options to use to parse the input expressions.
    -2415
    -2416        Returns:
    -2417            Select: the modified expression.
    -2418        """
    -2419        return _apply_list_builder(
    -2420            *expressions,
    -2421            instance=self,
    -2422            arg="laterals",
    -2423            append=append,
    -2424            into=Lateral,
    -2425            prefix="LATERAL VIEW",
    -2426            dialect=dialect,
    -2427            copy=copy,
    -2428            **opts,
    -2429        )
    +            
    2522    def lateral(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2523        """
    +2524        Append to or set the LATERAL expressions.
    +2525
    +2526        Example:
    +2527            >>> Select().select("x").lateral("OUTER explode(y) tbl2 AS z").from_("tbl").sql()
    +2528            'SELECT x FROM tbl LATERAL VIEW OUTER EXPLODE(y) tbl2 AS z'
    +2529
    +2530        Args:
    +2531            *expressions (str | Expression): the SQL code strings to parse.
    +2532                If an `Expression` instance is passed, it will be used as-is.
    +2533            append (bool): if `True`, add to any existing expressions.
    +2534                Otherwise, this resets the expressions.
    +2535            dialect (str): the dialect used to parse the input expressions.
    +2536            copy (bool): if `False`, modify this expression instance in-place.
    +2537            opts (kwargs): other options to use to parse the input expressions.
    +2538
    +2539        Returns:
    +2540            Select: the modified expression.
    +2541        """
    +2542        return _apply_list_builder(
    +2543            *expressions,
    +2544            instance=self,
    +2545            arg="laterals",
    +2546            append=append,
    +2547            into=Lateral,
    +2548            prefix="LATERAL VIEW",
    +2549            dialect=dialect,
    +2550            copy=copy,
    +2551            **opts,
    +2552        )
     
    @@ -23563,100 +24065,100 @@ Otherwise, this resets the expressions.
    -
    2431    def join(
    -2432        self,
    -2433        expression,
    -2434        on=None,
    -2435        using=None,
    -2436        append=True,
    -2437        join_type=None,
    -2438        join_alias=None,
    -2439        dialect=None,
    -2440        copy=True,
    -2441        **opts,
    -2442    ) -> Select:
    -2443        """
    -2444        Append to or set the JOIN expressions.
    -2445
    -2446        Example:
    -2447            >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y").sql()
    -2448            'SELECT * FROM tbl JOIN tbl2 ON tbl1.y = tbl2.y'
    -2449
    -2450            >>> Select().select("1").from_("a").join("b", using=["x", "y", "z"]).sql()
    -2451            'SELECT 1 FROM a JOIN b USING (x, y, z)'
    -2452
    -2453            Use `join_type` to change the type of join:
    -2454
    -2455            >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y", join_type="left outer").sql()
    -2456            'SELECT * FROM tbl LEFT OUTER JOIN tbl2 ON tbl1.y = tbl2.y'
    -2457
    -2458        Args:
    -2459            expression (str | Expression): the SQL code string to parse.
    -2460                If an `Expression` instance is passed, it will be used as-is.
    -2461            on (str | Expression): optionally specify the join "on" criteria as a SQL string.
    -2462                If an `Expression` instance is passed, it will be used as-is.
    -2463            using (str | Expression): optionally specify the join "using" criteria as a SQL string.
    -2464                If an `Expression` instance is passed, it will be used as-is.
    -2465            append (bool): if `True`, add to any existing expressions.
    -2466                Otherwise, this resets the expressions.
    -2467            join_type (str): If set, alter the parsed join type
    -2468            dialect (str): the dialect used to parse the input expressions.
    -2469            copy (bool): if `False`, modify this expression instance in-place.
    -2470            opts (kwargs): other options to use to parse the input expressions.
    -2471
    -2472        Returns:
    -2473            Select: the modified expression.
    -2474        """
    -2475        parse_args = {"dialect": dialect, **opts}
    -2476
    -2477        try:
    -2478            expression = maybe_parse(expression, into=Join, prefix="JOIN", **parse_args)
    -2479        except ParseError:
    -2480            expression = maybe_parse(expression, into=(Join, Expression), **parse_args)
    -2481
    -2482        join = expression if isinstance(expression, Join) else Join(this=expression)
    -2483
    -2484        if isinstance(join.this, Select):
    -2485            join.this.replace(join.this.subquery())
    -2486
    -2487        if join_type:
    -2488            natural: t.Optional[Token]
    -2489            side: t.Optional[Token]
    -2490            kind: t.Optional[Token]
    -2491
    -2492            natural, side, kind = maybe_parse(join_type, into="JOIN_TYPE", **parse_args)  # type: ignore
    -2493
    -2494            if natural:
    -2495                join.set("natural", True)
    -2496            if side:
    -2497                join.set("side", side.text)
    -2498            if kind:
    -2499                join.set("kind", kind.text)
    -2500
    -2501        if on:
    -2502            on = and_(*ensure_collection(on), dialect=dialect, **opts)
    -2503            join.set("on", on)
    -2504
    -2505        if using:
    -2506            join = _apply_list_builder(
    -2507                *ensure_collection(using),
    -2508                instance=join,
    -2509                arg="using",
    -2510                append=append,
    -2511                copy=copy,
    -2512                **opts,
    -2513            )
    -2514
    -2515        if join_alias:
    -2516            join.set("this", alias_(join.this, join_alias, table=True))
    -2517        return _apply_list_builder(
    -2518            join,
    -2519            instance=self,
    -2520            arg="joins",
    -2521            append=append,
    -2522            copy=copy,
    -2523            **opts,
    -2524        )
    +            
    2554    def join(
    +2555        self,
    +2556        expression,
    +2557        on=None,
    +2558        using=None,
    +2559        append=True,
    +2560        join_type=None,
    +2561        join_alias=None,
    +2562        dialect=None,
    +2563        copy=True,
    +2564        **opts,
    +2565    ) -> Select:
    +2566        """
    +2567        Append to or set the JOIN expressions.
    +2568
    +2569        Example:
    +2570            >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y").sql()
    +2571            'SELECT * FROM tbl JOIN tbl2 ON tbl1.y = tbl2.y'
    +2572
    +2573            >>> Select().select("1").from_("a").join("b", using=["x", "y", "z"]).sql()
    +2574            'SELECT 1 FROM a JOIN b USING (x, y, z)'
    +2575
    +2576            Use `join_type` to change the type of join:
    +2577
    +2578            >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y", join_type="left outer").sql()
    +2579            'SELECT * FROM tbl LEFT OUTER JOIN tbl2 ON tbl1.y = tbl2.y'
    +2580
    +2581        Args:
    +2582            expression (str | Expression): the SQL code string to parse.
    +2583                If an `Expression` instance is passed, it will be used as-is.
    +2584            on (str | Expression): optionally specify the join "on" criteria as a SQL string.
    +2585                If an `Expression` instance is passed, it will be used as-is.
    +2586            using (str | Expression): optionally specify the join "using" criteria as a SQL string.
    +2587                If an `Expression` instance is passed, it will be used as-is.
    +2588            append (bool): if `True`, add to any existing expressions.
    +2589                Otherwise, this resets the expressions.
    +2590            join_type (str): If set, alter the parsed join type
    +2591            dialect (str): the dialect used to parse the input expressions.
    +2592            copy (bool): if `False`, modify this expression instance in-place.
    +2593            opts (kwargs): other options to use to parse the input expressions.
    +2594
    +2595        Returns:
    +2596            Select: the modified expression.
    +2597        """
    +2598        parse_args = {"dialect": dialect, **opts}
    +2599
    +2600        try:
    +2601            expression = maybe_parse(expression, into=Join, prefix="JOIN", **parse_args)
    +2602        except ParseError:
    +2603            expression = maybe_parse(expression, into=(Join, Expression), **parse_args)
    +2604
    +2605        join = expression if isinstance(expression, Join) else Join(this=expression)
    +2606
    +2607        if isinstance(join.this, Select):
    +2608            join.this.replace(join.this.subquery())
    +2609
    +2610        if join_type:
    +2611            natural: t.Optional[Token]
    +2612            side: t.Optional[Token]
    +2613            kind: t.Optional[Token]
    +2614
    +2615            natural, side, kind = maybe_parse(join_type, into="JOIN_TYPE", **parse_args)  # type: ignore
    +2616
    +2617            if natural:
    +2618                join.set("natural", True)
    +2619            if side:
    +2620                join.set("side", side.text)
    +2621            if kind:
    +2622                join.set("kind", kind.text)
    +2623
    +2624        if on:
    +2625            on = and_(*ensure_collection(on), dialect=dialect, copy=copy, **opts)
    +2626            join.set("on", on)
    +2627
    +2628        if using:
    +2629            join = _apply_list_builder(
    +2630                *ensure_collection(using),
    +2631                instance=join,
    +2632                arg="using",
    +2633                append=append,
    +2634                copy=copy,
    +2635                **opts,
    +2636            )
    +2637
    +2638        if join_alias:
    +2639            join.set("this", alias_(join.this, join_alias, table=True))
    +2640        return _apply_list_builder(
    +2641            join,
    +2642            instance=self,
    +2643            arg="joins",
    +2644            append=append,
    +2645            copy=copy,
    +2646            **opts,
    +2647        )
     
    @@ -23723,37 +24225,37 @@ Otherwise, this resets the expressions.
    -
    2526    def where(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2527        """
    -2528        Append to or set the WHERE expressions.
    -2529
    -2530        Example:
    -2531            >>> Select().select("x").from_("tbl").where("x = 'a' OR x < 'b'").sql()
    -2532            "SELECT x FROM tbl WHERE x = 'a' OR x < 'b'"
    -2533
    -2534        Args:
    -2535            *expressions (str | Expression): the SQL code strings to parse.
    -2536                If an `Expression` instance is passed, it will be used as-is.
    -2537                Multiple expressions are combined with an AND operator.
    -2538            append (bool): if `True`, AND the new expressions to any existing expression.
    -2539                Otherwise, this resets the expression.
    -2540            dialect (str): the dialect used to parse the input expressions.
    -2541            copy (bool): if `False`, modify this expression instance in-place.
    -2542            opts (kwargs): other options to use to parse the input expressions.
    -2543
    -2544        Returns:
    -2545            Select: the modified expression.
    -2546        """
    -2547        return _apply_conjunction_builder(
    -2548            *expressions,
    -2549            instance=self,
    -2550            arg="where",
    -2551            append=append,
    -2552            into=Where,
    -2553            dialect=dialect,
    -2554            copy=copy,
    -2555            **opts,
    -2556        )
    +            
    2649    def where(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2650        """
    +2651        Append to or set the WHERE expressions.
    +2652
    +2653        Example:
    +2654            >>> Select().select("x").from_("tbl").where("x = 'a' OR x < 'b'").sql()
    +2655            "SELECT x FROM tbl WHERE x = 'a' OR x < 'b'"
    +2656
    +2657        Args:
    +2658            *expressions (str | Expression): the SQL code strings to parse.
    +2659                If an `Expression` instance is passed, it will be used as-is.
    +2660                Multiple expressions are combined with an AND operator.
    +2661            append (bool): if `True`, AND the new expressions to any existing expression.
    +2662                Otherwise, this resets the expression.
    +2663            dialect (str): the dialect used to parse the input expressions.
    +2664            copy (bool): if `False`, modify this expression instance in-place.
    +2665            opts (kwargs): other options to use to parse the input expressions.
    +2666
    +2667        Returns:
    +2668            Select: the modified expression.
    +2669        """
    +2670        return _apply_conjunction_builder(
    +2671            *expressions,
    +2672            instance=self,
    +2673            arg="where",
    +2674            append=append,
    +2675            into=Where,
    +2676            dialect=dialect,
    +2677            copy=copy,
    +2678            **opts,
    +2679        )
     
    @@ -23802,37 +24304,37 @@ Otherwise, this resets the expression.
    -
    2558    def having(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2559        """
    -2560        Append to or set the HAVING expressions.
    -2561
    -2562        Example:
    -2563            >>> Select().select("x", "COUNT(y)").from_("tbl").group_by("x").having("COUNT(y) > 3").sql()
    -2564            'SELECT x, COUNT(y) FROM tbl GROUP BY x HAVING COUNT(y) > 3'
    -2565
    -2566        Args:
    -2567            *expressions (str | Expression): the SQL code strings to parse.
    -2568                If an `Expression` instance is passed, it will be used as-is.
    -2569                Multiple expressions are combined with an AND operator.
    -2570            append (bool): if `True`, AND the new expressions to any existing expression.
    -2571                Otherwise, this resets the expression.
    -2572            dialect (str): the dialect used to parse the input expressions.
    -2573            copy (bool): if `False`, modify this expression instance in-place.
    -2574            opts (kwargs): other options to use to parse the input expressions.
    -2575
    -2576        Returns:
    -2577            Select: the modified expression.
    -2578        """
    -2579        return _apply_conjunction_builder(
    -2580            *expressions,
    -2581            instance=self,
    -2582            arg="having",
    -2583            append=append,
    -2584            into=Having,
    -2585            dialect=dialect,
    -2586            copy=copy,
    -2587            **opts,
    -2588        )
    +            
    2681    def having(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2682        """
    +2683        Append to or set the HAVING expressions.
    +2684
    +2685        Example:
    +2686            >>> Select().select("x", "COUNT(y)").from_("tbl").group_by("x").having("COUNT(y) > 3").sql()
    +2687            'SELECT x, COUNT(y) FROM tbl GROUP BY x HAVING COUNT(y) > 3'
    +2688
    +2689        Args:
    +2690            *expressions (str | Expression): the SQL code strings to parse.
    +2691                If an `Expression` instance is passed, it will be used as-is.
    +2692                Multiple expressions are combined with an AND operator.
    +2693            append (bool): if `True`, AND the new expressions to any existing expression.
    +2694                Otherwise, this resets the expression.
    +2695            dialect (str): the dialect used to parse the input expressions.
    +2696            copy (bool): if `False`, modify this expression instance in-place.
    +2697            opts (kwargs): other options to use to parse the input expressions.
    +2698
    +2699        Returns:
    +2700            Select: the modified expression.
    +2701        """
    +2702        return _apply_conjunction_builder(
    +2703            *expressions,
    +2704            instance=self,
    +2705            arg="having",
    +2706            append=append,
    +2707            into=Having,
    +2708            dialect=dialect,
    +2709            copy=copy,
    +2710            **opts,
    +2711        )
     
    @@ -23881,17 +24383,17 @@ Otherwise, this resets the expression.
    -
    2590    def window(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2591        return _apply_list_builder(
    -2592            *expressions,
    -2593            instance=self,
    -2594            arg="windows",
    -2595            append=append,
    -2596            into=Window,
    -2597            dialect=dialect,
    -2598            copy=copy,
    -2599            **opts,
    -2600        )
    +            
    2713    def window(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2714        return _apply_list_builder(
    +2715            *expressions,
    +2716            instance=self,
    +2717            arg="windows",
    +2718            append=append,
    +2719            into=Window,
    +2720            dialect=dialect,
    +2721            copy=copy,
    +2722            **opts,
    +2723        )
     
    @@ -23909,17 +24411,17 @@ Otherwise, this resets the expression.
    -
    2602    def qualify(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2603        return _apply_conjunction_builder(
    -2604            *expressions,
    -2605            instance=self,
    -2606            arg="qualify",
    -2607            append=append,
    -2608            into=Qualify,
    -2609            dialect=dialect,
    -2610            copy=copy,
    -2611            **opts,
    -2612        )
    +            
    2725    def qualify(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2726        return _apply_conjunction_builder(
    +2727            *expressions,
    +2728            instance=self,
    +2729            arg="qualify",
    +2730            append=append,
    +2731            into=Qualify,
    +2732            dialect=dialect,
    +2733            copy=copy,
    +2734            **opts,
    +2735        )
     
    @@ -23931,30 +24433,32 @@ Otherwise, this resets the expression.
    def - distinct(self, distinct=True, copy=True) -> sqlglot.expressions.Select: + distinct( self, *ons: Union[str, sqlglot.expressions.Expression], distinct: bool = True, copy: bool = True) -> sqlglot.expressions.Select:
    -
    2614    def distinct(self, distinct=True, copy=True) -> Select:
    -2615        """
    -2616        Set the OFFSET expression.
    -2617
    -2618        Example:
    -2619            >>> Select().from_("tbl").select("x").distinct().sql()
    -2620            'SELECT DISTINCT x FROM tbl'
    -2621
    -2622        Args:
    -2623            distinct (bool): whether the Select should be distinct
    -2624            copy (bool): if `False`, modify this expression instance in-place.
    -2625
    -2626        Returns:
    -2627            Select: the modified expression.
    -2628        """
    -2629        instance = _maybe_copy(self, copy)
    -2630        instance.set("distinct", Distinct() if distinct else None)
    -2631        return instance
    +            
    2737    def distinct(self, *ons: ExpOrStr, distinct: bool = True, copy: bool = True) -> Select:
    +2738        """
    +2739        Set the OFFSET expression.
    +2740
    +2741        Example:
    +2742            >>> Select().from_("tbl").select("x").distinct().sql()
    +2743            'SELECT DISTINCT x FROM tbl'
    +2744
    +2745        Args:
    +2746            ons: the expressions to distinct on
    +2747            distinct: whether the Select should be distinct
    +2748            copy: if `False`, modify this expression instance in-place.
    +2749
    +2750        Returns:
    +2751            Select: the modified expression.
    +2752        """
    +2753        instance = _maybe_copy(self, copy)
    +2754        on = Tuple(expressions=[maybe_parse(on, copy=copy) for on in ons]) if ons else None
    +2755        instance.set("distinct", Distinct(on=on) if distinct else None)
    +2756        return instance
     
    @@ -23973,8 +24477,9 @@ Otherwise, this resets the expression.
    Arguments:
      -
    • distinct (bool): whether the Select should be distinct
    • -
    • copy (bool): if False, modify this expression instance in-place.
    • +
    • ons: the expressions to distinct on
    • +
    • distinct: whether the Select should be distinct
    • +
    • copy: if False, modify this expression instance in-place.
    Returns:
    @@ -23997,42 +24502,42 @@ Otherwise, this resets the expression.
    -
    2633    def ctas(self, table, properties=None, dialect=None, copy=True, **opts) -> Create:
    -2634        """
    -2635        Convert this expression to a CREATE TABLE AS statement.
    -2636
    -2637        Example:
    -2638            >>> Select().select("*").from_("tbl").ctas("x").sql()
    -2639            'CREATE TABLE x AS SELECT * FROM tbl'
    -2640
    -2641        Args:
    -2642            table (str | Expression): the SQL code string to parse as the table name.
    -2643                If another `Expression` instance is passed, it will be used as-is.
    -2644            properties (dict): an optional mapping of table properties
    -2645            dialect (str): the dialect used to parse the input table.
    -2646            copy (bool): if `False`, modify this expression instance in-place.
    -2647            opts (kwargs): other options to use to parse the input table.
    -2648
    -2649        Returns:
    -2650            Create: the CREATE TABLE AS expression
    -2651        """
    -2652        instance = _maybe_copy(self, copy)
    -2653        table_expression = maybe_parse(
    -2654            table,
    -2655            into=Table,
    -2656            dialect=dialect,
    -2657            **opts,
    -2658        )
    -2659        properties_expression = None
    -2660        if properties:
    -2661            properties_expression = Properties.from_dict(properties)
    -2662
    -2663        return Create(
    -2664            this=table_expression,
    -2665            kind="table",
    -2666            expression=instance,
    -2667            properties=properties_expression,
    -2668        )
    +            
    2758    def ctas(self, table, properties=None, dialect=None, copy=True, **opts) -> Create:
    +2759        """
    +2760        Convert this expression to a CREATE TABLE AS statement.
    +2761
    +2762        Example:
    +2763            >>> Select().select("*").from_("tbl").ctas("x").sql()
    +2764            'CREATE TABLE x AS SELECT * FROM tbl'
    +2765
    +2766        Args:
    +2767            table (str | Expression): the SQL code string to parse as the table name.
    +2768                If another `Expression` instance is passed, it will be used as-is.
    +2769            properties (dict): an optional mapping of table properties
    +2770            dialect (str): the dialect used to parse the input table.
    +2771            copy (bool): if `False`, modify this expression instance in-place.
    +2772            opts (kwargs): other options to use to parse the input table.
    +2773
    +2774        Returns:
    +2775            Create: the CREATE TABLE AS expression
    +2776        """
    +2777        instance = _maybe_copy(self, copy)
    +2778        table_expression = maybe_parse(
    +2779            table,
    +2780            into=Table,
    +2781            dialect=dialect,
    +2782            **opts,
    +2783        )
    +2784        properties_expression = None
    +2785        if properties:
    +2786            properties_expression = Properties.from_dict(properties)
    +2787
    +2788        return Create(
    +2789            this=table_expression,
    +2790            kind="table",
    +2791            expression=instance,
    +2792            properties=properties_expression,
    +2793        )
     
    @@ -24079,29 +24584,29 @@ If another Expression instance is passed,
    -
    2670    def lock(self, update: bool = True, copy: bool = True) -> Select:
    -2671        """
    -2672        Set the locking read mode for this expression.
    -2673
    -2674        Examples:
    -2675            >>> Select().select("x").from_("tbl").where("x = 'a'").lock().sql("mysql")
    -2676            "SELECT x FROM tbl WHERE x = 'a' FOR UPDATE"
    -2677
    -2678            >>> Select().select("x").from_("tbl").where("x = 'a'").lock(update=False).sql("mysql")
    -2679            "SELECT x FROM tbl WHERE x = 'a' FOR SHARE"
    -2680
    -2681        Args:
    -2682            update: if `True`, the locking type will be `FOR UPDATE`, else it will be `FOR SHARE`.
    -2683            copy: if `False`, modify this expression instance in-place.
    -2684
    -2685        Returns:
    -2686            The modified expression.
    -2687        """
    -2688
    -2689        inst = _maybe_copy(self, copy)
    -2690        inst.set("lock", Lock(update=update))
    -2691
    -2692        return inst
    +            
    2795    def lock(self, update: bool = True, copy: bool = True) -> Select:
    +2796        """
    +2797        Set the locking read mode for this expression.
    +2798
    +2799        Examples:
    +2800            >>> Select().select("x").from_("tbl").where("x = 'a'").lock().sql("mysql")
    +2801            "SELECT x FROM tbl WHERE x = 'a' FOR UPDATE"
    +2802
    +2803            >>> Select().select("x").from_("tbl").where("x = 'a'").lock(update=False).sql("mysql")
    +2804            "SELECT x FROM tbl WHERE x = 'a' FOR SHARE"
    +2805
    +2806        Args:
    +2807            update: if `True`, the locking type will be `FOR UPDATE`, else it will be `FOR SHARE`.
    +2808            copy: if `False`, modify this expression instance in-place.
    +2809
    +2810        Returns:
    +2811            The modified expression.
    +2812        """
    +2813
    +2814        inst = _maybe_copy(self, copy)
    +2815        inst.set("lock", Lock(update=update))
    +2816
    +2817        return inst
     
    @@ -24219,30 +24724,30 @@ If another Expression instance is passed,
    -
    2707class Subquery(DerivedTable, Unionable):
    -2708    arg_types = {
    -2709        "this": True,
    -2710        "alias": False,
    -2711        "with": False,
    -2712        **QUERY_MODIFIERS,
    -2713    }
    -2714
    -2715    def unnest(self):
    -2716        """
    -2717        Returns the first non subquery.
    -2718        """
    -2719        expression = self
    -2720        while isinstance(expression, Subquery):
    -2721            expression = expression.this
    -2722        return expression
    -2723
    -2724    @property
    -2725    def is_star(self) -> bool:
    -2726        return self.this.is_star
    -2727
    -2728    @property
    -2729    def output_name(self):
    -2730        return self.alias
    +            
    2832class Subquery(DerivedTable, Unionable):
    +2833    arg_types = {
    +2834        "this": True,
    +2835        "alias": False,
    +2836        "with": False,
    +2837        **QUERY_MODIFIERS,
    +2838    }
    +2839
    +2840    def unnest(self):
    +2841        """
    +2842        Returns the first non subquery.
    +2843        """
    +2844        expression = self
    +2845        while isinstance(expression, Subquery):
    +2846            expression = expression.this
    +2847        return expression
    +2848
    +2849    @property
    +2850    def is_star(self) -> bool:
    +2851        return self.this.is_star
    +2852
    +2853    @property
    +2854    def output_name(self):
    +2855        return self.alias
     
    @@ -24259,14 +24764,14 @@ If another Expression instance is passed,
    -
    2715    def unnest(self):
    -2716        """
    -2717        Returns the first non subquery.
    -2718        """
    -2719        expression = self
    -2720        while isinstance(expression, Subquery):
    -2721            expression = expression.this
    -2722        return expression
    +            
    2840    def unnest(self):
    +2841        """
    +2842        Returns the first non subquery.
    +2843        """
    +2844        expression = self
    +2845        while isinstance(expression, Subquery):
    +2846            expression = expression.this
    +2847        return expression
     
    @@ -24378,19 +24883,19 @@ If another Expression instance is passed,
    -
    2733class TableSample(Expression):
    -2734    arg_types = {
    -2735        "this": False,
    -2736        "method": False,
    -2737        "bucket_numerator": False,
    -2738        "bucket_denominator": False,
    -2739        "bucket_field": False,
    -2740        "percent": False,
    -2741        "rows": False,
    -2742        "size": False,
    -2743        "seed": False,
    -2744        "kind": False,
    -2745    }
    +            
    2858class TableSample(Expression):
    +2859    arg_types = {
    +2860        "this": False,
    +2861        "method": False,
    +2862        "bucket_numerator": False,
    +2863        "bucket_denominator": False,
    +2864        "bucket_field": False,
    +2865        "percent": False,
    +2866        "rows": False,
    +2867        "size": False,
    +2868        "seed": False,
    +2869        "kind": False,
    +2870    }
     
    @@ -24453,14 +24958,14 @@ If another Expression instance is passed,
    -
    2748class Tag(Expression):
    -2749    """Tags are used for generating arbitrary sql like SELECT <span>x</span>."""
    -2750
    -2751    arg_types = {
    -2752        "this": False,
    -2753        "prefix": False,
    -2754        "postfix": False,
    -2755    }
    +            
    2873class Tag(Expression):
    +2874    """Tags are used for generating arbitrary sql like SELECT <span>x</span>."""
    +2875
    +2876    arg_types = {
    +2877        "this": False,
    +2878        "prefix": False,
    +2879        "postfix": False,
    +2880    }
     
    @@ -24525,15 +25030,15 @@ If another Expression instance is passed,
    -
    2758class Pivot(Expression):
    -2759    arg_types = {
    -2760        "this": False,
    -2761        "alias": False,
    -2762        "expressions": True,
    -2763        "field": True,
    -2764        "unpivot": True,
    -2765        "columns": False,
    -2766    }
    +            
    2883class Pivot(Expression):
    +2884    arg_types = {
    +2885        "this": False,
    +2886        "alias": False,
    +2887        "expressions": True,
    +2888        "field": True,
    +2889        "unpivot": True,
    +2890        "columns": False,
    +2891    }
     
    @@ -24596,14 +25101,16 @@ If another Expression instance is passed,
    -
    2769class Window(Expression):
    -2770    arg_types = {
    -2771        "this": True,
    -2772        "partition_by": False,
    -2773        "order": False,
    -2774        "spec": False,
    -2775        "alias": False,
    -2776    }
    +            
    2894class Window(Expression):
    +2895    arg_types = {
    +2896        "this": True,
    +2897        "partition_by": False,
    +2898        "order": False,
    +2899        "spec": False,
    +2900        "alias": False,
    +2901        "over": False,
    +2902        "first": False,
    +2903    }
     
    @@ -24666,14 +25173,14 @@ If another Expression instance is passed,
    -
    2779class WindowSpec(Expression):
    -2780    arg_types = {
    -2781        "kind": False,
    -2782        "start": False,
    -2783        "start_side": False,
    -2784        "end": False,
    -2785        "end_side": False,
    -2786    }
    +            
    2906class WindowSpec(Expression):
    +2907    arg_types = {
    +2908        "kind": False,
    +2909        "start": False,
    +2910        "start_side": False,
    +2911        "end": False,
    +2912        "end_side": False,
    +2913    }
     
    @@ -24736,8 +25243,8 @@ If another Expression instance is passed,
    -
    2789class Where(Expression):
    -2790    pass
    +            
    2916class Where(Expression):
    +2917    pass
     
    @@ -24800,16 +25307,16 @@ If another Expression instance is passed,
    -
    2793class Star(Expression):
    -2794    arg_types = {"except": False, "replace": False}
    -2795
    -2796    @property
    -2797    def name(self) -> str:
    -2798        return "*"
    -2799
    -2800    @property
    -2801    def output_name(self):
    -2802        return self.name
    +            
    2920class Star(Expression):
    +2921    arg_types = {"except": False, "replace": False}
    +2922
    +2923    @property
    +2924    def name(self) -> str:
    +2925        return "*"
    +2926
    +2927    @property
    +2928    def output_name(self):
    +2929        return self.name
     
    @@ -24901,8 +25408,8 @@ If another Expression instance is passed,
    -
    2805class Parameter(Expression):
    -2806    arg_types = {"this": True, "wrapped": False}
    +            
    2932class Parameter(Expression):
    +2933    arg_types = {"this": True, "wrapped": False}
     
    @@ -24965,8 +25472,8 @@ If another Expression instance is passed,
    -
    2809class SessionParameter(Expression):
    -2810    arg_types = {"this": True, "kind": False}
    +            
    2936class SessionParameter(Expression):
    +2937    arg_types = {"this": True, "kind": False}
     
    @@ -25029,8 +25536,8 @@ If another Expression instance is passed,
    -
    2813class Placeholder(Expression):
    -2814    arg_types = {"this": False}
    +            
    2940class Placeholder(Expression):
    +2941    arg_types = {"this": False}
     
    @@ -25093,12 +25600,12 @@ If another Expression instance is passed,
    -
    2817class Null(Condition):
    -2818    arg_types: t.Dict[str, t.Any] = {}
    -2819
    -2820    @property
    -2821    def name(self) -> str:
    -2822        return "NULL"
    +            
    2944class Null(Condition):
    +2945    arg_types: t.Dict[str, t.Any] = {}
    +2946
    +2947    @property
    +2948    def name(self) -> str:
    +2949        return "NULL"
     
    @@ -25151,6 +25658,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -25167,8 +25681,8 @@ If another Expression instance is passed,
    -
    2825class Boolean(Condition):
    -2826    pass
    +            
    2952class Boolean(Condition):
    +2953    pass
     
    @@ -25221,6 +25735,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -25237,128 +25758,128 @@ If another Expression instance is passed, -
    2829class DataType(Expression):
    -2830    arg_types = {
    -2831        "this": True,
    -2832        "expressions": False,
    -2833        "nested": False,
    -2834        "values": False,
    -2835        "prefix": False,
    -2836    }
    -2837
    -2838    class Type(AutoName):
    -2839        CHAR = auto()
    -2840        NCHAR = auto()
    -2841        VARCHAR = auto()
    -2842        NVARCHAR = auto()
    -2843        TEXT = auto()
    -2844        MEDIUMTEXT = auto()
    -2845        LONGTEXT = auto()
    -2846        MEDIUMBLOB = auto()
    -2847        LONGBLOB = auto()
    -2848        BINARY = auto()
    -2849        VARBINARY = auto()
    -2850        INT = auto()
    -2851        UINT = auto()
    -2852        TINYINT = auto()
    -2853        UTINYINT = auto()
    -2854        SMALLINT = auto()
    -2855        USMALLINT = auto()
    -2856        BIGINT = auto()
    -2857        UBIGINT = auto()
    -2858        FLOAT = auto()
    -2859        DOUBLE = auto()
    -2860        DECIMAL = auto()
    -2861        BIGDECIMAL = auto()
    -2862        BIT = auto()
    -2863        BOOLEAN = auto()
    -2864        JSON = auto()
    -2865        JSONB = auto()
    -2866        INTERVAL = auto()
    -2867        TIME = auto()
    -2868        TIMESTAMP = auto()
    -2869        TIMESTAMPTZ = auto()
    -2870        TIMESTAMPLTZ = auto()
    -2871        DATE = auto()
    -2872        DATETIME = auto()
    -2873        ARRAY = auto()
    -2874        MAP = auto()
    -2875        UUID = auto()
    -2876        GEOGRAPHY = auto()
    -2877        GEOMETRY = auto()
    -2878        STRUCT = auto()
    -2879        NULLABLE = auto()
    -2880        HLLSKETCH = auto()
    -2881        HSTORE = auto()
    -2882        SUPER = auto()
    -2883        SERIAL = auto()
    -2884        SMALLSERIAL = auto()
    -2885        BIGSERIAL = auto()
    -2886        XML = auto()
    -2887        UNIQUEIDENTIFIER = auto()
    -2888        MONEY = auto()
    -2889        SMALLMONEY = auto()
    -2890        ROWVERSION = auto()
    -2891        IMAGE = auto()
    -2892        VARIANT = auto()
    -2893        OBJECT = auto()
    -2894        INET = auto()
    -2895        NULL = auto()
    -2896        UNKNOWN = auto()  # Sentinel value, useful for type annotation
    -2897
    -2898    TEXT_TYPES = {
    -2899        Type.CHAR,
    -2900        Type.NCHAR,
    -2901        Type.VARCHAR,
    -2902        Type.NVARCHAR,
    -2903        Type.TEXT,
    -2904    }
    -2905
    -2906    INTEGER_TYPES = {
    -2907        Type.INT,
    -2908        Type.TINYINT,
    -2909        Type.SMALLINT,
    -2910        Type.BIGINT,
    -2911    }
    -2912
    -2913    FLOAT_TYPES = {
    -2914        Type.FLOAT,
    -2915        Type.DOUBLE,
    -2916    }
    -2917
    -2918    NUMERIC_TYPES = {*INTEGER_TYPES, *FLOAT_TYPES}
    -2919
    -2920    TEMPORAL_TYPES = {
    -2921        Type.TIMESTAMP,
    -2922        Type.TIMESTAMPTZ,
    -2923        Type.TIMESTAMPLTZ,
    -2924        Type.DATE,
    -2925        Type.DATETIME,
    -2926    }
    -2927
    -2928    @classmethod
    -2929    def build(
    -2930        cls, dtype: str | DataType | DataType.Type, dialect: DialectType = None, **kwargs
    -2931    ) -> DataType:
    -2932        from sqlglot import parse_one
    -2933
    -2934        if isinstance(dtype, str):
    -2935            if dtype.upper() in cls.Type.__members__:
    -2936                data_type_exp: t.Optional[Expression] = DataType(this=DataType.Type[dtype.upper()])
    -2937            else:
    -2938                data_type_exp = parse_one(dtype, read=dialect, into=DataType)
    -2939            if data_type_exp is None:
    -2940                raise ValueError(f"Unparsable data type value: {dtype}")
    -2941        elif isinstance(dtype, DataType.Type):
    -2942            data_type_exp = DataType(this=dtype)
    -2943        elif isinstance(dtype, DataType):
    -2944            return dtype
    -2945        else:
    -2946            raise ValueError(f"Invalid data type: {type(dtype)}. Expected str or DataType.Type")
    -2947        return DataType(**{**data_type_exp.args, **kwargs})
    -2948
    -2949    def is_type(self, dtype: DataType.Type) -> bool:
    -2950        return self.this == dtype
    +            
    2956class DataType(Expression):
    +2957    arg_types = {
    +2958        "this": True,
    +2959        "expressions": False,
    +2960        "nested": False,
    +2961        "values": False,
    +2962        "prefix": False,
    +2963    }
    +2964
    +2965    class Type(AutoName):
    +2966        CHAR = auto()
    +2967        NCHAR = auto()
    +2968        VARCHAR = auto()
    +2969        NVARCHAR = auto()
    +2970        TEXT = auto()
    +2971        MEDIUMTEXT = auto()
    +2972        LONGTEXT = auto()
    +2973        MEDIUMBLOB = auto()
    +2974        LONGBLOB = auto()
    +2975        BINARY = auto()
    +2976        VARBINARY = auto()
    +2977        INT = auto()
    +2978        UINT = auto()
    +2979        TINYINT = auto()
    +2980        UTINYINT = auto()
    +2981        SMALLINT = auto()
    +2982        USMALLINT = auto()
    +2983        BIGINT = auto()
    +2984        UBIGINT = auto()
    +2985        FLOAT = auto()
    +2986        DOUBLE = auto()
    +2987        DECIMAL = auto()
    +2988        BIGDECIMAL = auto()
    +2989        BIT = auto()
    +2990        BOOLEAN = auto()
    +2991        JSON = auto()
    +2992        JSONB = auto()
    +2993        INTERVAL = auto()
    +2994        TIME = auto()
    +2995        TIMESTAMP = auto()
    +2996        TIMESTAMPTZ = auto()
    +2997        TIMESTAMPLTZ = auto()
    +2998        DATE = auto()
    +2999        DATETIME = auto()
    +3000        ARRAY = auto()
    +3001        MAP = auto()
    +3002        UUID = auto()
    +3003        GEOGRAPHY = auto()
    +3004        GEOMETRY = auto()
    +3005        STRUCT = auto()
    +3006        NULLABLE = auto()
    +3007        HLLSKETCH = auto()
    +3008        HSTORE = auto()
    +3009        SUPER = auto()
    +3010        SERIAL = auto()
    +3011        SMALLSERIAL = auto()
    +3012        BIGSERIAL = auto()
    +3013        XML = auto()
    +3014        UNIQUEIDENTIFIER = auto()
    +3015        MONEY = auto()
    +3016        SMALLMONEY = auto()
    +3017        ROWVERSION = auto()
    +3018        IMAGE = auto()
    +3019        VARIANT = auto()
    +3020        OBJECT = auto()
    +3021        INET = auto()
    +3022        NULL = auto()
    +3023        UNKNOWN = auto()  # Sentinel value, useful for type annotation
    +3024
    +3025    TEXT_TYPES = {
    +3026        Type.CHAR,
    +3027        Type.NCHAR,
    +3028        Type.VARCHAR,
    +3029        Type.NVARCHAR,
    +3030        Type.TEXT,
    +3031    }
    +3032
    +3033    INTEGER_TYPES = {
    +3034        Type.INT,
    +3035        Type.TINYINT,
    +3036        Type.SMALLINT,
    +3037        Type.BIGINT,
    +3038    }
    +3039
    +3040    FLOAT_TYPES = {
    +3041        Type.FLOAT,
    +3042        Type.DOUBLE,
    +3043    }
    +3044
    +3045    NUMERIC_TYPES = {*INTEGER_TYPES, *FLOAT_TYPES}
    +3046
    +3047    TEMPORAL_TYPES = {
    +3048        Type.TIMESTAMP,
    +3049        Type.TIMESTAMPTZ,
    +3050        Type.TIMESTAMPLTZ,
    +3051        Type.DATE,
    +3052        Type.DATETIME,
    +3053    }
    +3054
    +3055    @classmethod
    +3056    def build(
    +3057        cls, dtype: str | DataType | DataType.Type, dialect: DialectType = None, **kwargs
    +3058    ) -> DataType:
    +3059        from sqlglot import parse_one
    +3060
    +3061        if isinstance(dtype, str):
    +3062            if dtype.upper() in cls.Type.__members__:
    +3063                data_type_exp: t.Optional[Expression] = DataType(this=DataType.Type[dtype.upper()])
    +3064            else:
    +3065                data_type_exp = parse_one(dtype, read=dialect, into=DataType)
    +3066            if data_type_exp is None:
    +3067                raise ValueError(f"Unparsable data type value: {dtype}")
    +3068        elif isinstance(dtype, DataType.Type):
    +3069            data_type_exp = DataType(this=dtype)
    +3070        elif isinstance(dtype, DataType):
    +3071            return dtype
    +3072        else:
    +3073            raise ValueError(f"Invalid data type: {type(dtype)}. Expected str or DataType.Type")
    +3074        return DataType(**{**data_type_exp.args, **kwargs})
    +3075
    +3076    def is_type(self, dtype: DataType.Type) -> bool:
    +3077        return self.this == dtype
     
    @@ -25376,26 +25897,26 @@ If another Expression instance is passed,
    -
    2928    @classmethod
    -2929    def build(
    -2930        cls, dtype: str | DataType | DataType.Type, dialect: DialectType = None, **kwargs
    -2931    ) -> DataType:
    -2932        from sqlglot import parse_one
    -2933
    -2934        if isinstance(dtype, str):
    -2935            if dtype.upper() in cls.Type.__members__:
    -2936                data_type_exp: t.Optional[Expression] = DataType(this=DataType.Type[dtype.upper()])
    -2937            else:
    -2938                data_type_exp = parse_one(dtype, read=dialect, into=DataType)
    -2939            if data_type_exp is None:
    -2940                raise ValueError(f"Unparsable data type value: {dtype}")
    -2941        elif isinstance(dtype, DataType.Type):
    -2942            data_type_exp = DataType(this=dtype)
    -2943        elif isinstance(dtype, DataType):
    -2944            return dtype
    -2945        else:
    -2946            raise ValueError(f"Invalid data type: {type(dtype)}. Expected str or DataType.Type")
    -2947        return DataType(**{**data_type_exp.args, **kwargs})
    +            
    3055    @classmethod
    +3056    def build(
    +3057        cls, dtype: str | DataType | DataType.Type, dialect: DialectType = None, **kwargs
    +3058    ) -> DataType:
    +3059        from sqlglot import parse_one
    +3060
    +3061        if isinstance(dtype, str):
    +3062            if dtype.upper() in cls.Type.__members__:
    +3063                data_type_exp: t.Optional[Expression] = DataType(this=DataType.Type[dtype.upper()])
    +3064            else:
    +3065                data_type_exp = parse_one(dtype, read=dialect, into=DataType)
    +3066            if data_type_exp is None:
    +3067                raise ValueError(f"Unparsable data type value: {dtype}")
    +3068        elif isinstance(dtype, DataType.Type):
    +3069            data_type_exp = DataType(this=dtype)
    +3070        elif isinstance(dtype, DataType):
    +3071            return dtype
    +3072        else:
    +3073            raise ValueError(f"Invalid data type: {type(dtype)}. Expected str or DataType.Type")
    +3074        return DataType(**{**data_type_exp.args, **kwargs})
     
    @@ -25413,8 +25934,8 @@ If another Expression instance is passed,
    -
    2949    def is_type(self, dtype: DataType.Type) -> bool:
    -2950        return self.this == dtype
    +            
    3076    def is_type(self, dtype: DataType.Type) -> bool:
    +3077        return self.this == dtype
     
    @@ -25478,65 +25999,65 @@ If another Expression instance is passed,
    -
    2838    class Type(AutoName):
    -2839        CHAR = auto()
    -2840        NCHAR = auto()
    -2841        VARCHAR = auto()
    -2842        NVARCHAR = auto()
    -2843        TEXT = auto()
    -2844        MEDIUMTEXT = auto()
    -2845        LONGTEXT = auto()
    -2846        MEDIUMBLOB = auto()
    -2847        LONGBLOB = auto()
    -2848        BINARY = auto()
    -2849        VARBINARY = auto()
    -2850        INT = auto()
    -2851        UINT = auto()
    -2852        TINYINT = auto()
    -2853        UTINYINT = auto()
    -2854        SMALLINT = auto()
    -2855        USMALLINT = auto()
    -2856        BIGINT = auto()
    -2857        UBIGINT = auto()
    -2858        FLOAT = auto()
    -2859        DOUBLE = auto()
    -2860        DECIMAL = auto()
    -2861        BIGDECIMAL = auto()
    -2862        BIT = auto()
    -2863        BOOLEAN = auto()
    -2864        JSON = auto()
    -2865        JSONB = auto()
    -2866        INTERVAL = auto()
    -2867        TIME = auto()
    -2868        TIMESTAMP = auto()
    -2869        TIMESTAMPTZ = auto()
    -2870        TIMESTAMPLTZ = auto()
    -2871        DATE = auto()
    -2872        DATETIME = auto()
    -2873        ARRAY = auto()
    -2874        MAP = auto()
    -2875        UUID = auto()
    -2876        GEOGRAPHY = auto()
    -2877        GEOMETRY = auto()
    -2878        STRUCT = auto()
    -2879        NULLABLE = auto()
    -2880        HLLSKETCH = auto()
    -2881        HSTORE = auto()
    -2882        SUPER = auto()
    -2883        SERIAL = auto()
    -2884        SMALLSERIAL = auto()
    -2885        BIGSERIAL = auto()
    -2886        XML = auto()
    -2887        UNIQUEIDENTIFIER = auto()
    -2888        MONEY = auto()
    -2889        SMALLMONEY = auto()
    -2890        ROWVERSION = auto()
    -2891        IMAGE = auto()
    -2892        VARIANT = auto()
    -2893        OBJECT = auto()
    -2894        INET = auto()
    -2895        NULL = auto()
    -2896        UNKNOWN = auto()  # Sentinel value, useful for type annotation
    +            
    2965    class Type(AutoName):
    +2966        CHAR = auto()
    +2967        NCHAR = auto()
    +2968        VARCHAR = auto()
    +2969        NVARCHAR = auto()
    +2970        TEXT = auto()
    +2971        MEDIUMTEXT = auto()
    +2972        LONGTEXT = auto()
    +2973        MEDIUMBLOB = auto()
    +2974        LONGBLOB = auto()
    +2975        BINARY = auto()
    +2976        VARBINARY = auto()
    +2977        INT = auto()
    +2978        UINT = auto()
    +2979        TINYINT = auto()
    +2980        UTINYINT = auto()
    +2981        SMALLINT = auto()
    +2982        USMALLINT = auto()
    +2983        BIGINT = auto()
    +2984        UBIGINT = auto()
    +2985        FLOAT = auto()
    +2986        DOUBLE = auto()
    +2987        DECIMAL = auto()
    +2988        BIGDECIMAL = auto()
    +2989        BIT = auto()
    +2990        BOOLEAN = auto()
    +2991        JSON = auto()
    +2992        JSONB = auto()
    +2993        INTERVAL = auto()
    +2994        TIME = auto()
    +2995        TIMESTAMP = auto()
    +2996        TIMESTAMPTZ = auto()
    +2997        TIMESTAMPLTZ = auto()
    +2998        DATE = auto()
    +2999        DATETIME = auto()
    +3000        ARRAY = auto()
    +3001        MAP = auto()
    +3002        UUID = auto()
    +3003        GEOGRAPHY = auto()
    +3004        GEOMETRY = auto()
    +3005        STRUCT = auto()
    +3006        NULLABLE = auto()
    +3007        HLLSKETCH = auto()
    +3008        HSTORE = auto()
    +3009        SUPER = auto()
    +3010        SERIAL = auto()
    +3011        SMALLSERIAL = auto()
    +3012        BIGSERIAL = auto()
    +3013        XML = auto()
    +3014        UNIQUEIDENTIFIER = auto()
    +3015        MONEY = auto()
    +3016        SMALLMONEY = auto()
    +3017        ROWVERSION = auto()
    +3018        IMAGE = auto()
    +3019        VARIANT = auto()
    +3020        OBJECT = auto()
    +3021        INET = auto()
    +3022        NULL = auto()
    +3023        UNKNOWN = auto()  # Sentinel value, useful for type annotation
     
    @@ -26262,8 +26783,8 @@ If another Expression instance is passed,
    -
    2954class PseudoType(Expression):
    -2955    pass
    +            
    3081class PseudoType(Expression):
    +3082    pass
     
    @@ -26326,8 +26847,8 @@ If another Expression instance is passed,
    -
    2958class StructKwarg(Expression):
    -2959    arg_types = {"this": True, "expression": True}
    +            
    3085class StructKwarg(Expression):
    +3086    arg_types = {"this": True, "expression": True}
     
    @@ -26390,8 +26911,8 @@ If another Expression instance is passed,
    -
    2963class SubqueryPredicate(Predicate):
    -2964    pass
    +            
    3090class SubqueryPredicate(Predicate):
    +3091    pass
     
    @@ -26444,6 +26965,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -26460,8 +26988,8 @@ If another Expression instance is passed, -
    2967class All(SubqueryPredicate):
    -2968    pass
    +            
    3094class All(SubqueryPredicate):
    +3095    pass
     
    @@ -26514,6 +27042,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -26530,8 +27065,8 @@ If another Expression instance is passed, -
    2971class Any(SubqueryPredicate):
    -2972    pass
    +            
    3098class Any(SubqueryPredicate):
    +3099    pass
     
    @@ -26584,6 +27119,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -26600,8 +27142,8 @@ If another Expression instance is passed, -
    2975class Exists(SubqueryPredicate):
    -2976    pass
    +            
    3102class Exists(SubqueryPredicate):
    +3103    pass
     
    @@ -26654,6 +27196,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -26670,8 +27219,8 @@ If another Expression instance is passed, -
    2981class Command(Expression):
    -2982    arg_types = {"this": True, "expression": False}
    +            
    3108class Command(Expression):
    +3109    arg_types = {"this": True, "expression": False}
     
    @@ -26734,8 +27283,8 @@ If another Expression instance is passed,
    -
    2985class Transaction(Expression):
    -2986    arg_types = {"this": False, "modes": False}
    +            
    3112class Transaction(Expression):
    +3113    arg_types = {"this": False, "modes": False}
     
    @@ -26798,8 +27347,8 @@ If another Expression instance is passed,
    -
    2989class Commit(Expression):
    -2990    arg_types = {"chain": False}
    +            
    3116class Commit(Expression):
    +3117    arg_types = {"chain": False}
     
    @@ -26862,8 +27411,8 @@ If another Expression instance is passed,
    -
    2993class Rollback(Expression):
    -2994    arg_types = {"savepoint": False}
    +            
    3120class Rollback(Expression):
    +3121    arg_types = {"savepoint": False}
     
    @@ -26926,8 +27475,8 @@ If another Expression instance is passed,
    -
    2997class AlterTable(Expression):
    -2998    arg_types = {"this": True, "actions": True, "exists": False}
    +            
    3124class AlterTable(Expression):
    +3125    arg_types = {"this": True, "actions": True, "exists": False}
     
    @@ -26990,8 +27539,8 @@ If another Expression instance is passed,
    -
    3001class AddConstraint(Expression):
    -3002    arg_types = {"this": False, "expression": False, "enforced": False}
    +            
    3128class AddConstraint(Expression):
    +3129    arg_types = {"this": False, "expression": False, "enforced": False}
     
    @@ -27054,8 +27603,8 @@ If another Expression instance is passed,
    -
    3005class DropPartition(Expression):
    -3006    arg_types = {"expressions": True, "exists": False}
    +            
    3132class DropPartition(Expression):
    +3133    arg_types = {"expressions": True, "exists": False}
     
    @@ -27112,22 +27661,22 @@ If another Expression instance is passed,
    class - Binary(Expression): + Binary(Condition):
    -
    3010class Binary(Expression):
    -3011    arg_types = {"this": True, "expression": True}
    -3012
    -3013    @property
    -3014    def left(self):
    -3015        return self.this
    -3016
    -3017    @property
    -3018    def right(self):
    -3019        return self.expression
    +            
    3137class Binary(Condition):
    +3138    arg_types = {"this": True, "expression": True}
    +3139
    +3140    @property
    +3141    def left(self):
    +3142        return self.this
    +3143
    +3144    @property
    +3145    def right(self):
    +3146        return self.expression
     
    @@ -27175,6 +27724,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    @@ -27190,8 +27752,8 @@ If another Expression instance is passed, -
    3022class Add(Binary):
    -3023    pass
    +            
    3149class Add(Binary):
    +3150    pass
     
    @@ -27239,6 +27801,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -27248,14 +27823,14 @@ If another Expression instance is passed,
    class - Connector(Binary, Condition): + Connector(Binary):
    -
    3026class Connector(Binary, Condition):
    -3027    pass
    +            
    3153class Connector(Binary):
    +3154    pass
     
    @@ -27308,6 +27883,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -27324,8 +27906,8 @@ If another Expression instance is passed, -
    3030class And(Connector):
    -3031    pass
    +            
    3157class And(Connector):
    +3158    pass
     
    @@ -27378,6 +27960,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -27394,8 +27983,8 @@ If another Expression instance is passed, -
    3034class Or(Connector):
    -3035    pass
    +            
    3161class Or(Connector):
    +3162    pass
     
    @@ -27448,6 +28037,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -27464,8 +28060,8 @@ If another Expression instance is passed, -
    3038class BitwiseAnd(Binary):
    -3039    pass
    +            
    3165class BitwiseAnd(Binary):
    +3166    pass
     
    @@ -27513,6 +28109,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -27528,8 +28137,8 @@ If another Expression instance is passed, -
    3042class BitwiseLeftShift(Binary):
    -3043    pass
    +            
    3169class BitwiseLeftShift(Binary):
    +3170    pass
     
    @@ -27577,6 +28186,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -27592,8 +28214,8 @@ If another Expression instance is passed, -
    3046class BitwiseOr(Binary):
    -3047    pass
    +            
    3173class BitwiseOr(Binary):
    +3174    pass
     
    @@ -27641,6 +28263,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -27656,8 +28291,8 @@ If another Expression instance is passed, -
    3050class BitwiseRightShift(Binary):
    -3051    pass
    +            
    3177class BitwiseRightShift(Binary):
    +3178    pass
     
    @@ -27705,6 +28340,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -27720,8 +28368,8 @@ If another Expression instance is passed, -
    3054class BitwiseXor(Binary):
    -3055    pass
    +            
    3181class BitwiseXor(Binary):
    +3182    pass
     
    @@ -27769,6 +28417,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -27784,8 +28445,8 @@ If another Expression instance is passed, -
    3058class Div(Binary):
    -3059    pass
    +            
    3185class Div(Binary):
    +3186    pass
     
    @@ -27833,6 +28494,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -27848,8 +28522,8 @@ If another Expression instance is passed, -
    3062class Overlaps(Binary):
    -3063    pass
    +            
    3189class Overlaps(Binary):
    +3190    pass
     
    @@ -27897,6 +28571,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -27912,24 +28599,24 @@ If another Expression instance is passed, -
    3066class Dot(Binary):
    -3067    @property
    -3068    def name(self) -> str:
    -3069        return self.expression.name
    -3070
    -3071    @classmethod
    -3072    def build(self, expressions: t.Sequence[Expression]) -> Dot:
    -3073        """Build a Dot object with a sequence of expressions."""
    -3074        if len(expressions) < 2:
    -3075            raise ValueError(f"Dot requires >= 2 expressions.")
    -3076
    -3077        a, b, *expressions = expressions
    -3078        dot = Dot(this=a, expression=b)
    -3079
    -3080        for expression in expressions:
    -3081            dot = Dot(this=dot, expression=expression)
    -3082
    -3083        return dot
    +            
    3193class Dot(Binary):
    +3194    @property
    +3195    def name(self) -> str:
    +3196        return self.expression.name
    +3197
    +3198    @classmethod
    +3199    def build(self, expressions: t.Sequence[Expression]) -> Dot:
    +3200        """Build a Dot object with a sequence of expressions."""
    +3201        if len(expressions) < 2:
    +3202            raise ValueError(f"Dot requires >= 2 expressions.")
    +3203
    +3204        a, b, *expressions = expressions
    +3205        dot = Dot(this=a, expression=b)
    +3206
    +3207        for expression in expressions:
    +3208            dot = Dot(this=dot, expression=expression)
    +3209
    +3210        return dot
     
    @@ -27947,19 +28634,19 @@ If another Expression instance is passed,
    -
    3071    @classmethod
    -3072    def build(self, expressions: t.Sequence[Expression]) -> Dot:
    -3073        """Build a Dot object with a sequence of expressions."""
    -3074        if len(expressions) < 2:
    -3075            raise ValueError(f"Dot requires >= 2 expressions.")
    -3076
    -3077        a, b, *expressions = expressions
    -3078        dot = Dot(this=a, expression=b)
    -3079
    -3080        for expression in expressions:
    -3081            dot = Dot(this=dot, expression=expression)
    -3082
    -3083        return dot
    +            
    3198    @classmethod
    +3199    def build(self, expressions: t.Sequence[Expression]) -> Dot:
    +3200        """Build a Dot object with a sequence of expressions."""
    +3201        if len(expressions) < 2:
    +3202            raise ValueError(f"Dot requires >= 2 expressions.")
    +3203
    +3204        a, b, *expressions = expressions
    +3205        dot = Dot(this=a, expression=b)
    +3206
    +3207        for expression in expressions:
    +3208            dot = Dot(this=dot, expression=expression)
    +3209
    +3210        return dot
     
    @@ -28010,6 +28697,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -28025,8 +28725,8 @@ If another Expression instance is passed, -
    3086class DPipe(Binary):
    -3087    pass
    +            
    3213class DPipe(Binary):
    +3214    pass
     
    @@ -28074,6 +28774,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -28089,8 +28802,8 @@ If another Expression instance is passed, -
    3090class EQ(Binary, Predicate):
    -3091    pass
    +            
    3217class EQ(Binary, Predicate):
    +3218    pass
     
    @@ -28143,6 +28856,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -28159,8 +28879,8 @@ If another Expression instance is passed, -
    3094class NullSafeEQ(Binary, Predicate):
    -3095    pass
    +            
    3221class NullSafeEQ(Binary, Predicate):
    +3222    pass
     
    @@ -28213,6 +28933,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -28229,8 +28956,8 @@ If another Expression instance is passed, -
    3098class NullSafeNEQ(Binary, Predicate):
    -3099    pass
    +            
    3225class NullSafeNEQ(Binary, Predicate):
    +3226    pass
     
    @@ -28283,6 +29010,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -28299,8 +29033,8 @@ If another Expression instance is passed, -
    3102class Distance(Binary):
    -3103    pass
    +            
    3229class Distance(Binary):
    +3230    pass
     
    @@ -28348,6 +29082,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -28363,8 +29110,8 @@ If another Expression instance is passed, -
    3106class Escape(Binary):
    -3107    pass
    +            
    3233class Escape(Binary):
    +3234    pass
     
    @@ -28412,6 +29159,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -28427,8 +29187,8 @@ If another Expression instance is passed, -
    3110class Glob(Binary, Predicate):
    -3111    pass
    +            
    3237class Glob(Binary, Predicate):
    +3238    pass
     
    @@ -28481,6 +29241,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -28497,8 +29264,8 @@ If another Expression instance is passed, -
    3114class GT(Binary, Predicate):
    -3115    pass
    +            
    3241class GT(Binary, Predicate):
    +3242    pass
     
    @@ -28551,6 +29318,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -28567,8 +29341,8 @@ If another Expression instance is passed, -
    3118class GTE(Binary, Predicate):
    -3119    pass
    +            
    3245class GTE(Binary, Predicate):
    +3246    pass
     
    @@ -28621,6 +29395,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -28637,8 +29418,8 @@ If another Expression instance is passed, -
    3122class ILike(Binary, Predicate):
    -3123    pass
    +            
    3249class ILike(Binary, Predicate):
    +3250    pass
     
    @@ -28691,6 +29472,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -28707,8 +29495,8 @@ If another Expression instance is passed, -
    3126class ILikeAny(Binary, Predicate):
    -3127    pass
    +            
    3253class ILikeAny(Binary, Predicate):
    +3254    pass
     
    @@ -28761,6 +29549,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -28777,8 +29572,8 @@ If another Expression instance is passed, -
    3130class IntDiv(Binary):
    -3131    pass
    +            
    3257class IntDiv(Binary):
    +3258    pass
     
    @@ -28826,6 +29621,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -28841,8 +29649,8 @@ If another Expression instance is passed, -
    3134class Is(Binary, Predicate):
    -3135    pass
    +            
    3261class Is(Binary, Predicate):
    +3262    pass
     
    @@ -28895,6 +29703,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -28911,8 +29726,8 @@ If another Expression instance is passed, -
    3138class Kwarg(Binary):
    -3139    """Kwarg in special functions like func(kwarg => y)."""
    +            
    3265class Kwarg(Binary):
    +3266    """Kwarg in special functions like func(kwarg => y)."""
     
    @@ -28962,6 +29777,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -28977,8 +29805,8 @@ If another Expression instance is passed, -
    3142class Like(Binary, Predicate):
    -3143    pass
    +            
    3269class Like(Binary, Predicate):
    +3270    pass
     
    @@ -29031,6 +29859,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -29047,8 +29882,8 @@ If another Expression instance is passed, -
    3146class LikeAny(Binary, Predicate):
    -3147    pass
    +            
    3273class LikeAny(Binary, Predicate):
    +3274    pass
     
    @@ -29101,6 +29936,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -29117,8 +29959,8 @@ If another Expression instance is passed, -
    3150class LT(Binary, Predicate):
    -3151    pass
    +            
    3277class LT(Binary, Predicate):
    +3278    pass
     
    @@ -29171,6 +30013,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -29187,8 +30036,8 @@ If another Expression instance is passed, -
    3154class LTE(Binary, Predicate):
    -3155    pass
    +            
    3281class LTE(Binary, Predicate):
    +3282    pass
     
    @@ -29241,6 +30090,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -29257,8 +30113,8 @@ If another Expression instance is passed, -
    3158class Mod(Binary):
    -3159    pass
    +            
    3285class Mod(Binary):
    +3286    pass
     
    @@ -29306,6 +30162,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -29321,8 +30190,8 @@ If another Expression instance is passed, -
    3162class Mul(Binary):
    -3163    pass
    +            
    3289class Mul(Binary):
    +3290    pass
     
    @@ -29370,6 +30239,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -29385,8 +30267,8 @@ If another Expression instance is passed, -
    3166class NEQ(Binary, Predicate):
    -3167    pass
    +            
    3293class NEQ(Binary, Predicate):
    +3294    pass
     
    @@ -29439,6 +30321,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -29455,8 +30344,8 @@ If another Expression instance is passed, -
    3170class SimilarTo(Binary, Predicate):
    -3171    pass
    +            
    3297class SimilarTo(Binary, Predicate):
    +3298    pass
     
    @@ -29509,6 +30398,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -29525,8 +30421,8 @@ If another Expression instance is passed, -
    3174class Slice(Binary):
    -3175    arg_types = {"this": False, "expression": False}
    +            
    3301class Slice(Binary):
    +3302    arg_types = {"this": False, "expression": False}
     
    @@ -29574,6 +30470,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -29589,8 +30498,8 @@ If another Expression instance is passed, -
    3178class Sub(Binary):
    -3179    pass
    +            
    3305class Sub(Binary):
    +3306    pass
     
    @@ -29638,6 +30547,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -29653,8 +30575,8 @@ If another Expression instance is passed, -
    3182class ArrayOverlaps(Binary):
    -3183    pass
    +            
    3309class ArrayOverlaps(Binary):
    +3310    pass
     
    @@ -29702,6 +30624,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -29711,14 +30646,14 @@ If another Expression instance is passed,
    class - Unary(Expression): + Unary(Condition):
    -
    3188class Unary(Expression):
    -3189    pass
    +            
    3315class Unary(Condition):
    +3316    pass
     
    @@ -29766,6 +30701,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -29781,8 +30729,8 @@ If another Expression instance is passed, -
    3192class BitwiseNot(Unary):
    -3193    pass
    +            
    3319class BitwiseNot(Unary):
    +3320    pass
     
    @@ -29830,6 +30778,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -29839,14 +30800,14 @@ If another Expression instance is passed,
    class - Not(Unary, Condition): + Not(Unary):
    -
    3196class Not(Unary, Condition):
    -3197    pass
    +            
    3323class Not(Unary):
    +3324    pass
     
    @@ -29899,6 +30860,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -29909,14 +30877,14 @@ If another Expression instance is passed,
    class - Paren(Unary, Condition): + Paren(Unary):
    -
    3200class Paren(Unary, Condition):
    -3201    arg_types = {"this": True, "with": False}
    +            
    3327class Paren(Unary):
    +3328    arg_types = {"this": True, "with": False}
     
    @@ -29969,6 +30937,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -29985,8 +30960,8 @@ If another Expression instance is passed, -
    3204class Neg(Unary):
    -3205    pass
    +            
    3331class Neg(Unary):
    +3332    pass
     
    @@ -30034,6 +31009,19 @@ If another Expression instance is passed,
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -30049,12 +31037,12 @@ If another Expression instance is passed, -
    3208class Alias(Expression):
    -3209    arg_types = {"this": True, "alias": False}
    -3210
    -3211    @property
    -3212    def output_name(self):
    -3213        return self.alias
    +            
    3335class Alias(Expression):
    +3336    arg_types = {"this": True, "alias": False}
    +3337
    +3338    @property
    +3339    def output_name(self):
    +3340        return self.alias
     
    @@ -30146,12 +31134,12 @@ If another Expression instance is passed,
    -
    3216class Aliases(Expression):
    -3217    arg_types = {"this": True, "expressions": True}
    -3218
    -3219    @property
    -3220    def aliases(self):
    -3221        return self.expressions
    +            
    3343class Aliases(Expression):
    +3344    arg_types = {"this": True, "expressions": True}
    +3345
    +3346    @property
    +3347    def aliases(self):
    +3348        return self.expressions
     
    @@ -30214,8 +31202,8 @@ If another Expression instance is passed,
    -
    3224class AtTimeZone(Expression):
    -3225    arg_types = {"this": True, "zone": True}
    +            
    3351class AtTimeZone(Expression):
    +3352    arg_types = {"this": True, "zone": True}
     
    @@ -30278,8 +31266,8 @@ If another Expression instance is passed,
    -
    3228class Between(Predicate):
    -3229    arg_types = {"this": True, "low": True, "high": True}
    +            
    3355class Between(Predicate):
    +3356    arg_types = {"this": True, "low": True, "high": True}
     
    @@ -30332,6 +31320,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -30348,8 +31343,8 @@ If another Expression instance is passed, -
    3232class Bracket(Condition):
    -3233    arg_types = {"this": True, "expressions": True}
    +            
    3359class Bracket(Condition):
    +3360    arg_types = {"this": True, "expressions": True}
     
    @@ -30402,6 +31397,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -30418,8 +31420,8 @@ If another Expression instance is passed, -
    3236class Distinct(Expression):
    -3237    arg_types = {"expressions": False, "on": False}
    +            
    3363class Distinct(Expression):
    +3364    arg_types = {"expressions": False, "on": False}
     
    @@ -30482,15 +31484,15 @@ If another Expression instance is passed,
    -
    3240class In(Predicate):
    -3241    arg_types = {
    -3242        "this": True,
    -3243        "expressions": False,
    -3244        "query": False,
    -3245        "unnest": False,
    -3246        "field": False,
    -3247        "is_global": False,
    -3248    }
    +            
    3367class In(Predicate):
    +3368    arg_types = {
    +3369        "this": True,
    +3370        "expressions": False,
    +3371        "query": False,
    +3372        "unnest": False,
    +3373        "field": False,
    +3374        "is_global": False,
    +3375    }
     
    @@ -30543,6 +31545,13 @@ If another Expression instance is passed,
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -30559,18 +31568,18 @@ If another Expression instance is passed, -
    3251class TimeUnit(Expression):
    -3252    """Automatically converts unit arg into a var."""
    -3253
    -3254    arg_types = {"unit": False}
    -3255
    -3256    def __init__(self, **args):
    -3257        unit = args.get("unit")
    -3258        if isinstance(unit, (Column, Literal)):
    -3259            args["unit"] = Var(this=unit.name)
    -3260        elif isinstance(unit, Week):
    -3261            unit.set("this", Var(this=unit.this.name))
    -3262        super().__init__(**args)
    +            
    3378class TimeUnit(Expression):
    +3379    """Automatically converts unit arg into a var."""
    +3380
    +3381    arg_types = {"unit": False}
    +3382
    +3383    def __init__(self, **args):
    +3384        unit = args.get("unit")
    +3385        if isinstance(unit, (Column, Literal)):
    +3386            args["unit"] = Var(this=unit.name)
    +3387        elif isinstance(unit, Week):
    +3388            unit.set("this", Var(this=unit.this.name))
    +3389        super().__init__(**args)
     
    @@ -30588,13 +31597,13 @@ If another Expression instance is passed,
    -
    3256    def __init__(self, **args):
    -3257        unit = args.get("unit")
    -3258        if isinstance(unit, (Column, Literal)):
    -3259            args["unit"] = Var(this=unit.name)
    -3260        elif isinstance(unit, Week):
    -3261            unit.set("this", Var(this=unit.this.name))
    -3262        super().__init__(**args)
    +            
    3383    def __init__(self, **args):
    +3384        unit = args.get("unit")
    +3385        if isinstance(unit, (Column, Literal)):
    +3386            args["unit"] = Var(this=unit.name)
    +3387        elif isinstance(unit, Week):
    +3388            unit.set("this", Var(this=unit.this.name))
    +3389        super().__init__(**args)
     
    @@ -30657,8 +31666,8 @@ If another Expression instance is passed,
    -
    3265class Interval(TimeUnit):
    -3266    arg_types = {"this": False, "unit": False}
    +            
    3392class Interval(TimeUnit):
    +3393    arg_types = {"this": False, "unit": False}
     
    @@ -30724,8 +31733,8 @@ If another Expression instance is passed,
    -
    3269class IgnoreNulls(Expression):
    -3270    pass
    +            
    3396class IgnoreNulls(Expression):
    +3397    pass
     
    @@ -30788,8 +31797,8 @@ If another Expression instance is passed,
    -
    3273class RespectNulls(Expression):
    -3274    pass
    +            
    3400class RespectNulls(Expression):
    +3401    pass
     
    @@ -30852,53 +31861,53 @@ If another Expression instance is passed,
    -
    3278class Func(Condition):
    -3279    """
    -3280    The base class for all function expressions.
    -3281
    -3282    Attributes:
    -3283        is_var_len_args (bool): if set to True the last argument defined in arg_types will be
    -3284            treated as a variable length argument and the argument's value will be stored as a list.
    -3285        _sql_names (list): determines the SQL name (1st item in the list) and aliases (subsequent items)
    -3286            for this function expression. These values are used to map this node to a name during parsing
    -3287            as well as to provide the function's name during SQL string generation. By default the SQL
    -3288            name is set to the expression's class name transformed to snake case.
    -3289    """
    -3290
    -3291    is_var_len_args = False
    -3292
    -3293    @classmethod
    -3294    def from_arg_list(cls, args):
    -3295        if cls.is_var_len_args:
    -3296            all_arg_keys = list(cls.arg_types)
    -3297            # If this function supports variable length argument treat the last argument as such.
    -3298            non_var_len_arg_keys = all_arg_keys[:-1] if cls.is_var_len_args else all_arg_keys
    -3299            num_non_var = len(non_var_len_arg_keys)
    -3300
    -3301            args_dict = {arg_key: arg for arg, arg_key in zip(args, non_var_len_arg_keys)}
    -3302            args_dict[all_arg_keys[-1]] = args[num_non_var:]
    -3303        else:
    -3304            args_dict = {arg_key: arg for arg, arg_key in zip(args, cls.arg_types)}
    -3305
    -3306        return cls(**args_dict)
    -3307
    -3308    @classmethod
    -3309    def sql_names(cls):
    -3310        if cls is Func:
    -3311            raise NotImplementedError(
    -3312                "SQL name is only supported by concrete function implementations"
    -3313            )
    -3314        if "_sql_names" not in cls.__dict__:
    -3315            cls._sql_names = [camel_to_snake_case(cls.__name__)]
    -3316        return cls._sql_names
    -3317
    -3318    @classmethod
    -3319    def sql_name(cls):
    -3320        return cls.sql_names()[0]
    -3321
    -3322    @classmethod
    -3323    def default_parser_mappings(cls):
    -3324        return {name: cls.from_arg_list for name in cls.sql_names()}
    +            
    3405class Func(Condition):
    +3406    """
    +3407    The base class for all function expressions.
    +3408
    +3409    Attributes:
    +3410        is_var_len_args (bool): if set to True the last argument defined in arg_types will be
    +3411            treated as a variable length argument and the argument's value will be stored as a list.
    +3412        _sql_names (list): determines the SQL name (1st item in the list) and aliases (subsequent items)
    +3413            for this function expression. These values are used to map this node to a name during parsing
    +3414            as well as to provide the function's name during SQL string generation. By default the SQL
    +3415            name is set to the expression's class name transformed to snake case.
    +3416    """
    +3417
    +3418    is_var_len_args = False
    +3419
    +3420    @classmethod
    +3421    def from_arg_list(cls, args):
    +3422        if cls.is_var_len_args:
    +3423            all_arg_keys = list(cls.arg_types)
    +3424            # If this function supports variable length argument treat the last argument as such.
    +3425            non_var_len_arg_keys = all_arg_keys[:-1] if cls.is_var_len_args else all_arg_keys
    +3426            num_non_var = len(non_var_len_arg_keys)
    +3427
    +3428            args_dict = {arg_key: arg for arg, arg_key in zip(args, non_var_len_arg_keys)}
    +3429            args_dict[all_arg_keys[-1]] = args[num_non_var:]
    +3430        else:
    +3431            args_dict = {arg_key: arg for arg, arg_key in zip(args, cls.arg_types)}
    +3432
    +3433        return cls(**args_dict)
    +3434
    +3435    @classmethod
    +3436    def sql_names(cls):
    +3437        if cls is Func:
    +3438            raise NotImplementedError(
    +3439                "SQL name is only supported by concrete function implementations"
    +3440            )
    +3441        if "_sql_names" not in cls.__dict__:
    +3442            cls._sql_names = [camel_to_snake_case(cls.__name__)]
    +3443        return cls._sql_names
    +3444
    +3445    @classmethod
    +3446    def sql_name(cls):
    +3447        return cls.sql_names()[0]
    +3448
    +3449    @classmethod
    +3450    def default_parser_mappings(cls):
    +3451        return {name: cls.from_arg_list for name in cls.sql_names()}
     
    @@ -30929,20 +31938,20 @@ name is set to the expression's class name transformed to snake case.
    -
    3293    @classmethod
    -3294    def from_arg_list(cls, args):
    -3295        if cls.is_var_len_args:
    -3296            all_arg_keys = list(cls.arg_types)
    -3297            # If this function supports variable length argument treat the last argument as such.
    -3298            non_var_len_arg_keys = all_arg_keys[:-1] if cls.is_var_len_args else all_arg_keys
    -3299            num_non_var = len(non_var_len_arg_keys)
    -3300
    -3301            args_dict = {arg_key: arg for arg, arg_key in zip(args, non_var_len_arg_keys)}
    -3302            args_dict[all_arg_keys[-1]] = args[num_non_var:]
    -3303        else:
    -3304            args_dict = {arg_key: arg for arg, arg_key in zip(args, cls.arg_types)}
    -3305
    -3306        return cls(**args_dict)
    +            
    3420    @classmethod
    +3421    def from_arg_list(cls, args):
    +3422        if cls.is_var_len_args:
    +3423            all_arg_keys = list(cls.arg_types)
    +3424            # If this function supports variable length argument treat the last argument as such.
    +3425            non_var_len_arg_keys = all_arg_keys[:-1] if cls.is_var_len_args else all_arg_keys
    +3426            num_non_var = len(non_var_len_arg_keys)
    +3427
    +3428            args_dict = {arg_key: arg for arg, arg_key in zip(args, non_var_len_arg_keys)}
    +3429            args_dict[all_arg_keys[-1]] = args[num_non_var:]
    +3430        else:
    +3431            args_dict = {arg_key: arg for arg, arg_key in zip(args, cls.arg_types)}
    +3432
    +3433        return cls(**args_dict)
     
    @@ -30961,15 +31970,15 @@ name is set to the expression's class name transformed to snake case.
    -
    3308    @classmethod
    -3309    def sql_names(cls):
    -3310        if cls is Func:
    -3311            raise NotImplementedError(
    -3312                "SQL name is only supported by concrete function implementations"
    -3313            )
    -3314        if "_sql_names" not in cls.__dict__:
    -3315            cls._sql_names = [camel_to_snake_case(cls.__name__)]
    -3316        return cls._sql_names
    +            
    3435    @classmethod
    +3436    def sql_names(cls):
    +3437        if cls is Func:
    +3438            raise NotImplementedError(
    +3439                "SQL name is only supported by concrete function implementations"
    +3440            )
    +3441        if "_sql_names" not in cls.__dict__:
    +3442            cls._sql_names = [camel_to_snake_case(cls.__name__)]
    +3443        return cls._sql_names
     
    @@ -30988,9 +31997,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3318    @classmethod
    -3319    def sql_name(cls):
    -3320        return cls.sql_names()[0]
    +            
    3445    @classmethod
    +3446    def sql_name(cls):
    +3447        return cls.sql_names()[0]
     
    @@ -31009,9 +32018,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3322    @classmethod
    -3323    def default_parser_mappings(cls):
    -3324        return {name: cls.from_arg_list for name in cls.sql_names()}
    +            
    3449    @classmethod
    +3450    def default_parser_mappings(cls):
    +3451        return {name: cls.from_arg_list for name in cls.sql_names()}
     
    @@ -31065,6 +32074,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -31081,8 +32097,8 @@ name is set to the expression's class name transformed to snake case. -
    3327class AggFunc(Func):
    -3328    pass
    +            
    3454class AggFunc(Func):
    +3455    pass
     
    @@ -31142,6 +32158,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -31158,8 +32181,8 @@ name is set to the expression's class name transformed to snake case. -
    3331class Abs(Func):
    -3332    pass
    +            
    3458class Abs(Func):
    +3459    pass
     
    @@ -31219,6 +32242,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -31235,9 +32265,9 @@ name is set to the expression's class name transformed to snake case. -
    3335class Anonymous(Func):
    -3336    arg_types = {"this": True, "expressions": False}
    -3337    is_var_len_args = True
    +            
    3462class Anonymous(Func):
    +3463    arg_types = {"this": True, "expressions": False}
    +3464    is_var_len_args = True
     
    @@ -31297,6 +32327,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -31313,9 +32350,9 @@ name is set to the expression's class name transformed to snake case. -
    3342class Hll(AggFunc):
    -3343    arg_types = {"this": True, "expressions": False}
    -3344    is_var_len_args = True
    +            
    3469class Hll(AggFunc):
    +3470    arg_types = {"this": True, "expressions": False}
    +3471    is_var_len_args = True
     
    @@ -31375,6 +32412,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -31391,8 +32435,8 @@ name is set to the expression's class name transformed to snake case. -
    3347class ApproxDistinct(AggFunc):
    -3348    arg_types = {"this": True, "accuracy": False}
    +            
    3474class ApproxDistinct(AggFunc):
    +3475    arg_types = {"this": True, "accuracy": False}
     
    @@ -31452,6 +32496,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -31468,9 +32519,9 @@ name is set to the expression's class name transformed to snake case. -
    3351class Array(Func):
    -3352    arg_types = {"expressions": False}
    -3353    is_var_len_args = True
    +            
    3478class Array(Func):
    +3479    arg_types = {"expressions": False}
    +3480    is_var_len_args = True
     
    @@ -31530,6 +32581,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -31546,8 +32604,8 @@ name is set to the expression's class name transformed to snake case. -
    3357class ToChar(Func):
    -3358    arg_types = {"this": True, "format": False}
    +            
    3484class ToChar(Func):
    +3485    arg_types = {"this": True, "format": False}
     
    @@ -31607,6 +32665,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -31623,8 +32688,8 @@ name is set to the expression's class name transformed to snake case. -
    3361class GenerateSeries(Func):
    -3362    arg_types = {"start": True, "end": True, "step": False}
    +            
    3488class GenerateSeries(Func):
    +3489    arg_types = {"start": True, "end": True, "step": False}
     
    @@ -31684,6 +32749,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -31700,8 +32772,8 @@ name is set to the expression's class name transformed to snake case. -
    3365class ArrayAgg(AggFunc):
    -3366    pass
    +            
    3492class ArrayAgg(AggFunc):
    +3493    pass
     
    @@ -31761,6 +32833,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -31777,8 +32856,8 @@ name is set to the expression's class name transformed to snake case. -
    3369class ArrayAll(Func):
    -3370    arg_types = {"this": True, "expression": True}
    +            
    3496class ArrayAll(Func):
    +3497    arg_types = {"this": True, "expression": True}
     
    @@ -31838,6 +32917,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -31854,8 +32940,8 @@ name is set to the expression's class name transformed to snake case. -
    3373class ArrayAny(Func):
    -3374    arg_types = {"this": True, "expression": True}
    +            
    3500class ArrayAny(Func):
    +3501    arg_types = {"this": True, "expression": True}
     
    @@ -31915,6 +33001,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -31931,9 +33024,9 @@ name is set to the expression's class name transformed to snake case. -
    3377class ArrayConcat(Func):
    -3378    arg_types = {"this": True, "expressions": False}
    -3379    is_var_len_args = True
    +            
    3504class ArrayConcat(Func):
    +3505    arg_types = {"this": True, "expressions": False}
    +3506    is_var_len_args = True
     
    @@ -31993,6 +33086,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -32009,8 +33109,8 @@ name is set to the expression's class name transformed to snake case. -
    3382class ArrayContains(Binary, Func):
    -3383    pass
    +            
    3509class ArrayContains(Binary, Func):
    +3510    pass
     
    @@ -32070,6 +33170,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -32086,8 +33193,8 @@ name is set to the expression's class name transformed to snake case. -
    3386class ArrayContained(Binary):
    -3387    pass
    +            
    3513class ArrayContained(Binary):
    +3514    pass
     
    @@ -32135,6 +33242,19 @@ name is set to the expression's class name transformed to snake case.
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -32150,9 +33270,9 @@ name is set to the expression's class name transformed to snake case. -
    3390class ArrayFilter(Func):
    -3391    arg_types = {"this": True, "expression": True}
    -3392    _sql_names = ["FILTER", "ARRAY_FILTER"]
    +            
    3517class ArrayFilter(Func):
    +3518    arg_types = {"this": True, "expression": True}
    +3519    _sql_names = ["FILTER", "ARRAY_FILTER"]
     
    @@ -32212,6 +33332,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -32228,8 +33355,8 @@ name is set to the expression's class name transformed to snake case. -
    3395class ArrayJoin(Func):
    -3396    arg_types = {"this": True, "expression": True, "null": False}
    +            
    3522class ArrayJoin(Func):
    +3523    arg_types = {"this": True, "expression": True, "null": False}
     
    @@ -32289,6 +33416,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -32305,8 +33439,8 @@ name is set to the expression's class name transformed to snake case. -
    3399class ArraySize(Func):
    -3400    arg_types = {"this": True, "expression": False}
    +            
    3526class ArraySize(Func):
    +3527    arg_types = {"this": True, "expression": False}
     
    @@ -32366,6 +33500,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -32382,8 +33523,8 @@ name is set to the expression's class name transformed to snake case. -
    3403class ArraySort(Func):
    -3404    arg_types = {"this": True, "expression": False}
    +            
    3530class ArraySort(Func):
    +3531    arg_types = {"this": True, "expression": False}
     
    @@ -32443,6 +33584,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -32459,8 +33607,8 @@ name is set to the expression's class name transformed to snake case. -
    3407class ArraySum(Func):
    -3408    pass
    +            
    3534class ArraySum(Func):
    +3535    pass
     
    @@ -32520,6 +33668,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -32536,8 +33691,8 @@ name is set to the expression's class name transformed to snake case. -
    3411class ArrayUnionAgg(AggFunc):
    -3412    pass
    +            
    3538class ArrayUnionAgg(AggFunc):
    +3539    pass
     
    @@ -32597,6 +33752,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -32613,8 +33775,8 @@ name is set to the expression's class name transformed to snake case. -
    3415class Avg(AggFunc):
    -3416    pass
    +            
    3542class Avg(AggFunc):
    +3543    pass
     
    @@ -32674,6 +33836,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -32690,8 +33859,8 @@ name is set to the expression's class name transformed to snake case. -
    3419class AnyValue(AggFunc):
    -3420    pass
    +            
    3546class AnyValue(AggFunc):
    +3547    pass
     
    @@ -32751,6 +33920,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -32767,13 +33943,77 @@ name is set to the expression's class name transformed to snake case. -
    3423class Case(Func):
    -3424    arg_types = {"this": False, "ifs": True, "default": False}
    +            
    3550class Case(Func):
    +3551    arg_types = {"this": False, "ifs": True, "default": False}
    +3552
    +3553    def when(self, condition: ExpOrStr, then: ExpOrStr, copy: bool = True, **opts) -> Case:
    +3554        instance = _maybe_copy(self, copy)
    +3555        instance.append(
    +3556            "ifs",
    +3557            If(
    +3558                this=maybe_parse(condition, copy=copy, **opts),
    +3559                true=maybe_parse(then, copy=copy, **opts),
    +3560            ),
    +3561        )
    +3562        return instance
    +3563
    +3564    def else_(self, condition: ExpOrStr, copy: bool = True, **opts) -> Case:
    +3565        instance = _maybe_copy(self, copy)
    +3566        instance.set("default", maybe_parse(condition, copy=copy, **opts))
    +3567        return instance
    +
    + + + + +
    + +
    + + def + when( self, condition: Union[str, sqlglot.expressions.Expression], then: Union[str, sqlglot.expressions.Expression], copy: bool = True, **opts) -> sqlglot.expressions.Case: + + + +
    + +
    3553    def when(self, condition: ExpOrStr, then: ExpOrStr, copy: bool = True, **opts) -> Case:
    +3554        instance = _maybe_copy(self, copy)
    +3555        instance.append(
    +3556            "ifs",
    +3557            If(
    +3558                this=maybe_parse(condition, copy=copy, **opts),
    +3559                true=maybe_parse(then, copy=copy, **opts),
    +3560            ),
    +3561        )
    +3562        return instance
    +
    + + + + +
    +
    + +
    + + def + else_( self, condition: Union[str, sqlglot.expressions.Expression], copy: bool = True, **opts) -> sqlglot.expressions.Case: + + + +
    + +
    3564    def else_(self, condition: ExpOrStr, copy: bool = True, **opts) -> Case:
    +3565        instance = _maybe_copy(self, copy)
    +3566        instance.set("default", maybe_parse(condition, copy=copy, **opts))
    +3567        return instance
     
    +
    Inherited Members
    @@ -32828,6 +34068,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -32844,23 +34091,23 @@ name is set to the expression's class name transformed to snake case.
    -
    3427class Cast(Func):
    -3428    arg_types = {"this": True, "to": True}
    -3429
    -3430    @property
    -3431    def name(self) -> str:
    -3432        return self.this.name
    -3433
    -3434    @property
    -3435    def to(self):
    -3436        return self.args["to"]
    -3437
    -3438    @property
    -3439    def output_name(self):
    -3440        return self.name
    -3441
    -3442    def is_type(self, dtype: DataType.Type) -> bool:
    -3443        return self.to.is_type(dtype)
    +            
    3570class Cast(Func):
    +3571    arg_types = {"this": True, "to": True}
    +3572
    +3573    @property
    +3574    def name(self) -> str:
    +3575        return self.this.name
    +3576
    +3577    @property
    +3578    def to(self):
    +3579        return self.args["to"]
    +3580
    +3581    @property
    +3582    def output_name(self):
    +3583        return self.name
    +3584
    +3585    def is_type(self, dtype: DataType.Type) -> bool:
    +3586        return self.to.is_type(dtype)
     
    @@ -32907,8 +34154,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3442    def is_type(self, dtype: DataType.Type) -> bool:
    -3443        return self.to.is_type(dtype)
    +            
    3585    def is_type(self, dtype: DataType.Type) -> bool:
    +3586        return self.to.is_type(dtype)
     
    @@ -32968,6 +34215,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -32984,8 +34238,8 @@ name is set to the expression's class name transformed to snake case. -
    3446class Collate(Binary):
    -3447    pass
    +            
    3589class Collate(Binary):
    +3590    pass
     
    @@ -33033,6 +34287,19 @@ name is set to the expression's class name transformed to snake case.
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -33048,8 +34315,8 @@ name is set to the expression's class name transformed to snake case. -
    3450class TryCast(Cast):
    -3451    pass
    +            
    3593class TryCast(Cast):
    +3594    pass
     
    @@ -33113,6 +34380,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -33129,9 +34403,9 @@ name is set to the expression's class name transformed to snake case. -
    3454class Ceil(Func):
    -3455    arg_types = {"this": True, "decimals": False}
    -3456    _sql_names = ["CEIL", "CEILING"]
    +            
    3597class Ceil(Func):
    +3598    arg_types = {"this": True, "decimals": False}
    +3599    _sql_names = ["CEIL", "CEILING"]
     
    @@ -33191,6 +34465,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -33207,9 +34488,9 @@ name is set to the expression's class name transformed to snake case. -
    3459class Coalesce(Func):
    -3460    arg_types = {"this": True, "expressions": False}
    -3461    is_var_len_args = True
    +            
    3602class Coalesce(Func):
    +3603    arg_types = {"this": True, "expressions": False}
    +3604    is_var_len_args = True
     
    @@ -33269,6 +34550,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -33285,9 +34573,9 @@ name is set to the expression's class name transformed to snake case. -
    3464class Concat(Func):
    -3465    arg_types = {"expressions": True}
    -3466    is_var_len_args = True
    +            
    3607class Concat(Func):
    +3608    arg_types = {"expressions": True}
    +3609    is_var_len_args = True
     
    @@ -33347,6 +34635,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -33363,8 +34658,8 @@ name is set to the expression's class name transformed to snake case. -
    3469class ConcatWs(Concat):
    -3470    _sql_names = ["CONCAT_WS"]
    +            
    3612class ConcatWs(Concat):
    +3613    _sql_names = ["CONCAT_WS"]
     
    @@ -33424,6 +34719,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -33440,8 +34742,8 @@ name is set to the expression's class name transformed to snake case. -
    3473class Count(AggFunc):
    -3474    arg_types = {"this": False}
    +            
    3616class Count(AggFunc):
    +3617    arg_types = {"this": False}
     
    @@ -33501,6 +34803,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -33517,8 +34826,8 @@ name is set to the expression's class name transformed to snake case. -
    3477class CountIf(AggFunc):
    -3478    pass
    +            
    3620class CountIf(AggFunc):
    +3621    pass
     
    @@ -33578,6 +34887,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -33594,8 +34910,8 @@ name is set to the expression's class name transformed to snake case. -
    3481class CurrentDate(Func):
    -3482    arg_types = {"this": False}
    +            
    3624class CurrentDate(Func):
    +3625    arg_types = {"this": False}
     
    @@ -33655,6 +34971,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -33671,8 +34994,8 @@ name is set to the expression's class name transformed to snake case. -
    3485class CurrentDatetime(Func):
    -3486    arg_types = {"this": False}
    +            
    3628class CurrentDatetime(Func):
    +3629    arg_types = {"this": False}
     
    @@ -33732,6 +35055,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -33748,8 +35078,8 @@ name is set to the expression's class name transformed to snake case. -
    3489class CurrentTime(Func):
    -3490    arg_types = {"this": False}
    +            
    3632class CurrentTime(Func):
    +3633    arg_types = {"this": False}
     
    @@ -33809,6 +35139,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -33825,8 +35162,8 @@ name is set to the expression's class name transformed to snake case. -
    3493class CurrentTimestamp(Func):
    -3494    arg_types = {"this": False}
    +            
    3636class CurrentTimestamp(Func):
    +3637    arg_types = {"this": False}
     
    @@ -33886,6 +35223,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -33902,8 +35246,8 @@ name is set to the expression's class name transformed to snake case. -
    3497class CurrentUser(Func):
    -3498    arg_types = {"this": False}
    +            
    3640class CurrentUser(Func):
    +3641    arg_types = {"this": False}
     
    @@ -33963,6 +35307,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -33979,8 +35330,8 @@ name is set to the expression's class name transformed to snake case. -
    3501class DateAdd(Func, TimeUnit):
    -3502    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3644class DateAdd(Func, TimeUnit):
    +3645    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -34004,6 +35355,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    Expression
    @@ -34059,8 +35417,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3505class DateSub(Func, TimeUnit):
    -3506    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3648class DateSub(Func, TimeUnit):
    +3649    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -34084,6 +35442,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    Expression
    @@ -34139,9 +35504,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3509class DateDiff(Func, TimeUnit):
    -3510    _sql_names = ["DATEDIFF", "DATE_DIFF"]
    -3511    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3652class DateDiff(Func, TimeUnit):
    +3653    _sql_names = ["DATEDIFF", "DATE_DIFF"]
    +3654    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -34165,6 +35530,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    Expression
    @@ -34220,8 +35592,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3514class DateTrunc(Func):
    -3515    arg_types = {"unit": True, "this": True, "zone": False}
    +            
    3657class DateTrunc(Func):
    +3658    arg_types = {"unit": True, "this": True, "zone": False}
     
    @@ -34281,6 +35653,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -34297,8 +35676,8 @@ name is set to the expression's class name transformed to snake case. -
    3518class DatetimeAdd(Func, TimeUnit):
    -3519    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3661class DatetimeAdd(Func, TimeUnit):
    +3662    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -34322,6 +35701,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    Expression
    @@ -34377,8 +35763,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3522class DatetimeSub(Func, TimeUnit):
    -3523    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3665class DatetimeSub(Func, TimeUnit):
    +3666    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -34402,6 +35788,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    Expression
    @@ -34457,8 +35850,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3526class DatetimeDiff(Func, TimeUnit):
    -3527    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3669class DatetimeDiff(Func, TimeUnit):
    +3670    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -34482,6 +35875,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    Expression
    @@ -34537,8 +35937,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3530class DatetimeTrunc(Func, TimeUnit):
    -3531    arg_types = {"this": True, "unit": True, "zone": False}
    +            
    3673class DatetimeTrunc(Func, TimeUnit):
    +3674    arg_types = {"this": True, "unit": True, "zone": False}
     
    @@ -34562,6 +35962,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    Expression
    @@ -34617,8 +36024,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3534class DayOfWeek(Func):
    -3535    _sql_names = ["DAY_OF_WEEK", "DAYOFWEEK"]
    +            
    3677class DayOfWeek(Func):
    +3678    _sql_names = ["DAY_OF_WEEK", "DAYOFWEEK"]
     
    @@ -34678,6 +36085,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -34694,8 +36108,8 @@ name is set to the expression's class name transformed to snake case. -
    3538class DayOfMonth(Func):
    -3539    _sql_names = ["DAY_OF_MONTH", "DAYOFMONTH"]
    +            
    3681class DayOfMonth(Func):
    +3682    _sql_names = ["DAY_OF_MONTH", "DAYOFMONTH"]
     
    @@ -34755,6 +36169,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -34771,8 +36192,8 @@ name is set to the expression's class name transformed to snake case. -
    3542class DayOfYear(Func):
    -3543    _sql_names = ["DAY_OF_YEAR", "DAYOFYEAR"]
    +            
    3685class DayOfYear(Func):
    +3686    _sql_names = ["DAY_OF_YEAR", "DAYOFYEAR"]
     
    @@ -34832,6 +36253,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -34848,8 +36276,8 @@ name is set to the expression's class name transformed to snake case. -
    3546class WeekOfYear(Func):
    -3547    _sql_names = ["WEEK_OF_YEAR", "WEEKOFYEAR"]
    +            
    3689class WeekOfYear(Func):
    +3690    _sql_names = ["WEEK_OF_YEAR", "WEEKOFYEAR"]
     
    @@ -34909,6 +36337,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -34925,8 +36360,8 @@ name is set to the expression's class name transformed to snake case. -
    3550class LastDateOfMonth(Func):
    -3551    pass
    +            
    3693class LastDateOfMonth(Func):
    +3694    pass
     
    @@ -34986,6 +36421,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -35002,8 +36444,8 @@ name is set to the expression's class name transformed to snake case. -
    3554class Extract(Func):
    -3555    arg_types = {"this": True, "expression": True}
    +            
    3697class Extract(Func):
    +3698    arg_types = {"this": True, "expression": True}
     
    @@ -35063,6 +36505,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -35079,8 +36528,8 @@ name is set to the expression's class name transformed to snake case. -
    3558class TimestampAdd(Func, TimeUnit):
    -3559    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3701class TimestampAdd(Func, TimeUnit):
    +3702    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -35104,6 +36553,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    Expression
    @@ -35159,8 +36615,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3562class TimestampSub(Func, TimeUnit):
    -3563    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3705class TimestampSub(Func, TimeUnit):
    +3706    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -35184,6 +36640,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    Expression
    @@ -35239,8 +36702,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3566class TimestampDiff(Func, TimeUnit):
    -3567    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3709class TimestampDiff(Func, TimeUnit):
    +3710    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -35264,6 +36727,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    Expression
    @@ -35319,8 +36789,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3570class TimestampTrunc(Func, TimeUnit):
    -3571    arg_types = {"this": True, "unit": True, "zone": False}
    +            
    3713class TimestampTrunc(Func, TimeUnit):
    +3714    arg_types = {"this": True, "unit": True, "zone": False}
     
    @@ -35344,6 +36814,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    Expression
    @@ -35399,8 +36876,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3574class TimeAdd(Func, TimeUnit):
    -3575    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3717class TimeAdd(Func, TimeUnit):
    +3718    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -35424,6 +36901,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    Expression
    @@ -35479,8 +36963,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3578class TimeSub(Func, TimeUnit):
    -3579    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3721class TimeSub(Func, TimeUnit):
    +3722    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -35504,6 +36988,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    Expression
    @@ -35559,8 +37050,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3582class TimeDiff(Func, TimeUnit):
    -3583    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3725class TimeDiff(Func, TimeUnit):
    +3726    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -35584,6 +37075,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    Expression
    @@ -35639,8 +37137,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3586class TimeTrunc(Func, TimeUnit):
    -3587    arg_types = {"this": True, "unit": True, "zone": False}
    +            
    3729class TimeTrunc(Func, TimeUnit):
    +3730    arg_types = {"this": True, "unit": True, "zone": False}
     
    @@ -35664,6 +37162,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    Expression
    @@ -35719,9 +37224,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3590class DateFromParts(Func):
    -3591    _sql_names = ["DATEFROMPARTS"]
    -3592    arg_types = {"year": True, "month": True, "day": True}
    +            
    3733class DateFromParts(Func):
    +3734    _sql_names = ["DATEFROMPARTS"]
    +3735    arg_types = {"year": True, "month": True, "day": True}
     
    @@ -35781,6 +37286,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -35797,8 +37309,8 @@ name is set to the expression's class name transformed to snake case. -
    3595class DateStrToDate(Func):
    -3596    pass
    +            
    3738class DateStrToDate(Func):
    +3739    pass
     
    @@ -35858,6 +37370,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -35874,8 +37393,8 @@ name is set to the expression's class name transformed to snake case. -
    3599class DateToDateStr(Func):
    -3600    pass
    +            
    3742class DateToDateStr(Func):
    +3743    pass
     
    @@ -35935,6 +37454,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -35951,8 +37477,8 @@ name is set to the expression's class name transformed to snake case. -
    3603class DateToDi(Func):
    -3604    pass
    +            
    3746class DateToDi(Func):
    +3747    pass
     
    @@ -36012,6 +37538,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -36028,8 +37561,8 @@ name is set to the expression's class name transformed to snake case. -
    3607class Day(Func):
    -3608    pass
    +            
    3750class Day(Func):
    +3751    pass
     
    @@ -36089,6 +37622,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -36105,8 +37645,8 @@ name is set to the expression's class name transformed to snake case. -
    3611class Decode(Func):
    -3612    arg_types = {"this": True, "charset": True, "replace": False}
    +            
    3754class Decode(Func):
    +3755    arg_types = {"this": True, "charset": True, "replace": False}
     
    @@ -36166,6 +37706,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -36182,8 +37729,8 @@ name is set to the expression's class name transformed to snake case. -
    3615class DiToDate(Func):
    -3616    pass
    +            
    3758class DiToDate(Func):
    +3759    pass
     
    @@ -36243,6 +37790,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -36259,8 +37813,8 @@ name is set to the expression's class name transformed to snake case. -
    3619class Encode(Func):
    -3620    arg_types = {"this": True, "charset": True}
    +            
    3762class Encode(Func):
    +3763    arg_types = {"this": True, "charset": True}
     
    @@ -36320,6 +37874,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -36336,8 +37897,8 @@ name is set to the expression's class name transformed to snake case. -
    3623class Exp(Func):
    -3624    pass
    +            
    3766class Exp(Func):
    +3767    pass
     
    @@ -36397,6 +37958,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -36413,8 +37981,8 @@ name is set to the expression's class name transformed to snake case. -
    3627class Explode(Func):
    -3628    pass
    +            
    3770class Explode(Func):
    +3771    pass
     
    @@ -36474,6 +38042,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -36490,8 +38065,8 @@ name is set to the expression's class name transformed to snake case. -
    3631class ExponentialTimeDecayedAvg(AggFunc):
    -3632    arg_types = {"this": True, "time": False, "decay": False}
    +            
    3774class ExponentialTimeDecayedAvg(AggFunc):
    +3775    arg_types = {"this": True, "time": False, "decay": False}
     
    @@ -36551,6 +38126,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -36567,8 +38149,8 @@ name is set to the expression's class name transformed to snake case. -
    3635class Floor(Func):
    -3636    arg_types = {"this": True, "decimals": False}
    +            
    3778class Floor(Func):
    +3779    arg_types = {"this": True, "decimals": False}
     
    @@ -36628,6 +38210,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -36644,9 +38233,9 @@ name is set to the expression's class name transformed to snake case. -
    3639class Greatest(Func):
    -3640    arg_types = {"this": True, "expressions": False}
    -3641    is_var_len_args = True
    +            
    3782class Greatest(Func):
    +3783    arg_types = {"this": True, "expressions": False}
    +3784    is_var_len_args = True
     
    @@ -36706,6 +38295,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -36722,8 +38318,8 @@ name is set to the expression's class name transformed to snake case. -
    3644class GroupConcat(Func):
    -3645    arg_types = {"this": True, "separator": False}
    +            
    3787class GroupConcat(Func):
    +3788    arg_types = {"this": True, "separator": False}
     
    @@ -36783,6 +38379,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -36799,8 +38402,8 @@ name is set to the expression's class name transformed to snake case. -
    3648class GroupUniqArray(AggFunc):
    -3649    arg_types = {"this": True, "size": False}
    +            
    3791class GroupUniqArray(AggFunc):
    +3792    arg_types = {"this": True, "size": False}
     
    @@ -36860,6 +38463,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -36876,8 +38486,8 @@ name is set to the expression's class name transformed to snake case. -
    3652class Hex(Func):
    -3653    pass
    +            
    3795class Hex(Func):
    +3796    pass
     
    @@ -36937,6 +38547,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -36953,8 +38570,8 @@ name is set to the expression's class name transformed to snake case. -
    3656class Histogram(AggFunc):
    -3657    arg_types = {"this": True, "bins": False}
    +            
    3799class Histogram(AggFunc):
    +3800    arg_types = {"this": True, "bins": False}
     
    @@ -37014,6 +38631,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -37030,8 +38654,8 @@ name is set to the expression's class name transformed to snake case. -
    3660class If(Func):
    -3661    arg_types = {"this": True, "true": True, "false": False}
    +            
    3803class If(Func):
    +3804    arg_types = {"this": True, "true": True, "false": False}
     
    @@ -37091,6 +38715,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -37107,9 +38738,9 @@ name is set to the expression's class name transformed to snake case. -
    3664class IfNull(Func):
    -3665    arg_types = {"this": True, "expression": False}
    -3666    _sql_names = ["IFNULL", "NVL"]
    +            
    3807class IfNull(Func):
    +3808    arg_types = {"this": True, "expression": False}
    +3809    _sql_names = ["IFNULL", "NVL"]
     
    @@ -37169,6 +38800,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -37185,8 +38823,8 @@ name is set to the expression's class name transformed to snake case. -
    3669class Initcap(Func):
    -3670    pass
    +            
    3812class Initcap(Func):
    +3813    pass
     
    @@ -37246,6 +38884,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -37262,8 +38907,8 @@ name is set to the expression's class name transformed to snake case. -
    3673class JSONKeyValue(Expression):
    -3674    arg_types = {"this": True, "expression": True}
    +            
    3816class JSONKeyValue(Expression):
    +3817    arg_types = {"this": True, "expression": True}
     
    @@ -37326,15 +38971,15 @@ name is set to the expression's class name transformed to snake case.
    -
    3677class JSONObject(Func):
    -3678    arg_types = {
    -3679        "expressions": False,
    -3680        "null_handling": False,
    -3681        "unique_keys": False,
    -3682        "return_type": False,
    -3683        "format_json": False,
    -3684        "encoding": False,
    -3685    }
    +            
    3820class JSONObject(Func):
    +3821    arg_types = {
    +3822        "expressions": False,
    +3823        "null_handling": False,
    +3824        "unique_keys": False,
    +3825        "return_type": False,
    +3826        "format_json": False,
    +3827        "encoding": False,
    +3828    }
     
    @@ -37394,6 +39039,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -37410,8 +39062,8 @@ name is set to the expression's class name transformed to snake case. -
    3688class JSONBContains(Binary):
    -3689    _sql_names = ["JSONB_CONTAINS"]
    +            
    3831class JSONBContains(Binary):
    +3832    _sql_names = ["JSONB_CONTAINS"]
     
    @@ -37459,6 +39111,19 @@ name is set to the expression's class name transformed to snake case.
    dump
    load
    +
    +
    Condition
    +
    and_
    +
    or_
    +
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    +
    @@ -37474,8 +39139,8 @@ name is set to the expression's class name transformed to snake case. -
    3692class JSONExtract(Binary, Func):
    -3693    _sql_names = ["JSON_EXTRACT"]
    +            
    3835class JSONExtract(Binary, Func):
    +3836    _sql_names = ["JSON_EXTRACT"]
     
    @@ -37535,6 +39200,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -37551,8 +39223,8 @@ name is set to the expression's class name transformed to snake case. -
    3696class JSONExtractScalar(JSONExtract):
    -3697    _sql_names = ["JSON_EXTRACT_SCALAR"]
    +            
    3839class JSONExtractScalar(JSONExtract):
    +3840    _sql_names = ["JSON_EXTRACT_SCALAR"]
     
    @@ -37612,6 +39284,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -37628,8 +39307,8 @@ name is set to the expression's class name transformed to snake case. -
    3700class JSONBExtract(JSONExtract):
    -3701    _sql_names = ["JSONB_EXTRACT"]
    +            
    3843class JSONBExtract(JSONExtract):
    +3844    _sql_names = ["JSONB_EXTRACT"]
     
    @@ -37689,6 +39368,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -37705,8 +39391,8 @@ name is set to the expression's class name transformed to snake case. -
    3704class JSONBExtractScalar(JSONExtract):
    -3705    _sql_names = ["JSONB_EXTRACT_SCALAR"]
    +            
    3847class JSONBExtractScalar(JSONExtract):
    +3848    _sql_names = ["JSONB_EXTRACT_SCALAR"]
     
    @@ -37766,6 +39452,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -37782,9 +39475,9 @@ name is set to the expression's class name transformed to snake case. -
    3708class JSONFormat(Func):
    -3709    arg_types = {"this": False, "options": False}
    -3710    _sql_names = ["JSON_FORMAT"]
    +            
    3851class JSONFormat(Func):
    +3852    arg_types = {"this": False, "options": False}
    +3853    _sql_names = ["JSON_FORMAT"]
     
    @@ -37844,6 +39537,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -37860,9 +39560,9 @@ name is set to the expression's class name transformed to snake case. -
    3713class Least(Func):
    -3714    arg_types = {"expressions": False}
    -3715    is_var_len_args = True
    +            
    3856class Least(Func):
    +3857    arg_types = {"expressions": False}
    +3858    is_var_len_args = True
     
    @@ -37922,6 +39622,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -37938,8 +39645,8 @@ name is set to the expression's class name transformed to snake case. -
    3718class Length(Func):
    -3719    pass
    +            
    3861class Length(Func):
    +3862    pass
     
    @@ -37999,6 +39706,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -38015,14 +39729,14 @@ name is set to the expression's class name transformed to snake case. -
    3722class Levenshtein(Func):
    -3723    arg_types = {
    -3724        "this": True,
    -3725        "expression": False,
    -3726        "ins_cost": False,
    -3727        "del_cost": False,
    -3728        "sub_cost": False,
    -3729    }
    +            
    3865class Levenshtein(Func):
    +3866    arg_types = {
    +3867        "this": True,
    +3868        "expression": False,
    +3869        "ins_cost": False,
    +3870        "del_cost": False,
    +3871        "sub_cost": False,
    +3872    }
     
    @@ -38082,6 +39796,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -38098,8 +39819,8 @@ name is set to the expression's class name transformed to snake case. -
    3732class Ln(Func):
    -3733    pass
    +            
    3875class Ln(Func):
    +3876    pass
     
    @@ -38159,6 +39880,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -38175,8 +39903,8 @@ name is set to the expression's class name transformed to snake case. -
    3736class Log(Func):
    -3737    arg_types = {"this": True, "expression": False}
    +            
    3879class Log(Func):
    +3880    arg_types = {"this": True, "expression": False}
     
    @@ -38236,6 +39964,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -38252,8 +39987,8 @@ name is set to the expression's class name transformed to snake case. -
    3740class Log2(Func):
    -3741    pass
    +            
    3883class Log2(Func):
    +3884    pass
     
    @@ -38313,6 +40048,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -38329,8 +40071,8 @@ name is set to the expression's class name transformed to snake case. -
    3744class Log10(Func):
    -3745    pass
    +            
    3887class Log10(Func):
    +3888    pass
     
    @@ -38390,6 +40132,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -38406,8 +40155,8 @@ name is set to the expression's class name transformed to snake case. -
    3748class LogicalOr(AggFunc):
    -3749    _sql_names = ["LOGICAL_OR", "BOOL_OR", "BOOLOR_AGG"]
    +            
    3891class LogicalOr(AggFunc):
    +3892    _sql_names = ["LOGICAL_OR", "BOOL_OR", "BOOLOR_AGG"]
     
    @@ -38467,6 +40216,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -38483,8 +40239,8 @@ name is set to the expression's class name transformed to snake case. -
    3752class LogicalAnd(AggFunc):
    -3753    _sql_names = ["LOGICAL_AND", "BOOL_AND", "BOOLAND_AGG"]
    +            
    3895class LogicalAnd(AggFunc):
    +3896    _sql_names = ["LOGICAL_AND", "BOOL_AND", "BOOLAND_AGG"]
     
    @@ -38544,6 +40300,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -38560,8 +40323,8 @@ name is set to the expression's class name transformed to snake case. -
    3756class Lower(Func):
    -3757    _sql_names = ["LOWER", "LCASE"]
    +            
    3899class Lower(Func):
    +3900    _sql_names = ["LOWER", "LCASE"]
     
    @@ -38621,6 +40384,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -38637,8 +40407,8 @@ name is set to the expression's class name transformed to snake case. -
    3760class Map(Func):
    -3761    arg_types = {"keys": False, "values": False}
    +            
    3903class Map(Func):
    +3904    arg_types = {"keys": False, "values": False}
     
    @@ -38698,6 +40468,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -38714,8 +40491,8 @@ name is set to the expression's class name transformed to snake case. -
    3764class StarMap(Func):
    -3765    pass
    +            
    3907class StarMap(Func):
    +3908    pass
     
    @@ -38775,6 +40552,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -38791,9 +40575,9 @@ name is set to the expression's class name transformed to snake case. -
    3768class VarMap(Func):
    -3769    arg_types = {"keys": True, "values": True}
    -3770    is_var_len_args = True
    +            
    3911class VarMap(Func):
    +3912    arg_types = {"keys": True, "values": True}
    +3913    is_var_len_args = True
     
    @@ -38853,6 +40637,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -38869,8 +40660,8 @@ name is set to the expression's class name transformed to snake case. -
    3774class MatchAgainst(Func):
    -3775    arg_types = {"this": True, "expressions": True, "modifier": False}
    +            
    3917class MatchAgainst(Func):
    +3918    arg_types = {"this": True, "expressions": True, "modifier": False}
     
    @@ -38930,6 +40721,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -38946,9 +40744,9 @@ name is set to the expression's class name transformed to snake case. -
    3778class Max(AggFunc):
    -3779    arg_types = {"this": True, "expressions": False}
    -3780    is_var_len_args = True
    +            
    3921class Max(AggFunc):
    +3922    arg_types = {"this": True, "expressions": False}
    +3923    is_var_len_args = True
     
    @@ -39008,6 +40806,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -39024,8 +40829,8 @@ name is set to the expression's class name transformed to snake case. -
    3783class MD5(Func):
    -3784    _sql_names = ["MD5"]
    +            
    3926class MD5(Func):
    +3927    _sql_names = ["MD5"]
     
    @@ -39085,6 +40890,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -39101,9 +40913,9 @@ name is set to the expression's class name transformed to snake case. -
    3787class Min(AggFunc):
    -3788    arg_types = {"this": True, "expressions": False}
    -3789    is_var_len_args = True
    +            
    3930class Min(AggFunc):
    +3931    arg_types = {"this": True, "expressions": False}
    +3932    is_var_len_args = True
     
    @@ -39163,6 +40975,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -39179,8 +40998,8 @@ name is set to the expression's class name transformed to snake case. -
    3792class Month(Func):
    -3793    pass
    +            
    3935class Month(Func):
    +3936    pass
     
    @@ -39240,6 +41059,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -39256,8 +41082,8 @@ name is set to the expression's class name transformed to snake case. -
    3796class Nvl2(Func):
    -3797    arg_types = {"this": True, "true": True, "false": False}
    +            
    3939class Nvl2(Func):
    +3940    arg_types = {"this": True, "true": True, "false": False}
     
    @@ -39317,6 +41143,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -39333,8 +41166,8 @@ name is set to the expression's class name transformed to snake case. -
    3800class Posexplode(Func):
    -3801    pass
    +            
    3943class Posexplode(Func):
    +3944    pass
     
    @@ -39394,6 +41227,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -39410,8 +41250,8 @@ name is set to the expression's class name transformed to snake case. -
    3804class Pow(Binary, Func):
    -3805    _sql_names = ["POWER", "POW"]
    +            
    3947class Pow(Binary, Func):
    +3948    _sql_names = ["POWER", "POW"]
     
    @@ -39471,6 +41311,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -39487,8 +41334,8 @@ name is set to the expression's class name transformed to snake case. -
    3808class PercentileCont(AggFunc):
    -3809    pass
    +            
    3951class PercentileCont(AggFunc):
    +3952    arg_types = {"this": True, "expression": False}
     
    @@ -39548,6 +41395,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -39564,8 +41418,8 @@ name is set to the expression's class name transformed to snake case. -
    3812class PercentileDisc(AggFunc):
    -3813    pass
    +            
    3955class PercentileDisc(AggFunc):
    +3956    arg_types = {"this": True, "expression": False}
     
    @@ -39625,6 +41479,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -39641,8 +41502,8 @@ name is set to the expression's class name transformed to snake case. -
    3816class Quantile(AggFunc):
    -3817    arg_types = {"this": True, "quantile": True}
    +            
    3959class Quantile(AggFunc):
    +3960    arg_types = {"this": True, "quantile": True}
     
    @@ -39702,6 +41563,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -39718,9 +41586,9 @@ name is set to the expression's class name transformed to snake case. -
    3822class Quantiles(AggFunc):
    -3823    arg_types = {"parameters": True, "expressions": True}
    -3824    is_var_len_args = True
    +            
    3965class Quantiles(AggFunc):
    +3966    arg_types = {"parameters": True, "expressions": True}
    +3967    is_var_len_args = True
     
    @@ -39780,6 +41648,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -39796,8 +41671,8 @@ name is set to the expression's class name transformed to snake case. -
    3827class QuantileIf(AggFunc):
    -3828    arg_types = {"parameters": True, "expressions": True}
    +            
    3970class QuantileIf(AggFunc):
    +3971    arg_types = {"parameters": True, "expressions": True}
     
    @@ -39857,6 +41732,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -39873,8 +41755,8 @@ name is set to the expression's class name transformed to snake case. -
    3831class ApproxQuantile(Quantile):
    -3832    arg_types = {"this": True, "quantile": True, "accuracy": False, "weight": False}
    +            
    3974class ApproxQuantile(Quantile):
    +3975    arg_types = {"this": True, "quantile": True, "accuracy": False, "weight": False}
     
    @@ -39934,6 +41816,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -39950,8 +41839,8 @@ name is set to the expression's class name transformed to snake case. -
    3835class RangeN(Func):
    -3836    arg_types = {"this": True, "expressions": True, "each": False}
    +            
    3978class RangeN(Func):
    +3979    arg_types = {"this": True, "expressions": True, "each": False}
     
    @@ -40011,6 +41900,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -40027,10 +41923,10 @@ name is set to the expression's class name transformed to snake case. -
    3839class ReadCSV(Func):
    -3840    _sql_names = ["READ_CSV"]
    -3841    is_var_len_args = True
    -3842    arg_types = {"this": True, "expressions": False}
    +            
    3982class ReadCSV(Func):
    +3983    _sql_names = ["READ_CSV"]
    +3984    is_var_len_args = True
    +3985    arg_types = {"this": True, "expressions": False}
     
    @@ -40090,6 +41986,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -40106,8 +42009,8 @@ name is set to the expression's class name transformed to snake case. -
    3845class Reduce(Func):
    -3846    arg_types = {"this": True, "initial": True, "merge": True, "finish": False}
    +            
    3988class Reduce(Func):
    +3989    arg_types = {"this": True, "initial": True, "merge": True, "finish": False}
     
    @@ -40167,6 +42070,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -40183,14 +42093,14 @@ name is set to the expression's class name transformed to snake case. -
    3849class RegexpExtract(Func):
    -3850    arg_types = {
    -3851        "this": True,
    -3852        "expression": True,
    -3853        "position": False,
    -3854        "occurrence": False,
    -3855        "group": False,
    -3856    }
    +            
    3992class RegexpExtract(Func):
    +3993    arg_types = {
    +3994        "this": True,
    +3995        "expression": True,
    +3996        "position": False,
    +3997        "occurrence": False,
    +3998        "group": False,
    +3999    }
     
    @@ -40250,6 +42160,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -40266,8 +42183,8 @@ name is set to the expression's class name transformed to snake case. -
    3859class RegexpLike(Func):
    -3860    arg_types = {"this": True, "expression": True, "flag": False}
    +            
    4002class RegexpLike(Func):
    +4003    arg_types = {"this": True, "expression": True, "flag": False}
     
    @@ -40327,6 +42244,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -40343,8 +42267,8 @@ name is set to the expression's class name transformed to snake case. -
    3863class RegexpILike(Func):
    -3864    arg_types = {"this": True, "expression": True, "flag": False}
    +            
    4006class RegexpILike(Func):
    +4007    arg_types = {"this": True, "expression": True, "flag": False}
     
    @@ -40404,6 +42328,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -40420,8 +42351,8 @@ name is set to the expression's class name transformed to snake case. -
    3869class RegexpSplit(Func):
    -3870    arg_types = {"this": True, "expression": True, "limit": False}
    +            
    4012class RegexpSplit(Func):
    +4013    arg_types = {"this": True, "expression": True, "limit": False}
     
    @@ -40481,6 +42412,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -40497,8 +42435,8 @@ name is set to the expression's class name transformed to snake case. -
    3873class Repeat(Func):
    -3874    arg_types = {"this": True, "times": True}
    +            
    4016class Repeat(Func):
    +4017    arg_types = {"this": True, "times": True}
     
    @@ -40558,6 +42496,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -40574,8 +42519,8 @@ name is set to the expression's class name transformed to snake case. -
    3877class Round(Func):
    -3878    arg_types = {"this": True, "decimals": False}
    +            
    4020class Round(Func):
    +4021    arg_types = {"this": True, "decimals": False}
     
    @@ -40635,6 +42580,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -40651,8 +42603,8 @@ name is set to the expression's class name transformed to snake case. -
    3881class RowNumber(Func):
    -3882    arg_types: t.Dict[str, t.Any] = {}
    +            
    4024class RowNumber(Func):
    +4025    arg_types: t.Dict[str, t.Any] = {}
     
    @@ -40712,6 +42664,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -40728,8 +42687,8 @@ name is set to the expression's class name transformed to snake case. -
    3885class SafeDivide(Func):
    -3886    arg_types = {"this": True, "expression": True}
    +            
    4028class SafeDivide(Func):
    +4029    arg_types = {"this": True, "expression": True}
     
    @@ -40789,6 +42748,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -40805,8 +42771,8 @@ name is set to the expression's class name transformed to snake case. -
    3889class SetAgg(AggFunc):
    -3890    pass
    +            
    4032class SetAgg(AggFunc):
    +4033    pass
     
    @@ -40866,6 +42832,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -40882,8 +42855,8 @@ name is set to the expression's class name transformed to snake case. -
    3893class SHA(Func):
    -3894    _sql_names = ["SHA", "SHA1"]
    +            
    4036class SHA(Func):
    +4037    _sql_names = ["SHA", "SHA1"]
     
    @@ -40943,6 +42916,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -40959,9 +42939,9 @@ name is set to the expression's class name transformed to snake case. -
    3897class SHA2(Func):
    -3898    _sql_names = ["SHA2"]
    -3899    arg_types = {"this": True, "length": False}
    +            
    4040class SHA2(Func):
    +4041    _sql_names = ["SHA2"]
    +4042    arg_types = {"this": True, "length": False}
     
    @@ -41021,6 +43001,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -41037,8 +43024,8 @@ name is set to the expression's class name transformed to snake case. -
    3902class SortArray(Func):
    -3903    arg_types = {"this": True, "asc": False}
    +            
    4045class SortArray(Func):
    +4046    arg_types = {"this": True, "asc": False}
     
    @@ -41098,6 +43085,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -41114,8 +43108,8 @@ name is set to the expression's class name transformed to snake case. -
    3906class Split(Func):
    -3907    arg_types = {"this": True, "expression": True, "limit": False}
    +            
    4049class Split(Func):
    +4050    arg_types = {"this": True, "expression": True, "limit": False}
     
    @@ -41175,6 +43169,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -41191,8 +43192,8 @@ name is set to the expression's class name transformed to snake case. -
    3912class Substring(Func):
    -3913    arg_types = {"this": True, "start": False, "length": False}
    +            
    4055class Substring(Func):
    +4056    arg_types = {"this": True, "start": False, "length": False}
     
    @@ -41252,6 +43253,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -41268,13 +43276,13 @@ name is set to the expression's class name transformed to snake case. -
    3916class StrPosition(Func):
    -3917    arg_types = {
    -3918        "this": True,
    -3919        "substr": True,
    -3920        "position": False,
    -3921        "instance": False,
    -3922    }
    +            
    4059class StrPosition(Func):
    +4060    arg_types = {
    +4061        "this": True,
    +4062        "substr": True,
    +4063        "position": False,
    +4064        "instance": False,
    +4065    }
     
    @@ -41334,6 +43342,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -41350,8 +43365,8 @@ name is set to the expression's class name transformed to snake case. -
    3925class StrToDate(Func):
    -3926    arg_types = {"this": True, "format": True}
    +            
    4068class StrToDate(Func):
    +4069    arg_types = {"this": True, "format": True}
     
    @@ -41411,6 +43426,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -41427,8 +43449,8 @@ name is set to the expression's class name transformed to snake case. -
    3929class StrToTime(Func):
    -3930    arg_types = {"this": True, "format": True}
    +            
    4072class StrToTime(Func):
    +4073    arg_types = {"this": True, "format": True}
     
    @@ -41488,6 +43510,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -41504,8 +43533,8 @@ name is set to the expression's class name transformed to snake case. -
    3935class StrToUnix(Func):
    -3936    arg_types = {"this": False, "format": False}
    +            
    4078class StrToUnix(Func):
    +4079    arg_types = {"this": False, "format": False}
     
    @@ -41565,6 +43594,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -41581,8 +43617,8 @@ name is set to the expression's class name transformed to snake case. -
    3939class NumberToStr(Func):
    -3940    arg_types = {"this": True, "format": True}
    +            
    4082class NumberToStr(Func):
    +4083    arg_types = {"this": True, "format": True}
     
    @@ -41642,6 +43678,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -41658,9 +43701,9 @@ name is set to the expression's class name transformed to snake case. -
    3943class Struct(Func):
    -3944    arg_types = {"expressions": True}
    -3945    is_var_len_args = True
    +            
    4086class Struct(Func):
    +4087    arg_types = {"expressions": True}
    +4088    is_var_len_args = True
     
    @@ -41720,6 +43763,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -41736,8 +43786,8 @@ name is set to the expression's class name transformed to snake case. -
    3948class StructExtract(Func):
    -3949    arg_types = {"this": True, "expression": True}
    +            
    4091class StructExtract(Func):
    +4092    arg_types = {"this": True, "expression": True}
     
    @@ -41797,6 +43847,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -41813,8 +43870,8 @@ name is set to the expression's class name transformed to snake case. -
    3952class Sum(AggFunc):
    -3953    pass
    +            
    4095class Sum(AggFunc):
    +4096    pass
     
    @@ -41874,6 +43931,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -41890,8 +43954,8 @@ name is set to the expression's class name transformed to snake case. -
    3956class Sqrt(Func):
    -3957    pass
    +            
    4099class Sqrt(Func):
    +4100    pass
     
    @@ -41951,6 +44015,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -41967,8 +44038,8 @@ name is set to the expression's class name transformed to snake case. -
    3960class Stddev(AggFunc):
    -3961    pass
    +            
    4103class Stddev(AggFunc):
    +4104    pass
     
    @@ -42028,6 +44099,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -42044,8 +44122,8 @@ name is set to the expression's class name transformed to snake case. -
    3964class StddevPop(AggFunc):
    -3965    pass
    +            
    4107class StddevPop(AggFunc):
    +4108    pass
     
    @@ -42105,6 +44183,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -42121,8 +44206,8 @@ name is set to the expression's class name transformed to snake case. -
    3968class StddevSamp(AggFunc):
    -3969    pass
    +            
    4111class StddevSamp(AggFunc):
    +4112    pass
     
    @@ -42182,6 +44267,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -42198,8 +44290,8 @@ name is set to the expression's class name transformed to snake case. -
    3972class TimeToStr(Func):
    -3973    arg_types = {"this": True, "format": True}
    +            
    4115class TimeToStr(Func):
    +4116    arg_types = {"this": True, "format": True}
     
    @@ -42259,6 +44351,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -42275,8 +44374,8 @@ name is set to the expression's class name transformed to snake case. -
    3976class TimeToTimeStr(Func):
    -3977    pass
    +            
    4119class TimeToTimeStr(Func):
    +4120    pass
     
    @@ -42336,6 +44435,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -42352,8 +44458,8 @@ name is set to the expression's class name transformed to snake case. -
    3980class TimeToUnix(Func):
    -3981    pass
    +            
    4123class TimeToUnix(Func):
    +4124    pass
     
    @@ -42413,6 +44519,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -42429,8 +44542,8 @@ name is set to the expression's class name transformed to snake case. -
    3984class TimeStrToDate(Func):
    -3985    pass
    +            
    4127class TimeStrToDate(Func):
    +4128    pass
     
    @@ -42490,6 +44603,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -42506,8 +44626,8 @@ name is set to the expression's class name transformed to snake case. -
    3988class TimeStrToTime(Func):
    -3989    pass
    +            
    4131class TimeStrToTime(Func):
    +4132    pass
     
    @@ -42567,6 +44687,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -42583,8 +44710,8 @@ name is set to the expression's class name transformed to snake case. -
    3992class TimeStrToUnix(Func):
    -3993    pass
    +            
    4135class TimeStrToUnix(Func):
    +4136    pass
     
    @@ -42644,6 +44771,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -42660,13 +44794,13 @@ name is set to the expression's class name transformed to snake case. -
    3996class Trim(Func):
    -3997    arg_types = {
    -3998        "this": True,
    -3999        "expression": False,
    -4000        "position": False,
    -4001        "collation": False,
    -4002    }
    +            
    4139class Trim(Func):
    +4140    arg_types = {
    +4141        "this": True,
    +4142        "expression": False,
    +4143        "position": False,
    +4144        "collation": False,
    +4145    }
     
    @@ -42726,6 +44860,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -42742,8 +44883,8 @@ name is set to the expression's class name transformed to snake case. -
    4005class TsOrDsAdd(Func, TimeUnit):
    -4006    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    4148class TsOrDsAdd(Func, TimeUnit):
    +4149    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -42767,6 +44908,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    Expression
    @@ -42822,8 +44970,8 @@ name is set to the expression's class name transformed to snake case.
    -
    4009class TsOrDsToDateStr(Func):
    -4010    pass
    +            
    4152class TsOrDsToDateStr(Func):
    +4153    pass
     
    @@ -42883,6 +45031,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -42899,8 +45054,8 @@ name is set to the expression's class name transformed to snake case. -
    4013class TsOrDsToDate(Func):
    -4014    arg_types = {"this": True, "format": False}
    +            
    4156class TsOrDsToDate(Func):
    +4157    arg_types = {"this": True, "format": False}
     
    @@ -42960,6 +45115,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -42976,8 +45138,8 @@ name is set to the expression's class name transformed to snake case. -
    4017class TsOrDiToDi(Func):
    -4018    pass
    +            
    4160class TsOrDiToDi(Func):
    +4161    pass
     
    @@ -43037,6 +45199,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -43053,8 +45222,8 @@ name is set to the expression's class name transformed to snake case. -
    4021class Unhex(Func):
    -4022    pass
    +            
    4164class Unhex(Func):
    +4165    pass
     
    @@ -43114,6 +45283,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -43130,8 +45306,8 @@ name is set to the expression's class name transformed to snake case. -
    4025class UnixToStr(Func):
    -4026    arg_types = {"this": True, "format": False}
    +            
    4168class UnixToStr(Func):
    +4169    arg_types = {"this": True, "format": False}
     
    @@ -43191,6 +45367,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -43207,12 +45390,12 @@ name is set to the expression's class name transformed to snake case. -
    4031class UnixToTime(Func):
    -4032    arg_types = {"this": True, "scale": False, "zone": False, "hours": False, "minutes": False}
    -4033
    -4034    SECONDS = Literal.string("seconds")
    -4035    MILLIS = Literal.string("millis")
    -4036    MICROS = Literal.string("micros")
    +            
    4174class UnixToTime(Func):
    +4175    arg_types = {"this": True, "scale": False, "zone": False, "hours": False, "minutes": False}
    +4176
    +4177    SECONDS = Literal.string("seconds")
    +4178    MILLIS = Literal.string("millis")
    +4179    MICROS = Literal.string("micros")
     
    @@ -43272,6 +45455,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -43288,8 +45478,8 @@ name is set to the expression's class name transformed to snake case. -
    4039class UnixToTimeStr(Func):
    -4040    pass
    +            
    4182class UnixToTimeStr(Func):
    +4183    pass
     
    @@ -43349,6 +45539,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -43365,8 +45562,8 @@ name is set to the expression's class name transformed to snake case. -
    4043class Upper(Func):
    -4044    _sql_names = ["UPPER", "UCASE"]
    +            
    4186class Upper(Func):
    +4187    _sql_names = ["UPPER", "UCASE"]
     
    @@ -43426,6 +45623,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -43442,8 +45646,8 @@ name is set to the expression's class name transformed to snake case. -
    4047class Variance(AggFunc):
    -4048    _sql_names = ["VARIANCE", "VARIANCE_SAMP", "VAR_SAMP"]
    +            
    4190class Variance(AggFunc):
    +4191    _sql_names = ["VARIANCE", "VARIANCE_SAMP", "VAR_SAMP"]
     
    @@ -43503,6 +45707,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -43519,8 +45730,8 @@ name is set to the expression's class name transformed to snake case. -
    4051class VariancePop(AggFunc):
    -4052    _sql_names = ["VARIANCE_POP", "VAR_POP"]
    +            
    4194class VariancePop(AggFunc):
    +4195    _sql_names = ["VARIANCE_POP", "VAR_POP"]
     
    @@ -43580,6 +45791,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -43596,8 +45814,8 @@ name is set to the expression's class name transformed to snake case. -
    4055class Week(Func):
    -4056    arg_types = {"this": True, "mode": False}
    +            
    4198class Week(Func):
    +4199    arg_types = {"this": True, "mode": False}
     
    @@ -43657,6 +45875,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -43673,8 +45898,8 @@ name is set to the expression's class name transformed to snake case. -
    4059class XMLTable(Func):
    -4060    arg_types = {"this": True, "passing": False, "columns": False, "by_ref": False}
    +            
    4202class XMLTable(Func):
    +4203    arg_types = {"this": True, "passing": False, "columns": False, "by_ref": False}
     
    @@ -43734,6 +45959,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -43750,8 +45982,8 @@ name is set to the expression's class name transformed to snake case. -
    4063class Year(Func):
    -4064    pass
    +            
    4206class Year(Func):
    +4207    pass
     
    @@ -43811,6 +46043,13 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    @@ -43827,8 +46066,8 @@ name is set to the expression's class name transformed to snake case. -
    4067class Use(Expression):
    -4068    arg_types = {"this": True, "kind": False}
    +            
    4210class Use(Expression):
    +4211    arg_types = {"this": True, "kind": False}
     
    @@ -43891,8 +46130,8 @@ name is set to the expression's class name transformed to snake case.
    -
    4071class Merge(Expression):
    -4072    arg_types = {"this": True, "using": True, "on": True, "expressions": True}
    +            
    4214class Merge(Expression):
    +4215    arg_types = {"this": True, "using": True, "on": True, "expressions": True}
     
    @@ -43955,8 +46194,8 @@ name is set to the expression's class name transformed to snake case.
    -
    4075class When(Func):
    -4076    arg_types = {"matched": True, "source": False, "condition": False, "then": True}
    +            
    4218class When(Func):
    +4219    arg_types = {"matched": True, "source": False, "condition": False, "then": True}
     
    @@ -44016,6 +46255,97 @@ name is set to the expression's class name transformed to snake case.
    and_
    or_
    not_
    +
    isin
    +
    between
    +
    like
    +
    ilike
    +
    eq
    +
    neq
    +
    rlike
    + +
    + + + +
    + +
    + + class + NextValueFor(Func): + + + +
    + +
    4224class NextValueFor(Func):
    +4225    arg_types = {"this": True, "order": False}
    +
    + + + + +
    +
    Inherited Members
    +
    + + +
    @@ -44032,48 +46362,48 @@ name is set to the expression's class name transformed to snake case.
    -
    4113def maybe_parse(
    -4114    sql_or_expression: ExpOrStr,
    -4115    *,
    -4116    into: t.Optional[IntoType] = None,
    -4117    dialect: DialectType = None,
    -4118    prefix: t.Optional[str] = None,
    -4119    copy: bool = False,
    -4120    **opts,
    -4121) -> Expression:
    -4122    """Gracefully handle a possible string or expression.
    -4123
    -4124    Example:
    -4125        >>> maybe_parse("1")
    -4126        (LITERAL this: 1, is_string: False)
    -4127        >>> maybe_parse(to_identifier("x"))
    -4128        (IDENTIFIER this: x, quoted: False)
    -4129
    -4130    Args:
    -4131        sql_or_expression: the SQL code string or an expression
    -4132        into: the SQLGlot Expression to parse into
    -4133        dialect: the dialect used to parse the input expressions (in the case that an
    -4134            input expression is a SQL string).
    -4135        prefix: a string to prefix the sql with before it gets parsed
    -4136            (automatically includes a space)
    -4137        copy: whether or not to copy the expression.
    -4138        **opts: other options to use to parse the input expressions (again, in the case
    -4139            that an input expression is a SQL string).
    -4140
    -4141    Returns:
    -4142        Expression: the parsed or given expression.
    -4143    """
    -4144    if isinstance(sql_or_expression, Expression):
    -4145        if copy:
    -4146            return sql_or_expression.copy()
    -4147        return sql_or_expression
    -4148
    -4149    import sqlglot
    -4150
    -4151    sql = str(sql_or_expression)
    -4152    if prefix:
    -4153        sql = f"{prefix} {sql}"
    -4154    return sqlglot.parse_one(sql, read=dialect, into=into, **opts)
    +            
    4262def maybe_parse(
    +4263    sql_or_expression: ExpOrStr,
    +4264    *,
    +4265    into: t.Optional[IntoType] = None,
    +4266    dialect: DialectType = None,
    +4267    prefix: t.Optional[str] = None,
    +4268    copy: bool = False,
    +4269    **opts,
    +4270) -> Expression:
    +4271    """Gracefully handle a possible string or expression.
    +4272
    +4273    Example:
    +4274        >>> maybe_parse("1")
    +4275        (LITERAL this: 1, is_string: False)
    +4276        >>> maybe_parse(to_identifier("x"))
    +4277        (IDENTIFIER this: x, quoted: False)
    +4278
    +4279    Args:
    +4280        sql_or_expression: the SQL code string or an expression
    +4281        into: the SQLGlot Expression to parse into
    +4282        dialect: the dialect used to parse the input expressions (in the case that an
    +4283            input expression is a SQL string).
    +4284        prefix: a string to prefix the sql with before it gets parsed
    +4285            (automatically includes a space)
    +4286        copy: whether or not to copy the expression.
    +4287        **opts: other options to use to parse the input expressions (again, in the case
    +4288            that an input expression is a SQL string).
    +4289
    +4290    Returns:
    +4291        Expression: the parsed or given expression.
    +4292    """
    +4293    if isinstance(sql_or_expression, Expression):
    +4294        if copy:
    +4295            return sql_or_expression.copy()
    +4296        return sql_or_expression
    +4297
    +4298    import sqlglot
    +4299
    +4300    sql = str(sql_or_expression)
    +4301    if prefix:
    +4302        sql = f"{prefix} {sql}"
    +4303    return sqlglot.parse_one(sql, read=dialect, into=into, **opts)
     
    @@ -44125,29 +46455,29 @@ that an input expression is a SQL string).
    -
    4300def union(left, right, distinct=True, dialect=None, **opts):
    -4301    """
    -4302    Initializes a syntax tree from one UNION expression.
    -4303
    -4304    Example:
    -4305        >>> union("SELECT * FROM foo", "SELECT * FROM bla").sql()
    -4306        'SELECT * FROM foo UNION SELECT * FROM bla'
    -4307
    -4308    Args:
    -4309        left (str | Expression): the SQL code string corresponding to the left-hand side.
    -4310            If an `Expression` instance is passed, it will be used as-is.
    -4311        right (str | Expression): the SQL code string corresponding to the right-hand side.
    -4312            If an `Expression` instance is passed, it will be used as-is.
    -4313        distinct (bool): set the DISTINCT flag if and only if this is true.
    -4314        dialect (str): the dialect used to parse the input expression.
    -4315        opts (kwargs): other options to use to parse the input expressions.
    -4316    Returns:
    -4317        Union: the syntax tree for the UNION expression.
    -4318    """
    -4319    left = maybe_parse(sql_or_expression=left, dialect=dialect, **opts)
    -4320    right = maybe_parse(sql_or_expression=right, dialect=dialect, **opts)
    -4321
    -4322    return Union(this=left, expression=right, distinct=distinct)
    +            
    4451def union(left, right, distinct=True, dialect=None, **opts):
    +4452    """
    +4453    Initializes a syntax tree from one UNION expression.
    +4454
    +4455    Example:
    +4456        >>> union("SELECT * FROM foo", "SELECT * FROM bla").sql()
    +4457        'SELECT * FROM foo UNION SELECT * FROM bla'
    +4458
    +4459    Args:
    +4460        left (str | Expression): the SQL code string corresponding to the left-hand side.
    +4461            If an `Expression` instance is passed, it will be used as-is.
    +4462        right (str | Expression): the SQL code string corresponding to the right-hand side.
    +4463            If an `Expression` instance is passed, it will be used as-is.
    +4464        distinct (bool): set the DISTINCT flag if and only if this is true.
    +4465        dialect (str): the dialect used to parse the input expression.
    +4466        opts (kwargs): other options to use to parse the input expressions.
    +4467    Returns:
    +4468        Union: the syntax tree for the UNION expression.
    +4469    """
    +4470    left = maybe_parse(sql_or_expression=left, dialect=dialect, **opts)
    +4471    right = maybe_parse(sql_or_expression=right, dialect=dialect, **opts)
    +4472
    +4473    return Union(this=left, expression=right, distinct=distinct)
     
    @@ -44195,29 +46525,29 @@ If an Expression instance is passed, it w
    -
    4325def intersect(left, right, distinct=True, dialect=None, **opts):
    -4326    """
    -4327    Initializes a syntax tree from one INTERSECT expression.
    -4328
    -4329    Example:
    -4330        >>> intersect("SELECT * FROM foo", "SELECT * FROM bla").sql()
    -4331        'SELECT * FROM foo INTERSECT SELECT * FROM bla'
    -4332
    -4333    Args:
    -4334        left (str | Expression): the SQL code string corresponding to the left-hand side.
    -4335            If an `Expression` instance is passed, it will be used as-is.
    -4336        right (str | Expression): the SQL code string corresponding to the right-hand side.
    -4337            If an `Expression` instance is passed, it will be used as-is.
    -4338        distinct (bool): set the DISTINCT flag if and only if this is true.
    -4339        dialect (str): the dialect used to parse the input expression.
    -4340        opts (kwargs): other options to use to parse the input expressions.
    -4341    Returns:
    -4342        Intersect: the syntax tree for the INTERSECT expression.
    -4343    """
    -4344    left = maybe_parse(sql_or_expression=left, dialect=dialect, **opts)
    -4345    right = maybe_parse(sql_or_expression=right, dialect=dialect, **opts)
    -4346
    -4347    return Intersect(this=left, expression=right, distinct=distinct)
    +            
    4476def intersect(left, right, distinct=True, dialect=None, **opts):
    +4477    """
    +4478    Initializes a syntax tree from one INTERSECT expression.
    +4479
    +4480    Example:
    +4481        >>> intersect("SELECT * FROM foo", "SELECT * FROM bla").sql()
    +4482        'SELECT * FROM foo INTERSECT SELECT * FROM bla'
    +4483
    +4484    Args:
    +4485        left (str | Expression): the SQL code string corresponding to the left-hand side.
    +4486            If an `Expression` instance is passed, it will be used as-is.
    +4487        right (str | Expression): the SQL code string corresponding to the right-hand side.
    +4488            If an `Expression` instance is passed, it will be used as-is.
    +4489        distinct (bool): set the DISTINCT flag if and only if this is true.
    +4490        dialect (str): the dialect used to parse the input expression.
    +4491        opts (kwargs): other options to use to parse the input expressions.
    +4492    Returns:
    +4493        Intersect: the syntax tree for the INTERSECT expression.
    +4494    """
    +4495    left = maybe_parse(sql_or_expression=left, dialect=dialect, **opts)
    +4496    right = maybe_parse(sql_or_expression=right, dialect=dialect, **opts)
    +4497
    +4498    return Intersect(this=left, expression=right, distinct=distinct)
     
    @@ -44265,29 +46595,29 @@ If an Expression instance is passed, it w
    -
    4350def except_(left, right, distinct=True, dialect=None, **opts):
    -4351    """
    -4352    Initializes a syntax tree from one EXCEPT expression.
    -4353
    -4354    Example:
    -4355        >>> except_("SELECT * FROM foo", "SELECT * FROM bla").sql()
    -4356        'SELECT * FROM foo EXCEPT SELECT * FROM bla'
    -4357
    -4358    Args:
    -4359        left (str | Expression): the SQL code string corresponding to the left-hand side.
    -4360            If an `Expression` instance is passed, it will be used as-is.
    -4361        right (str | Expression): the SQL code string corresponding to the right-hand side.
    -4362            If an `Expression` instance is passed, it will be used as-is.
    -4363        distinct (bool): set the DISTINCT flag if and only if this is true.
    -4364        dialect (str): the dialect used to parse the input expression.
    -4365        opts (kwargs): other options to use to parse the input expressions.
    -4366    Returns:
    -4367        Except: the syntax tree for the EXCEPT statement.
    -4368    """
    -4369    left = maybe_parse(sql_or_expression=left, dialect=dialect, **opts)
    -4370    right = maybe_parse(sql_or_expression=right, dialect=dialect, **opts)
    -4371
    -4372    return Except(this=left, expression=right, distinct=distinct)
    +            
    4501def except_(left, right, distinct=True, dialect=None, **opts):
    +4502    """
    +4503    Initializes a syntax tree from one EXCEPT expression.
    +4504
    +4505    Example:
    +4506        >>> except_("SELECT * FROM foo", "SELECT * FROM bla").sql()
    +4507        'SELECT * FROM foo EXCEPT SELECT * FROM bla'
    +4508
    +4509    Args:
    +4510        left (str | Expression): the SQL code string corresponding to the left-hand side.
    +4511            If an `Expression` instance is passed, it will be used as-is.
    +4512        right (str | Expression): the SQL code string corresponding to the right-hand side.
    +4513            If an `Expression` instance is passed, it will be used as-is.
    +4514        distinct (bool): set the DISTINCT flag if and only if this is true.
    +4515        dialect (str): the dialect used to parse the input expression.
    +4516        opts (kwargs): other options to use to parse the input expressions.
    +4517    Returns:
    +4518        Except: the syntax tree for the EXCEPT statement.
    +4519    """
    +4520    left = maybe_parse(sql_or_expression=left, dialect=dialect, **opts)
    +4521    right = maybe_parse(sql_or_expression=right, dialect=dialect, **opts)
    +4522
    +4523    return Except(this=left, expression=right, distinct=distinct)
     
    @@ -44335,26 +46665,26 @@ If an Expression instance is passed, it w
    -
    4375def select(*expressions: ExpOrStr, dialect: DialectType = None, **opts) -> Select:
    -4376    """
    -4377    Initializes a syntax tree from one or multiple SELECT expressions.
    -4378
    -4379    Example:
    -4380        >>> select("col1", "col2").from_("tbl").sql()
    -4381        'SELECT col1, col2 FROM tbl'
    -4382
    -4383    Args:
    -4384        *expressions: the SQL code string to parse as the expressions of a
    -4385            SELECT statement. If an Expression instance is passed, this is used as-is.
    -4386        dialect: the dialect used to parse the input expressions (in the case that an
    -4387            input expression is a SQL string).
    -4388        **opts: other options to use to parse the input expressions (again, in the case
    -4389            that an input expression is a SQL string).
    -4390
    -4391    Returns:
    -4392        Select: the syntax tree for the SELECT statement.
    -4393    """
    -4394    return Select().select(*expressions, dialect=dialect, **opts)
    +            
    4526def select(*expressions: ExpOrStr, dialect: DialectType = None, **opts) -> Select:
    +4527    """
    +4528    Initializes a syntax tree from one or multiple SELECT expressions.
    +4529
    +4530    Example:
    +4531        >>> select("col1", "col2").from_("tbl").sql()
    +4532        'SELECT col1, col2 FROM tbl'
    +4533
    +4534    Args:
    +4535        *expressions: the SQL code string to parse as the expressions of a
    +4536            SELECT statement. If an Expression instance is passed, this is used as-is.
    +4537        dialect: the dialect used to parse the input expressions (in the case that an
    +4538            input expression is a SQL string).
    +4539        **opts: other options to use to parse the input expressions (again, in the case
    +4540            that an input expression is a SQL string).
    +4541
    +4542    Returns:
    +4543        Select: the syntax tree for the SELECT statement.
    +4544    """
    +4545    return Select().select(*expressions, dialect=dialect, **opts)
     
    @@ -44401,26 +46731,26 @@ that an input expression is a SQL string).
    -
    4397def from_(*expressions, dialect=None, **opts) -> Select:
    -4398    """
    -4399    Initializes a syntax tree from a FROM expression.
    -4400
    -4401    Example:
    -4402        >>> from_("tbl").select("col1", "col2").sql()
    -4403        'SELECT col1, col2 FROM tbl'
    -4404
    -4405    Args:
    -4406        *expressions (str | Expression): the SQL code string to parse as the FROM expressions of a
    -4407            SELECT statement. If an Expression instance is passed, this is used as-is.
    -4408        dialect (str): the dialect used to parse the input expression (in the case that the
    -4409            input expression is a SQL string).
    -4410        **opts: other options to use to parse the input expressions (again, in the case
    -4411            that the input expression is a SQL string).
    -4412
    -4413    Returns:
    -4414        Select: the syntax tree for the SELECT statement.
    -4415    """
    -4416    return Select().from_(*expressions, dialect=dialect, **opts)
    +            
    4548def from_(*expressions, dialect=None, **opts) -> Select:
    +4549    """
    +4550    Initializes a syntax tree from a FROM expression.
    +4551
    +4552    Example:
    +4553        >>> from_("tbl").select("col1", "col2").sql()
    +4554        'SELECT col1, col2 FROM tbl'
    +4555
    +4556    Args:
    +4557        *expressions (str | Expression): the SQL code string to parse as the FROM expressions of a
    +4558            SELECT statement. If an Expression instance is passed, this is used as-is.
    +4559        dialect (str): the dialect used to parse the input expression (in the case that the
    +4560            input expression is a SQL string).
    +4561        **opts: other options to use to parse the input expressions (again, in the case
    +4562            that the input expression is a SQL string).
    +4563
    +4564    Returns:
    +4565        Select: the syntax tree for the SELECT statement.
    +4566    """
    +4567    return Select().from_(*expressions, dialect=dialect, **opts)
     
    @@ -44467,53 +46797,53 @@ that the input expression is a SQL string).
    -
    4419def update(
    -4420    table: str | Table,
    -4421    properties: dict,
    -4422    where: t.Optional[ExpOrStr] = None,
    -4423    from_: t.Optional[ExpOrStr] = None,
    -4424    dialect: DialectType = None,
    -4425    **opts,
    -4426) -> Update:
    -4427    """
    -4428    Creates an update statement.
    -4429
    -4430    Example:
    -4431        >>> update("my_table", {"x": 1, "y": "2", "z": None}, from_="baz", where="id > 1").sql()
    -4432        "UPDATE my_table SET x = 1, y = '2', z = NULL FROM baz WHERE id > 1"
    -4433
    -4434    Args:
    -4435        *properties: dictionary of properties to set which are
    -4436            auto converted to sql objects eg None -> NULL
    -4437        where: sql conditional parsed into a WHERE statement
    -4438        from_: sql statement parsed into a FROM statement
    -4439        dialect: the dialect used to parse the input expressions.
    -4440        **opts: other options to use to parse the input expressions.
    -4441
    -4442    Returns:
    -4443        Update: the syntax tree for the UPDATE statement.
    -4444    """
    -4445    update_expr = Update(this=maybe_parse(table, into=Table, dialect=dialect))
    -4446    update_expr.set(
    -4447        "expressions",
    -4448        [
    -4449            EQ(this=maybe_parse(k, dialect=dialect, **opts), expression=convert(v))
    -4450            for k, v in properties.items()
    -4451        ],
    -4452    )
    -4453    if from_:
    -4454        update_expr.set(
    -4455            "from",
    -4456            maybe_parse(from_, into=From, dialect=dialect, prefix="FROM", **opts),
    -4457        )
    -4458    if isinstance(where, Condition):
    -4459        where = Where(this=where)
    -4460    if where:
    -4461        update_expr.set(
    -4462            "where",
    -4463            maybe_parse(where, into=Where, dialect=dialect, prefix="WHERE", **opts),
    -4464        )
    -4465    return update_expr
    +            
    4570def update(
    +4571    table: str | Table,
    +4572    properties: dict,
    +4573    where: t.Optional[ExpOrStr] = None,
    +4574    from_: t.Optional[ExpOrStr] = None,
    +4575    dialect: DialectType = None,
    +4576    **opts,
    +4577) -> Update:
    +4578    """
    +4579    Creates an update statement.
    +4580
    +4581    Example:
    +4582        >>> update("my_table", {"x": 1, "y": "2", "z": None}, from_="baz", where="id > 1").sql()
    +4583        "UPDATE my_table SET x = 1, y = '2', z = NULL FROM baz WHERE id > 1"
    +4584
    +4585    Args:
    +4586        *properties: dictionary of properties to set which are
    +4587            auto converted to sql objects eg None -> NULL
    +4588        where: sql conditional parsed into a WHERE statement
    +4589        from_: sql statement parsed into a FROM statement
    +4590        dialect: the dialect used to parse the input expressions.
    +4591        **opts: other options to use to parse the input expressions.
    +4592
    +4593    Returns:
    +4594        Update: the syntax tree for the UPDATE statement.
    +4595    """
    +4596    update_expr = Update(this=maybe_parse(table, into=Table, dialect=dialect))
    +4597    update_expr.set(
    +4598        "expressions",
    +4599        [
    +4600            EQ(this=maybe_parse(k, dialect=dialect, **opts), expression=convert(v))
    +4601            for k, v in properties.items()
    +4602        ],
    +4603    )
    +4604    if from_:
    +4605        update_expr.set(
    +4606            "from",
    +4607            maybe_parse(from_, into=From, dialect=dialect, prefix="FROM", **opts),
    +4608        )
    +4609    if isinstance(where, Condition):
    +4610        where = Where(this=where)
    +4611    if where:
    +4612        update_expr.set(
    +4613            "where",
    +4614            maybe_parse(where, into=Where, dialect=dialect, prefix="WHERE", **opts),
    +4615        )
    +4616    return update_expr
     
    @@ -44560,35 +46890,35 @@ auto converted to sql objects eg None -> NULL
    -
    4468def delete(
    -4469    table: ExpOrStr,
    -4470    where: t.Optional[ExpOrStr] = None,
    -4471    returning: t.Optional[ExpOrStr] = None,
    -4472    dialect: DialectType = None,
    -4473    **opts,
    -4474) -> Delete:
    -4475    """
    -4476    Builds a delete statement.
    -4477
    -4478    Example:
    -4479        >>> delete("my_table", where="id > 1").sql()
    -4480        'DELETE FROM my_table WHERE id > 1'
    -4481
    -4482    Args:
    -4483        where: sql conditional parsed into a WHERE statement
    -4484        returning: sql conditional parsed into a RETURNING statement
    -4485        dialect: the dialect used to parse the input expressions.
    -4486        **opts: other options to use to parse the input expressions.
    -4487
    -4488    Returns:
    -4489        Delete: the syntax tree for the DELETE statement.
    -4490    """
    -4491    delete_expr = Delete().delete(table, dialect=dialect, copy=False, **opts)
    -4492    if where:
    -4493        delete_expr = delete_expr.where(where, dialect=dialect, copy=False, **opts)
    -4494    if returning:
    -4495        delete_expr = delete_expr.returning(returning, dialect=dialect, copy=False, **opts)
    -4496    return delete_expr
    +            
    4619def delete(
    +4620    table: ExpOrStr,
    +4621    where: t.Optional[ExpOrStr] = None,
    +4622    returning: t.Optional[ExpOrStr] = None,
    +4623    dialect: DialectType = None,
    +4624    **opts,
    +4625) -> Delete:
    +4626    """
    +4627    Builds a delete statement.
    +4628
    +4629    Example:
    +4630        >>> delete("my_table", where="id > 1").sql()
    +4631        'DELETE FROM my_table WHERE id > 1'
    +4632
    +4633    Args:
    +4634        where: sql conditional parsed into a WHERE statement
    +4635        returning: sql conditional parsed into a RETURNING statement
    +4636        dialect: the dialect used to parse the input expressions.
    +4637        **opts: other options to use to parse the input expressions.
    +4638
    +4639    Returns:
    +4640        Delete: the syntax tree for the DELETE statement.
    +4641    """
    +4642    delete_expr = Delete().delete(table, dialect=dialect, copy=False, **opts)
    +4643    if where:
    +4644        delete_expr = delete_expr.where(where, dialect=dialect, copy=False, **opts)
    +4645    if returning:
    +4646        delete_expr = delete_expr.returning(returning, dialect=dialect, copy=False, **opts)
    +4647    return delete_expr
     
    @@ -44627,43 +46957,45 @@ auto converted to sql objects eg None -> NULL
    def - condition(expression, dialect=None, **opts) -> sqlglot.expressions.Condition: + condition( expression, dialect=None, copy=True, **opts) -> sqlglot.expressions.Condition:
    -
    4499def condition(expression, dialect=None, **opts) -> Condition:
    -4500    """
    -4501    Initialize a logical condition expression.
    -4502
    -4503    Example:
    -4504        >>> condition("x=1").sql()
    -4505        'x = 1'
    -4506
    -4507        This is helpful for composing larger logical syntax trees:
    -4508        >>> where = condition("x=1")
    -4509        >>> where = where.and_("y=1")
    -4510        >>> Select().from_("tbl").select("*").where(where).sql()
    -4511        'SELECT * FROM tbl WHERE x = 1 AND y = 1'
    -4512
    -4513    Args:
    -4514        *expression (str | Expression): the SQL code string to parse.
    -4515            If an Expression instance is passed, this is used as-is.
    -4516        dialect (str): the dialect used to parse the input expression (in the case that the
    -4517            input expression is a SQL string).
    -4518        **opts: other options to use to parse the input expressions (again, in the case
    -4519            that the input expression is a SQL string).
    -4520
    -4521    Returns:
    -4522        Condition: the expression
    -4523    """
    -4524    return maybe_parse(  # type: ignore
    -4525        expression,
    -4526        into=Condition,
    -4527        dialect=dialect,
    -4528        **opts,
    -4529    )
    +            
    4650def condition(expression, dialect=None, copy=True, **opts) -> Condition:
    +4651    """
    +4652    Initialize a logical condition expression.
    +4653
    +4654    Example:
    +4655        >>> condition("x=1").sql()
    +4656        'x = 1'
    +4657
    +4658        This is helpful for composing larger logical syntax trees:
    +4659        >>> where = condition("x=1")
    +4660        >>> where = where.and_("y=1")
    +4661        >>> Select().from_("tbl").select("*").where(where).sql()
    +4662        'SELECT * FROM tbl WHERE x = 1 AND y = 1'
    +4663
    +4664    Args:
    +4665        *expression (str | Expression): the SQL code string to parse.
    +4666            If an Expression instance is passed, this is used as-is.
    +4667        dialect (str): the dialect used to parse the input expression (in the case that the
    +4668            input expression is a SQL string).
    +4669        copy (bool): Whether or not to copy `expression` (only applies to expressions).
    +4670        **opts: other options to use to parse the input expressions (again, in the case
    +4671            that the input expression is a SQL string).
    +4672
    +4673    Returns:
    +4674        Condition: the expression
    +4675    """
    +4676    return maybe_parse(  # type: ignore
    +4677        expression,
    +4678        into=Condition,
    +4679        dialect=dialect,
    +4680        copy=copy,
    +4681        **opts,
    +4682    )
     
    @@ -44696,6 +47028,7 @@ auto converted to sql objects eg None -> NULL If an Expression instance is passed, this is used as-is.
  • dialect (str): the dialect used to parse the input expression (in the case that the input expression is a SQL string).
  • +
  • copy (bool): Whether or not to copy expression (only applies to expressions).
  • **opts: other options to use to parse the input expressions (again, in the case that the input expression is a SQL string).
  • @@ -44714,30 +47047,31 @@ that the input expression is a SQL string).
    def - and_(*expressions, dialect=None, **opts) -> sqlglot.expressions.And: + and_(*expressions, dialect=None, copy=True, **opts) -> sqlglot.expressions.And:
    -
    4532def and_(*expressions, dialect=None, **opts) -> And:
    -4533    """
    -4534    Combine multiple conditions with an AND logical operator.
    -4535
    -4536    Example:
    -4537        >>> and_("x=1", and_("y=1", "z=1")).sql()
    -4538        'x = 1 AND (y = 1 AND z = 1)'
    -4539
    -4540    Args:
    -4541        *expressions (str | Expression): the SQL code strings to parse.
    -4542            If an Expression instance is passed, this is used as-is.
    -4543        dialect (str): the dialect used to parse the input expression.
    -4544        **opts: other options to use to parse the input expressions.
    -4545
    -4546    Returns:
    -4547        And: the new condition
    -4548    """
    -4549    return _combine(expressions, And, dialect, **opts)
    +            
    4685def and_(*expressions, dialect=None, copy=True, **opts) -> And:
    +4686    """
    +4687    Combine multiple conditions with an AND logical operator.
    +4688
    +4689    Example:
    +4690        >>> and_("x=1", and_("y=1", "z=1")).sql()
    +4691        'x = 1 AND (y = 1 AND z = 1)'
    +4692
    +4693    Args:
    +4694        *expressions (str | Expression): the SQL code strings to parse.
    +4695            If an Expression instance is passed, this is used as-is.
    +4696        dialect (str): the dialect used to parse the input expression.
    +4697        copy (bool): whether or not to copy `expressions` (only applies to Expressions).
    +4698        **opts: other options to use to parse the input expressions.
    +4699
    +4700    Returns:
    +4701        And: the new condition
    +4702    """
    +4703    return _combine(expressions, And, dialect, copy=copy, **opts)
     
    @@ -44759,6 +47093,7 @@ that the input expression is a SQL string).
  • *expressions (str | Expression): the SQL code strings to parse. If an Expression instance is passed, this is used as-is.
  • dialect (str): the dialect used to parse the input expression.
  • +
  • copy (bool): whether or not to copy expressions (only applies to Expressions).
  • **opts: other options to use to parse the input expressions.
  • @@ -44776,30 +47111,31 @@ If an Expression instance is passed, this is used as-is.
    def - or_(*expressions, dialect=None, **opts) -> sqlglot.expressions.Or: + or_(*expressions, dialect=None, copy=True, **opts) -> sqlglot.expressions.Or:
    -
    4552def or_(*expressions, dialect=None, **opts) -> Or:
    -4553    """
    -4554    Combine multiple conditions with an OR logical operator.
    -4555
    -4556    Example:
    -4557        >>> or_("x=1", or_("y=1", "z=1")).sql()
    -4558        'x = 1 OR (y = 1 OR z = 1)'
    -4559
    -4560    Args:
    -4561        *expressions (str | Expression): the SQL code strings to parse.
    -4562            If an Expression instance is passed, this is used as-is.
    -4563        dialect (str): the dialect used to parse the input expression.
    -4564        **opts: other options to use to parse the input expressions.
    -4565
    -4566    Returns:
    -4567        Or: the new condition
    -4568    """
    -4569    return _combine(expressions, Or, dialect, **opts)
    +            
    4706def or_(*expressions, dialect=None, copy=True, **opts) -> Or:
    +4707    """
    +4708    Combine multiple conditions with an OR logical operator.
    +4709
    +4710    Example:
    +4711        >>> or_("x=1", or_("y=1", "z=1")).sql()
    +4712        'x = 1 OR (y = 1 OR z = 1)'
    +4713
    +4714    Args:
    +4715        *expressions (str | Expression): the SQL code strings to parse.
    +4716            If an Expression instance is passed, this is used as-is.
    +4717        dialect (str): the dialect used to parse the input expression.
    +4718        copy (bool): whether or not to copy `expressions` (only applies to Expressions).
    +4719        **opts: other options to use to parse the input expressions.
    +4720
    +4721    Returns:
    +4722        Or: the new condition
    +4723    """
    +4724    return _combine(expressions, Or, dialect, copy=copy, **opts)
     
    @@ -44821,6 +47157,7 @@ If an Expression instance is passed, this is used as-is.
  • *expressions (str | Expression): the SQL code strings to parse. If an Expression instance is passed, this is used as-is.
  • dialect (str): the dialect used to parse the input expression.
  • +
  • copy (bool): whether or not to copy expressions (only applies to Expressions).
  • **opts: other options to use to parse the input expressions.
  • @@ -44838,35 +47175,36 @@ If an Expression instance is passed, this is used as-is.
    def - not_(expression, dialect=None, **opts) -> sqlglot.expressions.Not: + not_(expression, dialect=None, copy=True, **opts) -> sqlglot.expressions.Not:
    -
    4572def not_(expression, dialect=None, **opts) -> Not:
    -4573    """
    -4574    Wrap a condition with a NOT operator.
    -4575
    -4576    Example:
    -4577        >>> not_("this_suit='black'").sql()
    -4578        "NOT this_suit = 'black'"
    -4579
    -4580    Args:
    -4581        expression (str | Expression): the SQL code strings to parse.
    -4582            If an Expression instance is passed, this is used as-is.
    -4583        dialect (str): the dialect used to parse the input expression.
    -4584        **opts: other options to use to parse the input expressions.
    -4585
    -4586    Returns:
    -4587        Not: the new condition
    -4588    """
    -4589    this = condition(
    -4590        expression,
    -4591        dialect=dialect,
    -4592        **opts,
    -4593    )
    -4594    return Not(this=_wrap_operator(this))
    +            
    4727def not_(expression, dialect=None, copy=True, **opts) -> Not:
    +4728    """
    +4729    Wrap a condition with a NOT operator.
    +4730
    +4731    Example:
    +4732        >>> not_("this_suit='black'").sql()
    +4733        "NOT this_suit = 'black'"
    +4734
    +4735    Args:
    +4736        expression (str | Expression): the SQL code strings to parse.
    +4737            If an Expression instance is passed, this is used as-is.
    +4738        dialect (str): the dialect used to parse the input expression.
    +4739        **opts: other options to use to parse the input expressions.
    +4740
    +4741    Returns:
    +4742        Not: the new condition
    +4743    """
    +4744    this = condition(
    +4745        expression,
    +4746        dialect=dialect,
    +4747        copy=copy,
    +4748        **opts,
    +4749    )
    +4750    return Not(this=_wrap(this, Connector))
     
    @@ -44905,14 +47243,14 @@ If an Expression instance is passed, this is used as-is.
    def - paren(expression) -> sqlglot.expressions.Paren: + paren(expression, copy=True) -> sqlglot.expressions.Paren:
    -
    4597def paren(expression) -> Paren:
    -4598    return Paren(this=expression)
    +            
    4753def paren(expression, copy=True) -> Paren:
    +4754    return Paren(this=_maybe_copy(expression, copy))
     
    @@ -44930,30 +47268,30 @@ If an Expression instance is passed, this is used as-is.
    -
    4614def to_identifier(name, quoted=None):
    -4615    """Builds an identifier.
    -4616
    -4617    Args:
    -4618        name: The name to turn into an identifier.
    -4619        quoted: Whether or not force quote the identifier.
    -4620
    -4621    Returns:
    -4622        The identifier ast node.
    -4623    """
    -4624
    -4625    if name is None:
    -4626        return None
    -4627
    -4628    if isinstance(name, Identifier):
    -4629        identifier = name
    -4630    elif isinstance(name, str):
    -4631        identifier = Identifier(
    -4632            this=name,
    -4633            quoted=not SAFE_IDENTIFIER_RE.match(name) if quoted is None else quoted,
    -4634        )
    -4635    else:
    -4636        raise ValueError(f"Name needs to be a string or an Identifier, got: {name.__class__}")
    -4637    return identifier
    +            
    4770def to_identifier(name, quoted=None):
    +4771    """Builds an identifier.
    +4772
    +4773    Args:
    +4774        name: The name to turn into an identifier.
    +4775        quoted: Whether or not force quote the identifier.
    +4776
    +4777    Returns:
    +4778        The identifier ast node.
    +4779    """
    +4780
    +4781    if name is None:
    +4782        return None
    +4783
    +4784    if isinstance(name, Identifier):
    +4785        identifier = name
    +4786    elif isinstance(name, str):
    +4787        identifier = Identifier(
    +4788            this=name,
    +4789            quoted=not SAFE_IDENTIFIER_RE.match(name) if quoted is None else quoted,
    +4790        )
    +4791    else:
    +4792        raise ValueError(f"Name needs to be a string or an Identifier, got: {name.__class__}")
    +4793    return identifier
     
    @@ -44986,23 +47324,23 @@ If an Expression instance is passed, this is used as-is.
    -
    4643def to_interval(interval: str | Literal) -> Interval:
    -4644    """Builds an interval expression from a string like '1 day' or '5 months'."""
    -4645    if isinstance(interval, Literal):
    -4646        if not interval.is_string:
    -4647            raise ValueError("Invalid interval string.")
    -4648
    -4649        interval = interval.this
    -4650
    -4651    interval_parts = INTERVAL_STRING_RE.match(interval)  # type: ignore
    -4652
    -4653    if not interval_parts:
    -4654        raise ValueError("Invalid interval string.")
    -4655
    -4656    return Interval(
    -4657        this=Literal.string(interval_parts.group(1)),
    -4658        unit=Var(this=interval_parts.group(2)),
    -4659    )
    +            
    4799def to_interval(interval: str | Literal) -> Interval:
    +4800    """Builds an interval expression from a string like '1 day' or '5 months'."""
    +4801    if isinstance(interval, Literal):
    +4802        if not interval.is_string:
    +4803            raise ValueError("Invalid interval string.")
    +4804
    +4805        interval = interval.this
    +4806
    +4807    interval_parts = INTERVAL_STRING_RE.match(interval)  # type: ignore
    +4808
    +4809    if not interval_parts:
    +4810        raise ValueError("Invalid interval string.")
    +4811
    +4812    return Interval(
    +4813        this=Literal.string(interval_parts.group(1)),
    +4814        unit=Var(this=interval_parts.group(2)),
    +4815    )
     
    @@ -45022,24 +47360,24 @@ If an Expression instance is passed, this is used as-is.
    -
    4672def to_table(sql_path: t.Optional[str | Table], **kwargs) -> t.Optional[Table]:
    -4673    """
    -4674    Create a table expression from a `[catalog].[schema].[table]` sql path. Catalog and schema are optional.
    -4675    If a table is passed in then that table is returned.
    -4676
    -4677    Args:
    -4678        sql_path: a `[catalog].[schema].[table]` string.
    -4679
    -4680    Returns:
    -4681        A table expression.
    -4682    """
    -4683    if sql_path is None or isinstance(sql_path, Table):
    -4684        return sql_path
    -4685    if not isinstance(sql_path, str):
    -4686        raise ValueError(f"Invalid type provided for a table: {type(sql_path)}")
    -4687
    -4688    catalog, db, table_name = (to_identifier(x) for x in split_num_words(sql_path, ".", 3))
    -4689    return Table(this=table_name, db=db, catalog=catalog, **kwargs)
    +            
    4828def to_table(sql_path: t.Optional[str | Table], **kwargs) -> t.Optional[Table]:
    +4829    """
    +4830    Create a table expression from a `[catalog].[schema].[table]` sql path. Catalog and schema are optional.
    +4831    If a table is passed in then that table is returned.
    +4832
    +4833    Args:
    +4834        sql_path: a `[catalog].[schema].[table]` string.
    +4835
    +4836    Returns:
    +4837        A table expression.
    +4838    """
    +4839    if sql_path is None or isinstance(sql_path, Table):
    +4840        return sql_path
    +4841    if not isinstance(sql_path, str):
    +4842        raise ValueError(f"Invalid type provided for a table: {type(sql_path)}")
    +4843
    +4844    catalog, db, table_name = (to_identifier(x) for x in split_num_words(sql_path, ".", 3))
    +4845    return Table(this=table_name, db=db, catalog=catalog, **kwargs)
     
    @@ -45072,22 +47410,22 @@ If a table is passed in then that table is returned.

    -
    4692def to_column(sql_path: str | Column, **kwargs) -> Column:
    -4693    """
    -4694    Create a column from a `[table].[column]` sql path. Schema is optional.
    -4695
    -4696    If a column is passed in then that column is returned.
    -4697
    -4698    Args:
    -4699        sql_path: `[table].[column]` string
    -4700    Returns:
    -4701        Table: A column expression
    -4702    """
    -4703    if sql_path is None or isinstance(sql_path, Column):
    -4704        return sql_path
    -4705    if not isinstance(sql_path, str):
    -4706        raise ValueError(f"Invalid type provided for column: {type(sql_path)}")
    -4707    return column(*reversed(sql_path.split(".")), **kwargs)  # type: ignore
    +            
    4848def to_column(sql_path: str | Column, **kwargs) -> Column:
    +4849    """
    +4850    Create a column from a `[table].[column]` sql path. Schema is optional.
    +4851
    +4852    If a column is passed in then that column is returned.
    +4853
    +4854    Args:
    +4855        sql_path: `[table].[column]` string
    +4856    Returns:
    +4857        Table: A column expression
    +4858    """
    +4859    if sql_path is None or isinstance(sql_path, Column):
    +4860        return sql_path
    +4861    if not isinstance(sql_path, str):
    +4862        raise ValueError(f"Invalid type provided for column: {type(sql_path)}")
    +4863    return column(*reversed(sql_path.split(".")), **kwargs)  # type: ignore
     
    @@ -45121,62 +47459,62 @@ If a table is passed in then that table is returned.

    -
    4710def alias_(
    -4711    expression: ExpOrStr,
    -4712    alias: str | Identifier,
    -4713    table: bool | t.Sequence[str | Identifier] = False,
    -4714    quoted: t.Optional[bool] = None,
    -4715    dialect: DialectType = None,
    -4716    **opts,
    -4717):
    -4718    """Create an Alias expression.
    -4719
    -4720    Example:
    -4721        >>> alias_('foo', 'bar').sql()
    -4722        'foo AS bar'
    -4723
    -4724        >>> alias_('(select 1, 2)', 'bar', table=['a', 'b']).sql()
    -4725        '(SELECT 1, 2) AS bar(a, b)'
    -4726
    -4727    Args:
    -4728        expression: the SQL code strings to parse.
    -4729            If an Expression instance is passed, this is used as-is.
    -4730        alias: the alias name to use. If the name has
    -4731            special characters it is quoted.
    -4732        table: Whether or not to create a table alias, can also be a list of columns.
    -4733        quoted: whether or not to quote the alias
    -4734        dialect: the dialect used to parse the input expression.
    -4735        **opts: other options to use to parse the input expressions.
    -4736
    -4737    Returns:
    -4738        Alias: the aliased expression
    -4739    """
    -4740    exp = maybe_parse(expression, dialect=dialect, **opts)
    -4741    alias = to_identifier(alias, quoted=quoted)
    -4742
    -4743    if table:
    -4744        table_alias = TableAlias(this=alias)
    -4745
    -4746        exp = exp.copy() if isinstance(expression, Expression) else exp
    -4747        exp.set("alias", table_alias)
    -4748
    -4749        if not isinstance(table, bool):
    -4750            for column in table:
    -4751                table_alias.append("columns", to_identifier(column, quoted=quoted))
    -4752
    -4753        return exp
    -4754
    -4755    # We don't set the "alias" arg for Window expressions, because that would add an IDENTIFIER node in
    -4756    # the AST, representing a "named_window" [1] construct (eg. bigquery). What we want is an ALIAS node
    -4757    # for the complete Window expression.
    -4758    #
    -4759    # [1]: https://cloud.google.com/bigquery/docs/reference/standard-sql/window-function-calls
    -4760
    -4761    if "alias" in exp.arg_types and not isinstance(exp, Window):
    -4762        exp = exp.copy()
    -4763        exp.set("alias", alias)
    -4764        return exp
    -4765    return Alias(this=exp, alias=alias)
    +            
    4866def alias_(
    +4867    expression: ExpOrStr,
    +4868    alias: str | Identifier,
    +4869    table: bool | t.Sequence[str | Identifier] = False,
    +4870    quoted: t.Optional[bool] = None,
    +4871    dialect: DialectType = None,
    +4872    **opts,
    +4873):
    +4874    """Create an Alias expression.
    +4875
    +4876    Example:
    +4877        >>> alias_('foo', 'bar').sql()
    +4878        'foo AS bar'
    +4879
    +4880        >>> alias_('(select 1, 2)', 'bar', table=['a', 'b']).sql()
    +4881        '(SELECT 1, 2) AS bar(a, b)'
    +4882
    +4883    Args:
    +4884        expression: the SQL code strings to parse.
    +4885            If an Expression instance is passed, this is used as-is.
    +4886        alias: the alias name to use. If the name has
    +4887            special characters it is quoted.
    +4888        table: Whether or not to create a table alias, can also be a list of columns.
    +4889        quoted: whether or not to quote the alias
    +4890        dialect: the dialect used to parse the input expression.
    +4891        **opts: other options to use to parse the input expressions.
    +4892
    +4893    Returns:
    +4894        Alias: the aliased expression
    +4895    """
    +4896    exp = maybe_parse(expression, dialect=dialect, **opts)
    +4897    alias = to_identifier(alias, quoted=quoted)
    +4898
    +4899    if table:
    +4900        table_alias = TableAlias(this=alias)
    +4901
    +4902        exp = exp.copy() if isinstance(expression, Expression) else exp
    +4903        exp.set("alias", table_alias)
    +4904
    +4905        if not isinstance(table, bool):
    +4906            for column in table:
    +4907                table_alias.append("columns", to_identifier(column, quoted=quoted))
    +4908
    +4909        return exp
    +4910
    +4911    # We don't set the "alias" arg for Window expressions, because that would add an IDENTIFIER node in
    +4912    # the AST, representing a "named_window" [1] construct (eg. bigquery). What we want is an ALIAS node
    +4913    # for the complete Window expression.
    +4914    #
    +4915    # [1]: https://cloud.google.com/bigquery/docs/reference/standard-sql/window-function-calls
    +4916
    +4917    if "alias" in exp.arg_types and not isinstance(exp, Window):
    +4918        exp = exp.copy()
    +4919        exp.set("alias", alias)
    +4920        return exp
    +4921    return Alias(this=exp, alias=alias)
     
    @@ -45231,27 +47569,27 @@ special characters it is quoted.
    -
    4768def subquery(expression, alias=None, dialect=None, **opts):
    -4769    """
    -4770    Build a subquery expression.
    -4771
    -4772    Example:
    -4773        >>> subquery('select x from tbl', 'bar').select('x').sql()
    -4774        'SELECT x FROM (SELECT x FROM tbl) AS bar'
    -4775
    -4776    Args:
    -4777        expression (str | Expression): the SQL code strings to parse.
    -4778            If an Expression instance is passed, this is used as-is.
    -4779        alias (str | Expression): the alias name to use.
    -4780        dialect (str): the dialect used to parse the input expression.
    -4781        **opts: other options to use to parse the input expressions.
    -4782
    -4783    Returns:
    -4784        Select: a new select with the subquery expression included
    -4785    """
    -4786
    -4787    expression = maybe_parse(expression, dialect=dialect, **opts).subquery(alias)
    -4788    return Select().from_(expression, dialect=dialect, **opts)
    +            
    4924def subquery(expression, alias=None, dialect=None, **opts):
    +4925    """
    +4926    Build a subquery expression.
    +4927
    +4928    Example:
    +4929        >>> subquery('select x from tbl', 'bar').select('x').sql()
    +4930        'SELECT x FROM (SELECT x FROM tbl) AS bar'
    +4931
    +4932    Args:
    +4933        expression (str | Expression): the SQL code strings to parse.
    +4934            If an Expression instance is passed, this is used as-is.
    +4935        alias (str | Expression): the alias name to use.
    +4936        dialect (str): the dialect used to parse the input expression.
    +4937        **opts: other options to use to parse the input expressions.
    +4938
    +4939    Returns:
    +4940        Select: a new select with the subquery expression included
    +4941    """
    +4942
    +4943    expression = maybe_parse(expression, dialect=dialect, **opts).subquery(alias)
    +4944    return Select().from_(expression, dialect=dialect, **opts)
     
    @@ -45297,31 +47635,31 @@ If an Expression instance is passed, this is used as-is.
    -
    4791def column(
    -4792    col: str | Identifier,
    -4793    table: t.Optional[str | Identifier] = None,
    -4794    db: t.Optional[str | Identifier] = None,
    -4795    catalog: t.Optional[str | Identifier] = None,
    -4796    quoted: t.Optional[bool] = None,
    -4797) -> Column:
    -4798    """
    -4799    Build a Column.
    -4800
    -4801    Args:
    -4802        col: column name
    -4803        table: table name
    -4804        db: db name
    -4805        catalog: catalog name
    -4806        quoted: whether or not to force quote each part
    -4807    Returns:
    -4808        Column: column instance
    -4809    """
    -4810    return Column(
    -4811        this=to_identifier(col, quoted=quoted),
    -4812        table=to_identifier(table, quoted=quoted),
    -4813        db=to_identifier(db, quoted=quoted),
    -4814        catalog=to_identifier(catalog, quoted=quoted),
    -4815    )
    +            
    4947def column(
    +4948    col: str | Identifier,
    +4949    table: t.Optional[str | Identifier] = None,
    +4950    db: t.Optional[str | Identifier] = None,
    +4951    catalog: t.Optional[str | Identifier] = None,
    +4952    quoted: t.Optional[bool] = None,
    +4953) -> Column:
    +4954    """
    +4955    Build a Column.
    +4956
    +4957    Args:
    +4958        col: column name
    +4959        table: table name
    +4960        db: db name
    +4961        catalog: catalog name
    +4962        quoted: whether or not to force quote each part
    +4963    Returns:
    +4964        Column: column instance
    +4965    """
    +4966    return Column(
    +4967        this=to_identifier(col, quoted=quoted),
    +4968        table=to_identifier(table, quoted=quoted),
    +4969        db=to_identifier(db, quoted=quoted),
    +4970        catalog=to_identifier(catalog, quoted=quoted),
    +4971    )
     
    @@ -45357,22 +47695,22 @@ If an Expression instance is passed, this is used as-is.
    -
    4818def cast(expression: ExpOrStr, to: str | DataType | DataType.Type, **opts) -> Cast:
    -4819    """Cast an expression to a data type.
    -4820
    -4821    Example:
    -4822        >>> cast('x + 1', 'int').sql()
    -4823        'CAST(x + 1 AS INT)'
    -4824
    -4825    Args:
    -4826        expression: The expression to cast.
    -4827        to: The datatype to cast to.
    -4828
    -4829    Returns:
    -4830        A cast node.
    -4831    """
    -4832    expression = maybe_parse(expression, **opts)
    -4833    return Cast(this=expression, to=DataType.build(to, **opts))
    +            
    4974def cast(expression: ExpOrStr, to: str | DataType | DataType.Type, **opts) -> Cast:
    +4975    """Cast an expression to a data type.
    +4976
    +4977    Example:
    +4978        >>> cast('x + 1', 'int').sql()
    +4979        'CAST(x + 1 AS INT)'
    +4980
    +4981    Args:
    +4982        expression: The expression to cast.
    +4983        to: The datatype to cast to.
    +4984
    +4985    Returns:
    +4986        A cast node.
    +4987    """
    +4988    expression = maybe_parse(expression, **opts)
    +4989    return Cast(this=expression, to=DataType.build(to, **opts))
     
    @@ -45415,23 +47753,23 @@ If an Expression instance is passed, this is used as-is.
    -
    4836def table_(table, db=None, catalog=None, quoted=None, alias=None) -> Table:
    -4837    """Build a Table.
    -4838
    -4839    Args:
    -4840        table (str | Expression): column name
    -4841        db (str | Expression): db name
    -4842        catalog (str | Expression): catalog name
    -4843
    -4844    Returns:
    -4845        Table: table instance
    -4846    """
    -4847    return Table(
    -4848        this=to_identifier(table, quoted=quoted),
    -4849        db=to_identifier(db, quoted=quoted),
    -4850        catalog=to_identifier(catalog, quoted=quoted),
    -4851        alias=TableAlias(this=to_identifier(alias)) if alias else None,
    -4852    )
    +            
    4992def table_(table, db=None, catalog=None, quoted=None, alias=None) -> Table:
    +4993    """Build a Table.
    +4994
    +4995    Args:
    +4996        table (str | Expression): column name
    +4997        db (str | Expression): db name
    +4998        catalog (str | Expression): catalog name
    +4999
    +5000    Returns:
    +5001        Table: table instance
    +5002    """
    +5003    return Table(
    +5004        this=to_identifier(table, quoted=quoted),
    +5005        db=to_identifier(db, quoted=quoted),
    +5006        catalog=to_identifier(catalog, quoted=quoted),
    +5007        alias=TableAlias(this=to_identifier(alias)) if alias else None,
    +5008    )
     
    @@ -45465,46 +47803,37 @@ If an Expression instance is passed, this is used as-is.
    -
    4855def values(
    -4856    values: t.Iterable[t.Tuple[t.Any, ...]],
    -4857    alias: t.Optional[str] = None,
    -4858    columns: t.Optional[t.Iterable[str] | t.Dict[str, DataType]] = None,
    -4859) -> Values:
    -4860    """Build VALUES statement.
    -4861
    -4862    Example:
    -4863        >>> values([(1, '2')]).sql()
    -4864        "VALUES (1, '2')"
    -4865
    -4866    Args:
    -4867        values: values statements that will be converted to SQL
    -4868        alias: optional alias
    -4869        columns: Optional list of ordered column names or ordered dictionary of column names to types.
    -4870         If either are provided then an alias is also required.
    -4871         If a dictionary is provided then the first column of the values will be casted to the expected type
    -4872         in order to help with type inference.
    -4873
    -4874    Returns:
    -4875        Values: the Values expression object
    -4876    """
    -4877    if columns and not alias:
    -4878        raise ValueError("Alias is required when providing columns")
    -4879    table_alias = (
    -4880        TableAlias(this=to_identifier(alias), columns=[to_identifier(x) for x in columns])
    -4881        if columns
    -4882        else TableAlias(this=to_identifier(alias) if alias else None)
    -4883    )
    -4884    expressions = [convert(tup) for tup in values]
    -4885    if columns and isinstance(columns, dict):
    -4886        types = list(columns.values())
    -4887        expressions[0].set(
    -4888            "expressions",
    -4889            [cast(x, types[i]) for i, x in enumerate(expressions[0].expressions)],
    -4890        )
    -4891    return Values(
    -4892        expressions=expressions,
    -4893        alias=table_alias,
    -4894    )
    +            
    5011def values(
    +5012    values: t.Iterable[t.Tuple[t.Any, ...]],
    +5013    alias: t.Optional[str] = None,
    +5014    columns: t.Optional[t.Iterable[str] | t.Dict[str, DataType]] = None,
    +5015) -> Values:
    +5016    """Build VALUES statement.
    +5017
    +5018    Example:
    +5019        >>> values([(1, '2')]).sql()
    +5020        "VALUES (1, '2')"
    +5021
    +5022    Args:
    +5023        values: values statements that will be converted to SQL
    +5024        alias: optional alias
    +5025        columns: Optional list of ordered column names or ordered dictionary of column names to types.
    +5026         If either are provided then an alias is also required.
    +5027
    +5028    Returns:
    +5029        Values: the Values expression object
    +5030    """
    +5031    if columns and not alias:
    +5032        raise ValueError("Alias is required when providing columns")
    +5033
    +5034    return Values(
    +5035        expressions=[convert(tup) for tup in values],
    +5036        alias=(
    +5037            TableAlias(this=to_identifier(alias), columns=[to_identifier(x) for x in columns])
    +5038            if columns
    +5039            else (TableAlias(this=to_identifier(alias)) if alias else None)
    +5040        ),
    +5041    )
     
    @@ -45526,9 +47855,7 @@ If an Expression instance is passed, this is used as-is.
  • values: values statements that will be converted to SQL
  • alias: optional alias
  • columns: Optional list of ordered column names or ordered dictionary of column names to types. -If either are provided then an alias is also required. -If a dictionary is provided then the first column of the values will be casted to the expected type -in order to help with type inference.
  • +If either are provided then an alias is also required.
    Returns:
    @@ -45551,28 +47878,28 @@ in order to help with type inference.
    -
    4897def var(name: t.Optional[ExpOrStr]) -> Var:
    -4898    """Build a SQL variable.
    -4899
    -4900    Example:
    -4901        >>> repr(var('x'))
    -4902        '(VAR this: x)'
    -4903
    -4904        >>> repr(var(column('x', table='y')))
    -4905        '(VAR this: x)'
    -4906
    -4907    Args:
    -4908        name: The name of the var or an expression who's name will become the var.
    -4909
    -4910    Returns:
    -4911        The new variable node.
    -4912    """
    -4913    if not name:
    -4914        raise ValueError("Cannot convert empty name into var.")
    -4915
    -4916    if isinstance(name, Expression):
    -4917        name = name.name
    -4918    return Var(this=name)
    +            
    5044def var(name: t.Optional[ExpOrStr]) -> Var:
    +5045    """Build a SQL variable.
    +5046
    +5047    Example:
    +5048        >>> repr(var('x'))
    +5049        '(VAR this: x)'
    +5050
    +5051        >>> repr(var(column('x', table='y')))
    +5052        '(VAR this: x)'
    +5053
    +5054    Args:
    +5055        name: The name of the var or an expression who's name will become the var.
    +5056
    +5057    Returns:
    +5058        The new variable node.
    +5059    """
    +5060    if not name:
    +5061        raise ValueError("Cannot convert empty name into var.")
    +5062
    +5063    if isinstance(name, Expression):
    +5064        name = name.name
    +5065    return Var(this=name)
     
    @@ -45620,24 +47947,24 @@ in order to help with type inference.
    -
    4921def rename_table(old_name: str | Table, new_name: str | Table) -> AlterTable:
    -4922    """Build ALTER TABLE... RENAME... expression
    -4923
    -4924    Args:
    -4925        old_name: The old name of the table
    -4926        new_name: The new name of the table
    -4927
    -4928    Returns:
    -4929        Alter table expression
    -4930    """
    -4931    old_table = to_table(old_name)
    -4932    new_table = to_table(new_name)
    -4933    return AlterTable(
    -4934        this=old_table,
    -4935        actions=[
    -4936            RenameTable(this=new_table),
    -4937        ],
    -4938    )
    +            
    5068def rename_table(old_name: str | Table, new_name: str | Table) -> AlterTable:
    +5069    """Build ALTER TABLE... RENAME... expression
    +5070
    +5071    Args:
    +5072        old_name: The old name of the table
    +5073        new_name: The new name of the table
    +5074
    +5075    Returns:
    +5076        Alter table expression
    +5077    """
    +5078    old_table = to_table(old_name)
    +5079    new_table = to_table(new_name)
    +5080    return AlterTable(
    +5081        this=old_table,
    +5082        actions=[
    +5083            RenameTable(this=new_table),
    +5084        ],
    +5085    )
     
    @@ -45664,53 +47991,52 @@ in order to help with type inference.
    def - convert(value) -> sqlglot.expressions.Expression: + convert(value: Any, copy: bool = False) -> sqlglot.expressions.Expression:
    -
    4941def convert(value) -> Expression:
    -4942    """Convert a python value into an expression object.
    -4943
    -4944    Raises an error if a conversion is not possible.
    -4945
    -4946    Args:
    -4947        value (Any): a python object
    -4948
    -4949    Returns:
    -4950        Expression: the equivalent expression object
    -4951    """
    -4952    if isinstance(value, Expression):
    -4953        return value
    -4954    if value is None:
    -4955        return NULL
    -4956    if isinstance(value, bool):
    -4957        return Boolean(this=value)
    -4958    if isinstance(value, str):
    -4959        return Literal.string(value)
    -4960    if isinstance(value, float) and math.isnan(value):
    -4961        return NULL
    -4962    if isinstance(value, numbers.Number):
    -4963        return Literal.number(value)
    -4964    if isinstance(value, tuple):
    -4965        return Tuple(expressions=[convert(v) for v in value])
    -4966    if isinstance(value, list):
    -4967        return Array(expressions=[convert(v) for v in value])
    -4968    if isinstance(value, dict):
    -4969        return Map(
    -4970            keys=[convert(k) for k in value],
    -4971            values=[convert(v) for v in value.values()],
    -4972        )
    -4973    if isinstance(value, datetime.datetime):
    -4974        datetime_literal = Literal.string(
    -4975            (value if value.tzinfo else value.replace(tzinfo=datetime.timezone.utc)).isoformat()
    -4976        )
    -4977        return TimeStrToTime(this=datetime_literal)
    -4978    if isinstance(value, datetime.date):
    -4979        date_literal = Literal.string(value.strftime("%Y-%m-%d"))
    -4980        return DateStrToDate(this=date_literal)
    -4981    raise ValueError(f"Cannot convert {value}")
    +            
    5088def convert(value: t.Any, copy: bool = False) -> Expression:
    +5089    """Convert a python value into an expression object.
    +5090
    +5091    Raises an error if a conversion is not possible.
    +5092
    +5093    Args:
    +5094        value: A python object.
    +5095        copy: Whether or not to copy `value` (only applies to Expressions and collections).
    +5096
    +5097    Returns:
    +5098        Expression: the equivalent expression object.
    +5099    """
    +5100    if isinstance(value, Expression):
    +5101        return _maybe_copy(value, copy)
    +5102    if isinstance(value, str):
    +5103        return Literal.string(value)
    +5104    if isinstance(value, bool):
    +5105        return Boolean(this=value)
    +5106    if value is None or (isinstance(value, float) and math.isnan(value)):
    +5107        return NULL
    +5108    if isinstance(value, numbers.Number):
    +5109        return Literal.number(value)
    +5110    if isinstance(value, datetime.datetime):
    +5111        datetime_literal = Literal.string(
    +5112            (value if value.tzinfo else value.replace(tzinfo=datetime.timezone.utc)).isoformat()
    +5113        )
    +5114        return TimeStrToTime(this=datetime_literal)
    +5115    if isinstance(value, datetime.date):
    +5116        date_literal = Literal.string(value.strftime("%Y-%m-%d"))
    +5117        return DateStrToDate(this=date_literal)
    +5118    if isinstance(value, tuple):
    +5119        return Tuple(expressions=[convert(v, copy=copy) for v in value])
    +5120    if isinstance(value, list):
    +5121        return Array(expressions=[convert(v, copy=copy) for v in value])
    +5122    if isinstance(value, dict):
    +5123        return Map(
    +5124            keys=[convert(k, copy=copy) for k in value],
    +5125            values=[convert(v, copy=copy) for v in value.values()],
    +5126        )
    +5127    raise ValueError(f"Cannot convert {value}")
     
    @@ -45721,13 +48047,14 @@ in order to help with type inference.
    Arguments:
      -
    • value (Any): a python object
    • +
    • value: A python object.
    • +
    • copy: Whether or not to copy value (only applies to Expressions and collections).
    Returns:
    -

    Expression: the equivalent expression object

    +

    Expression: the equivalent expression object.

    @@ -45744,26 +48071,26 @@ in order to help with type inference.
    -
    4984def replace_children(expression, fun, *args, **kwargs):
    -4985    """
    -4986    Replace children of an expression with the result of a lambda fun(child) -> exp.
    -4987    """
    -4988    for k, v in expression.args.items():
    -4989        is_list_arg = type(v) is list
    -4990
    -4991        child_nodes = v if is_list_arg else [v]
    -4992        new_child_nodes = []
    -4993
    -4994        for cn in child_nodes:
    -4995            if isinstance(cn, Expression):
    -4996                for child_node in ensure_collection(fun(cn, *args, **kwargs)):
    -4997                    new_child_nodes.append(child_node)
    -4998                    child_node.parent = expression
    -4999                    child_node.arg_key = k
    -5000            else:
    -5001                new_child_nodes.append(cn)
    -5002
    -5003        expression.args[k] = new_child_nodes if is_list_arg else seq_get(new_child_nodes, 0)
    +            
    5130def replace_children(expression, fun, *args, **kwargs):
    +5131    """
    +5132    Replace children of an expression with the result of a lambda fun(child) -> exp.
    +5133    """
    +5134    for k, v in expression.args.items():
    +5135        is_list_arg = type(v) is list
    +5136
    +5137        child_nodes = v if is_list_arg else [v]
    +5138        new_child_nodes = []
    +5139
    +5140        for cn in child_nodes:
    +5141            if isinstance(cn, Expression):
    +5142                for child_node in ensure_collection(fun(cn, *args, **kwargs)):
    +5143                    new_child_nodes.append(child_node)
    +5144                    child_node.parent = expression
    +5145                    child_node.arg_key = k
    +5146            else:
    +5147                new_child_nodes.append(cn)
    +5148
    +5149        expression.args[k] = new_child_nodes if is_list_arg else seq_get(new_child_nodes, 0)
     
    @@ -45783,22 +48110,22 @@ in order to help with type inference.
    -
    5006def column_table_names(expression):
    -5007    """
    -5008    Return all table names referenced through columns in an expression.
    -5009
    -5010    Example:
    -5011        >>> import sqlglot
    -5012        >>> column_table_names(sqlglot.parse_one("a.b AND c.d AND c.e"))
    -5013        ['c', 'a']
    -5014
    -5015    Args:
    -5016        expression (sqlglot.Expression): expression to find table names
    -5017
    -5018    Returns:
    -5019        list: A list of unique names
    -5020    """
    -5021    return list(dict.fromkeys(column.table for column in expression.find_all(Column)))
    +            
    5152def column_table_names(expression):
    +5153    """
    +5154    Return all table names referenced through columns in an expression.
    +5155
    +5156    Example:
    +5157        >>> import sqlglot
    +5158        >>> column_table_names(sqlglot.parse_one("a.b AND c.d AND c.e"))
    +5159        ['c', 'a']
    +5160
    +5161    Args:
    +5162        expression (sqlglot.Expression): expression to find table names
    +5163
    +5164    Returns:
    +5165        list: A list of unique names
    +5166    """
    +5167    return list(dict.fromkeys(column.table for column in expression.find_all(Column)))
     
    @@ -45841,35 +48168,35 @@ in order to help with type inference.
    -
    5024def table_name(table) -> str:
    -5025    """Get the full name of a table as a string.
    -5026
    -5027    Args:
    -5028        table (exp.Table | str): table expression node or string.
    -5029
    -5030    Examples:
    -5031        >>> from sqlglot import exp, parse_one
    -5032        >>> table_name(parse_one("select * from a.b.c").find(exp.Table))
    -5033        'a.b.c'
    -5034
    -5035    Returns:
    -5036        The table name.
    -5037    """
    -5038
    -5039    table = maybe_parse(table, into=Table)
    -5040
    -5041    if not table:
    -5042        raise ValueError(f"Cannot parse {table}")
    -5043
    -5044    return ".".join(
    -5045        part
    -5046        for part in (
    -5047            table.text("catalog"),
    -5048            table.text("db"),
    -5049            table.name,
    -5050        )
    -5051        if part
    -5052    )
    +            
    5170def table_name(table) -> str:
    +5171    """Get the full name of a table as a string.
    +5172
    +5173    Args:
    +5174        table (exp.Table | str): table expression node or string.
    +5175
    +5176    Examples:
    +5177        >>> from sqlglot import exp, parse_one
    +5178        >>> table_name(parse_one("select * from a.b.c").find(exp.Table))
    +5179        'a.b.c'
    +5180
    +5181    Returns:
    +5182        The table name.
    +5183    """
    +5184
    +5185    table = maybe_parse(table, into=Table)
    +5186
    +5187    if not table:
    +5188        raise ValueError(f"Cannot parse {table}")
    +5189
    +5190    return ".".join(
    +5191        part
    +5192        for part in (
    +5193            table.text("catalog"),
    +5194            table.text("db"),
    +5195            table.name,
    +5196        )
    +5197        if part
    +5198    )
     
    @@ -45912,33 +48239,33 @@ in order to help with type inference.
    -
    5055def replace_tables(expression, mapping):
    -5056    """Replace all tables in expression according to the mapping.
    -5057
    -5058    Args:
    -5059        expression (sqlglot.Expression): expression node to be transformed and replaced.
    -5060        mapping (Dict[str, str]): mapping of table names.
    -5061
    -5062    Examples:
    -5063        >>> from sqlglot import exp, parse_one
    -5064        >>> replace_tables(parse_one("select * from a.b"), {"a.b": "c"}).sql()
    -5065        'SELECT * FROM c'
    -5066
    -5067    Returns:
    -5068        The mapped expression.
    -5069    """
    -5070
    -5071    def _replace_tables(node):
    -5072        if isinstance(node, Table):
    -5073            new_name = mapping.get(table_name(node))
    -5074            if new_name:
    -5075                return to_table(
    -5076                    new_name,
    -5077                    **{k: v for k, v in node.args.items() if k not in ("this", "db", "catalog")},
    -5078                )
    -5079        return node
    -5080
    -5081    return expression.transform(_replace_tables)
    +            
    5201def replace_tables(expression, mapping):
    +5202    """Replace all tables in expression according to the mapping.
    +5203
    +5204    Args:
    +5205        expression (sqlglot.Expression): expression node to be transformed and replaced.
    +5206        mapping (Dict[str, str]): mapping of table names.
    +5207
    +5208    Examples:
    +5209        >>> from sqlglot import exp, parse_one
    +5210        >>> replace_tables(parse_one("select * from a.b"), {"a.b": "c"}).sql()
    +5211        'SELECT * FROM c'
    +5212
    +5213    Returns:
    +5214        The mapped expression.
    +5215    """
    +5216
    +5217    def _replace_tables(node):
    +5218        if isinstance(node, Table):
    +5219            new_name = mapping.get(table_name(node))
    +5220            if new_name:
    +5221                return to_table(
    +5222                    new_name,
    +5223                    **{k: v for k, v in node.args.items() if k not in ("this", "db", "catalog")},
    +5224                )
    +5225        return node
    +5226
    +5227    return expression.transform(_replace_tables)
     
    @@ -45982,40 +48309,40 @@ in order to help with type inference.
    -
    5084def replace_placeholders(expression, *args, **kwargs):
    -5085    """Replace placeholders in an expression.
    -5086
    -5087    Args:
    -5088        expression (sqlglot.Expression): expression node to be transformed and replaced.
    -5089        args: positional names that will substitute unnamed placeholders in the given order.
    -5090        kwargs: keyword arguments that will substitute named placeholders.
    -5091
    -5092    Examples:
    -5093        >>> from sqlglot import exp, parse_one
    -5094        >>> replace_placeholders(
    -5095        ...     parse_one("select * from :tbl where ? = ?"),
    -5096        ...     exp.to_identifier("str_col"), "b", tbl=exp.to_identifier("foo")
    -5097        ... ).sql()
    -5098        "SELECT * FROM foo WHERE str_col = 'b'"
    -5099
    -5100    Returns:
    -5101        The mapped expression.
    -5102    """
    -5103
    -5104    def _replace_placeholders(node, args, **kwargs):
    -5105        if isinstance(node, Placeholder):
    -5106            if node.name:
    -5107                new_name = kwargs.get(node.name)
    -5108                if new_name:
    -5109                    return convert(new_name)
    -5110            else:
    -5111                try:
    -5112                    return convert(next(args))
    -5113                except StopIteration:
    -5114                    pass
    -5115        return node
    -5116
    -5117    return expression.transform(_replace_placeholders, iter(args), **kwargs)
    +            
    5230def replace_placeholders(expression, *args, **kwargs):
    +5231    """Replace placeholders in an expression.
    +5232
    +5233    Args:
    +5234        expression (sqlglot.Expression): expression node to be transformed and replaced.
    +5235        args: positional names that will substitute unnamed placeholders in the given order.
    +5236        kwargs: keyword arguments that will substitute named placeholders.
    +5237
    +5238    Examples:
    +5239        >>> from sqlglot import exp, parse_one
    +5240        >>> replace_placeholders(
    +5241        ...     parse_one("select * from :tbl where ? = ?"),
    +5242        ...     exp.to_identifier("str_col"), "b", tbl=exp.to_identifier("foo")
    +5243        ... ).sql()
    +5244        "SELECT * FROM foo WHERE str_col = 'b'"
    +5245
    +5246    Returns:
    +5247        The mapped expression.
    +5248    """
    +5249
    +5250    def _replace_placeholders(node, args, **kwargs):
    +5251        if isinstance(node, Placeholder):
    +5252            if node.name:
    +5253                new_name = kwargs.get(node.name)
    +5254                if new_name:
    +5255                    return convert(new_name)
    +5256            else:
    +5257                try:
    +5258                    return convert(next(args))
    +5259                except StopIteration:
    +5260                    pass
    +5261        return node
    +5262
    +5263    return expression.transform(_replace_placeholders, iter(args), **kwargs)
     
    @@ -46063,39 +48390,39 @@ in order to help with type inference.
    -
    5120def expand(
    -5121    expression: Expression, sources: t.Dict[str, Subqueryable], copy: bool = True
    -5122) -> Expression:
    -5123    """Transforms an expression by expanding all referenced sources into subqueries.
    -5124
    -5125    Examples:
    -5126        >>> from sqlglot import parse_one
    -5127        >>> expand(parse_one("select * from x AS z"), {"x": parse_one("select * from y")}).sql()
    -5128        'SELECT * FROM (SELECT * FROM y) AS z /* source: x */'
    -5129
    -5130        >>> expand(parse_one("select * from x AS z"), {"x": parse_one("select * from y"), "y": parse_one("select * from z")}).sql()
    -5131        'SELECT * FROM (SELECT * FROM (SELECT * FROM z) AS y /* source: y */) AS z /* source: x */'
    -5132
    -5133    Args:
    -5134        expression: The expression to expand.
    -5135        sources: A dictionary of name to Subqueryables.
    -5136        copy: Whether or not to copy the expression during transformation. Defaults to True.
    -5137
    -5138    Returns:
    -5139        The transformed expression.
    -5140    """
    -5141
    -5142    def _expand(node: Expression):
    -5143        if isinstance(node, Table):
    -5144            name = table_name(node)
    -5145            source = sources.get(name)
    -5146            if source:
    -5147                subquery = source.subquery(node.alias or name)
    -5148                subquery.comments = [f"source: {name}"]
    -5149                return subquery.transform(_expand, copy=False)
    -5150        return node
    -5151
    -5152    return expression.transform(_expand, copy=copy)
    +            
    5266def expand(
    +5267    expression: Expression, sources: t.Dict[str, Subqueryable], copy: bool = True
    +5268) -> Expression:
    +5269    """Transforms an expression by expanding all referenced sources into subqueries.
    +5270
    +5271    Examples:
    +5272        >>> from sqlglot import parse_one
    +5273        >>> expand(parse_one("select * from x AS z"), {"x": parse_one("select * from y")}).sql()
    +5274        'SELECT * FROM (SELECT * FROM y) AS z /* source: x */'
    +5275
    +5276        >>> expand(parse_one("select * from x AS z"), {"x": parse_one("select * from y"), "y": parse_one("select * from z")}).sql()
    +5277        'SELECT * FROM (SELECT * FROM (SELECT * FROM z) AS y /* source: y */) AS z /* source: x */'
    +5278
    +5279    Args:
    +5280        expression: The expression to expand.
    +5281        sources: A dictionary of name to Subqueryables.
    +5282        copy: Whether or not to copy the expression during transformation. Defaults to True.
    +5283
    +5284    Returns:
    +5285        The transformed expression.
    +5286    """
    +5287
    +5288    def _expand(node: Expression):
    +5289        if isinstance(node, Table):
    +5290            name = table_name(node)
    +5291            source = sources.get(name)
    +5292            if source:
    +5293                subquery = source.subquery(node.alias or name)
    +5294                subquery.comments = [f"source: {name}"]
    +5295                return subquery.transform(_expand, copy=False)
    +5296        return node
    +5297
    +5298    return expression.transform(_expand, copy=copy)
     
    @@ -46146,51 +48473,51 @@ in order to help with type inference.
    -
    5155def func(name: str, *args, dialect: DialectType = None, **kwargs) -> Func:
    -5156    """
    -5157    Returns a Func expression.
    -5158
    -5159    Examples:
    -5160        >>> func("abs", 5).sql()
    -5161        'ABS(5)'
    -5162
    -5163        >>> func("cast", this=5, to=DataType.build("DOUBLE")).sql()
    -5164        'CAST(5 AS DOUBLE)'
    -5165
    -5166    Args:
    -5167        name: the name of the function to build.
    -5168        args: the args used to instantiate the function of interest.
    -5169        dialect: the source dialect.
    -5170        kwargs: the kwargs used to instantiate the function of interest.
    -5171
    -5172    Note:
    -5173        The arguments `args` and `kwargs` are mutually exclusive.
    -5174
    -5175    Returns:
    -5176        An instance of the function of interest, or an anonymous function, if `name` doesn't
    -5177        correspond to an existing `sqlglot.expressions.Func` class.
    -5178    """
    -5179    if args and kwargs:
    -5180        raise ValueError("Can't use both args and kwargs to instantiate a function.")
    -5181
    -5182    from sqlglot.dialects.dialect import Dialect
    -5183
    -5184    converted = [convert(arg) for arg in args]
    -5185    kwargs = {key: convert(value) for key, value in kwargs.items()}
    -5186
    -5187    parser = Dialect.get_or_raise(dialect)().parser()
    -5188    from_args_list = parser.FUNCTIONS.get(name.upper())
    -5189
    -5190    if from_args_list:
    -5191        function = from_args_list(converted) if converted else from_args_list.__self__(**kwargs)  # type: ignore
    -5192    else:
    -5193        kwargs = kwargs or {"expressions": converted}
    -5194        function = Anonymous(this=name, **kwargs)
    -5195
    -5196    for error_message in function.error_messages(converted):
    -5197        raise ValueError(error_message)
    -5198
    -5199    return function
    +            
    5301def func(name: str, *args, dialect: DialectType = None, **kwargs) -> Func:
    +5302    """
    +5303    Returns a Func expression.
    +5304
    +5305    Examples:
    +5306        >>> func("abs", 5).sql()
    +5307        'ABS(5)'
    +5308
    +5309        >>> func("cast", this=5, to=DataType.build("DOUBLE")).sql()
    +5310        'CAST(5 AS DOUBLE)'
    +5311
    +5312    Args:
    +5313        name: the name of the function to build.
    +5314        args: the args used to instantiate the function of interest.
    +5315        dialect: the source dialect.
    +5316        kwargs: the kwargs used to instantiate the function of interest.
    +5317
    +5318    Note:
    +5319        The arguments `args` and `kwargs` are mutually exclusive.
    +5320
    +5321    Returns:
    +5322        An instance of the function of interest, or an anonymous function, if `name` doesn't
    +5323        correspond to an existing `sqlglot.expressions.Func` class.
    +5324    """
    +5325    if args and kwargs:
    +5326        raise ValueError("Can't use both args and kwargs to instantiate a function.")
    +5327
    +5328    from sqlglot.dialects.dialect import Dialect
    +5329
    +5330    converted: t.List[Expression] = [maybe_parse(arg, dialect=dialect) for arg in args]
    +5331    kwargs = {key: maybe_parse(value, dialect=dialect) for key, value in kwargs.items()}
    +5332
    +5333    parser = Dialect.get_or_raise(dialect)().parser()
    +5334    from_args_list = parser.FUNCTIONS.get(name.upper())
    +5335
    +5336    if from_args_list:
    +5337        function = from_args_list(converted) if converted else from_args_list.__self__(**kwargs)  # type: ignore
    +5338    else:
    +5339        kwargs = kwargs or {"expressions": converted}
    +5340        function = Anonymous(this=name, **kwargs)
    +5341
    +5342    for error_message in function.error_messages(converted):
    +5343        raise ValueError(error_message)
    +5344
    +5345    return function
     
    @@ -46248,11 +48575,11 @@ in order to help with type inference.
    -
    5202def true():
    -5203    """
    -5204    Returns a true Boolean expression.
    -5205    """
    -5206    return Boolean(this=True)
    +            
    5348def true():
    +5349    """
    +5350    Returns a true Boolean expression.
    +5351    """
    +5352    return Boolean(this=True)
     
    @@ -46272,11 +48599,11 @@ in order to help with type inference.
    -
    5209def false():
    -5210    """
    -5211    Returns a false Boolean expression.
    -5212    """
    -5213    return Boolean(this=False)
    +            
    5355def false():
    +5356    """
    +5357    Returns a false Boolean expression.
    +5358    """
    +5359    return Boolean(this=False)
     
    @@ -46296,11 +48623,11 @@ in order to help with type inference.
    -
    5216def null():
    -5217    """
    -5218    Returns a Null expression.
    -5219    """
    -5220    return Null()
    +            
    5362def null():
    +5363    """
    +5364    Returns a Null expression.
    +5365    """
    +5366    return Null()
     
    -- cgit v1.2.3