From 67c28dbe67209effad83d93b850caba5ee1e20e3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 3 May 2023 11:12:28 +0200 Subject: Merging upstream version 11.7.1. Signed-off-by: Daniel Baumann --- docs/sqlglot/expressions.html | 17221 +++++++++++++++++++++------------------- 1 file changed, 9066 insertions(+), 8155 deletions(-) (limited to 'docs/sqlglot/expressions.html') diff --git a/docs/sqlglot/expressions.html b/docs/sqlglot/expressions.html index 6463633..a4b82fc 100644 --- a/docs/sqlglot/expressions.html +++ b/docs/sqlglot/expressions.html @@ -3,7 +3,7 @@ - + sqlglot.expressions API documentation @@ -442,6 +442,12 @@ + +
  • + OnUpdateColumnConstraint +
      +
    +
  • PrimaryKeyColumnConstraint @@ -586,6 +592,12 @@
    +
  • +
  • + OnConflict +
      +
    +
  • Returning @@ -829,6 +841,12 @@
    +
  • +
  • + InputOutputFormat +
      +
    +
  • IsolatedLoadingProperty @@ -907,6 +925,12 @@
    +
  • +
  • + RowFormatProperty +
      +
    +
  • RowFormatDelimitedProperty @@ -949,6 +973,12 @@
    +
  • +
  • + StabilityProperty +
      +
    +
  • TableFormatProperty @@ -969,7 +999,7 @@
  • - VolatilityProperty + VolatileProperty
    @@ -1361,6 +1391,9 @@
  • DECIMAL
  • +
  • + BIGDECIMAL +
  • BIT
  • @@ -2128,6 +2161,12 @@ + +
  • + CurrentUser +
      +
    +
  • DateAdd @@ -2494,6 +2533,12 @@
    +
  • +
  • + StarMap +
      +
    +
  • VarMap @@ -2512,6 +2557,12 @@
    +
  • +
  • + MD5 +
      +
    +
  • Min @@ -2650,6 +2701,18 @@
    +
  • +
  • + SHA +
      +
    + +
  • +
  • + SHA2 +
      +
    +
  • SortArray @@ -3844,4316 +3907,4411 @@ SQL expressions, such as sqlglot.expressions.select< 818 "properties": False, 819 "replace": False, 820 "unique": False, - 821 "volatile": False, - 822 "indexes": False, - 823 "no_schema_binding": False, - 824 "begin": False, - 825 } + 821 "indexes": False, + 822 "no_schema_binding": False, + 823 "begin": False, + 824 } + 825 826 - 827 - 828class Describe(Expression): - 829 arg_types = {"this": True, "kind": False} + 827class Describe(Expression): + 828 arg_types = {"this": True, "kind": False} + 829 830 - 831 - 832class Pragma(Expression): - 833 pass + 831class Pragma(Expression): + 832 pass + 833 834 - 835 - 836class Set(Expression): - 837 arg_types = {"expressions": False} + 835class Set(Expression): + 836 arg_types = {"expressions": False} + 837 838 - 839 - 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 } + 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 848 - 849 - 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 } + 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 - 869 - 870class UserDefinedFunction(Expression): - 871 arg_types = {"this": True, "expressions": False, "wrapped": False} + 869class UserDefinedFunction(Expression): + 870 arg_types = {"this": True, "expressions": False, "wrapped": False} + 871 872 - 873 - 874class CharacterSet(Expression): - 875 arg_types = {"this": True, "default": False} + 873class CharacterSet(Expression): + 874 arg_types = {"this": True, "default": False} + 875 876 - 877 - 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")) + 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")) + 883 884 - 885 - 886class WithinGroup(Expression): - 887 arg_types = {"this": True, "expression": False} + 885class WithinGroup(Expression): + 886 arg_types = {"this": True, "expression": False} + 887 888 - 889 - 890class CTE(DerivedTable): - 891 arg_types = {"this": True, "alias": True} + 889class CTE(DerivedTable): + 890 arg_types = {"this": True, "alias": True} + 891 892 - 893 - 894class TableAlias(Expression): - 895 arg_types = {"this": False, "columns": False} - 896 - 897 @property - 898 def columns(self): - 899 return self.args.get("columns") or [] + 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 - 901 - 902class BitString(Condition): - 903 pass + 901class BitString(Condition): + 902 pass + 903 904 - 905 - 906class HexString(Condition): - 907 pass + 905class HexString(Condition): + 906 pass + 907 908 - 909 - 910class ByteString(Condition): - 911 pass + 909class ByteString(Condition): + 910 pass + 911 912 - 913 - 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) + 913class Column(Condition): + 914 arg_types = {"this": True, "table": False, "db": False, "catalog": False, "join_mark": False} + 915 + 916 @property + 917 def table(self) -> str: + 918 return self.text("table") + 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) + 948 949 - 950 - 951class ColumnPosition(Expression): - 952 arg_types = {"this": False, "position": True} + 950class ColumnPosition(Expression): + 951 arg_types = {"this": False, "position": True} + 952 953 - 954 - 955class ColumnDef(Expression): - 956 arg_types = { - 957 "this": True, - 958 "kind": False, - 959 "constraints": False, - 960 "exists": False, - 961 "position": False, - 962 } + 954class ColumnDef(Expression): + 955 arg_types = { + 956 "this": True, + 957 "kind": False, + 958 "constraints": False, + 959 "exists": False, + 960 "position": False, + 961 } + 962 963 - 964 - 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 } + 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 - 975 - 976class RenameTable(Expression): - 977 pass + 975class RenameTable(Expression): + 976 pass + 977 978 - 979 - 980class SetTag(Expression): - 981 arg_types = {"expressions": True, "unset": False} + 979class SetTag(Expression): + 980 arg_types = {"expressions": True, "unset": False} + 981 982 - 983 - 984class Comment(Expression): - 985 arg_types = {"this": True, "kind": True, "expression": True, "exists": False} + 983class Comment(Expression): + 984 arg_types = {"this": True, "kind": True, "expression": True, "exists": False} + 985 986 - 987 - 988class ColumnConstraint(Expression): - 989 arg_types = {"this": False, "kind": True} + 987class ColumnConstraint(Expression): + 988 arg_types = {"this": False, "kind": True} + 989 990 - 991 - 992class ColumnConstraintKind(Expression): - 993 pass + 991class ColumnConstraintKind(Expression): + 992 pass + 993 994 - 995 - 996class AutoIncrementColumnConstraint(ColumnConstraintKind): - 997 pass + 995class AutoIncrementColumnConstraint(ColumnConstraintKind): + 996 pass + 997 998 - 999 -1000class CaseSpecificColumnConstraint(ColumnConstraintKind): -1001 arg_types = {"not_": True} + 999class CaseSpecificColumnConstraint(ColumnConstraintKind): +1000 arg_types = {"not_": True} +1001 1002 -1003 -1004class CharacterSetColumnConstraint(ColumnConstraintKind): -1005 arg_types = {"this": True} +1003class CharacterSetColumnConstraint(ColumnConstraintKind): +1004 arg_types = {"this": True} +1005 1006 -1007 -1008class CheckColumnConstraint(ColumnConstraintKind): -1009 pass +1007class CheckColumnConstraint(ColumnConstraintKind): +1008 pass +1009 1010 -1011 -1012class CollateColumnConstraint(ColumnConstraintKind): -1013 pass +1011class CollateColumnConstraint(ColumnConstraintKind): +1012 pass +1013 1014 -1015 -1016class CommentColumnConstraint(ColumnConstraintKind): -1017 pass +1015class CommentColumnConstraint(ColumnConstraintKind): +1016 pass +1017 1018 -1019 -1020class CompressColumnConstraint(ColumnConstraintKind): -1021 pass +1019class CompressColumnConstraint(ColumnConstraintKind): +1020 pass +1021 1022 -1023 -1024class DateFormatColumnConstraint(ColumnConstraintKind): -1025 arg_types = {"this": True} +1023class DateFormatColumnConstraint(ColumnConstraintKind): +1024 arg_types = {"this": True} +1025 1026 -1027 -1028class DefaultColumnConstraint(ColumnConstraintKind): -1029 pass +1027class DefaultColumnConstraint(ColumnConstraintKind): +1028 pass +1029 1030 -1031 -1032class EncodeColumnConstraint(ColumnConstraintKind): -1033 pass +1031class EncodeColumnConstraint(ColumnConstraintKind): +1032 pass +1033 1034 -1035 -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 } +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 1046 -1047 -1048class InlineLengthColumnConstraint(ColumnConstraintKind): -1049 pass +1047class InlineLengthColumnConstraint(ColumnConstraintKind): +1048 pass +1049 1050 -1051 -1052class NotNullColumnConstraint(ColumnConstraintKind): -1053 arg_types = {"allow_null": False} +1051class NotNullColumnConstraint(ColumnConstraintKind): +1052 arg_types = {"allow_null": False} +1053 1054 -1055 -1056class PrimaryKeyColumnConstraint(ColumnConstraintKind): -1057 arg_types = {"desc": False} +1055# https://dev.mysql.com/doc/refman/5.7/en/timestamp-initialization.html +1056class OnUpdateColumnConstraint(ColumnConstraintKind): +1057 pass 1058 1059 -1060class TitleColumnConstraint(ColumnConstraintKind): -1061 pass +1060class PrimaryKeyColumnConstraint(ColumnConstraintKind): +1061 arg_types = {"desc": False} 1062 1063 -1064class UniqueColumnConstraint(ColumnConstraintKind): -1065 arg_types: t.Dict[str, t.Any] = {} +1064class TitleColumnConstraint(ColumnConstraintKind): +1065 pass 1066 1067 -1068class UppercaseColumnConstraint(ColumnConstraintKind): +1068class UniqueColumnConstraint(ColumnConstraintKind): 1069 arg_types: t.Dict[str, t.Any] = {} 1070 1071 -1072class PathColumnConstraint(ColumnConstraintKind): -1073 pass +1072class UppercaseColumnConstraint(ColumnConstraintKind): +1073 arg_types: t.Dict[str, t.Any] = {} 1074 1075 -1076class Constraint(Expression): -1077 arg_types = {"this": True, "expressions": True} +1076class PathColumnConstraint(ColumnConstraintKind): +1077 pass 1078 1079 -1080class Delete(Expression): -1081 arg_types = {"with": False, "this": False, "using": False, "where": False, "returning": False} +1080class Constraint(Expression): +1081 arg_types = {"this": True, "expressions": True} 1082 -1083 def delete( -1084 self, -1085 table: ExpOrStr, -1086 dialect: DialectType = None, -1087 copy: bool = True, -1088 **opts, -1089 ) -> Delete: -1090 """ -1091 Create a DELETE expression or replace the table on an existing DELETE expression. -1092 -1093 Example: -1094 >>> delete("tbl").sql() -1095 'DELETE FROM tbl' +1083 +1084class Delete(Expression): +1085 arg_types = {"with": False, "this": False, "using": False, "where": False, "returning": False} +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. 1096 -1097 Args: -1098 table: the table from which to delete. -1099 dialect: the dialect used to parse the input expression. -1100 copy: if `False`, modify this expression instance in-place. -1101 opts: other options to use to parse the input expressions. -1102 -1103 Returns: -1104 Delete: the modified expression. -1105 """ -1106 return _apply_builder( -1107 expression=table, -1108 instance=self, -1109 arg="this", -1110 dialect=dialect, -1111 into=Table, -1112 copy=copy, -1113 **opts, -1114 ) -1115 -1116 def where( -1117 self, -1118 *expressions: ExpOrStr, -1119 append: bool = True, -1120 dialect: DialectType = None, -1121 copy: bool = True, -1122 **opts, -1123 ) -> Delete: -1124 """ -1125 Append to or set the WHERE expressions. -1126 -1127 Example: -1128 >>> delete("tbl").where("x = 'a' OR x < 'b'").sql() -1129 "DELETE FROM tbl WHERE x = 'a' OR x < 'b'" +1097 Example: +1098 >>> delete("tbl").sql() +1099 'DELETE FROM tbl' +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 Args: -1132 *expressions: the SQL code strings to parse. -1133 If an `Expression` instance is passed, it will be used as-is. -1134 Multiple expressions are combined with an AND operator. -1135 append: if `True`, AND the new expressions to any existing expression. -1136 Otherwise, this resets the expression. -1137 dialect: the dialect used to parse the input expressions. -1138 copy: if `False`, modify this expression instance in-place. -1139 opts: other options to use to parse the input expressions. -1140 -1141 Returns: -1142 Delete: the modified expression. -1143 """ -1144 return _apply_conjunction_builder( -1145 *expressions, -1146 instance=self, -1147 arg="where", -1148 append=append, -1149 into=Where, -1150 dialect=dialect, -1151 copy=copy, -1152 **opts, -1153 ) -1154 -1155 def returning( -1156 self, -1157 expression: ExpOrStr, -1158 dialect: DialectType = None, -1159 copy: bool = True, -1160 **opts, -1161 ) -> Delete: -1162 """ -1163 Set the RETURNING expression. Not supported by all dialects. -1164 -1165 Example: -1166 >>> delete("tbl").returning("*", dialect="postgres").sql() -1167 'DELETE FROM tbl RETURNING *' +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. +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. 1168 -1169 Args: -1170 expression: the SQL code strings to parse. -1171 If an `Expression` instance is passed, it will be used as-is. -1172 dialect: the dialect used to parse the input expressions. -1173 copy: if `False`, modify this expression instance in-place. -1174 opts: other options to use to parse the input expressions. -1175 -1176 Returns: -1177 Delete: the modified expression. -1178 """ -1179 return _apply_builder( -1180 expression=expression, -1181 instance=self, -1182 arg="returning", -1183 prefix="RETURNING", -1184 dialect=dialect, -1185 copy=copy, -1186 into=Returning, -1187 **opts, -1188 ) -1189 -1190 -1191class Drop(Expression): -1192 arg_types = { -1193 "this": False, -1194 "kind": False, -1195 "exists": False, -1196 "temporary": False, -1197 "materialized": False, -1198 "cascade": False, -1199 "constraints": False, -1200 } -1201 -1202 -1203class Filter(Expression): -1204 arg_types = {"this": True, "expression": True} -1205 +1169 Example: +1170 >>> delete("tbl").returning("*", dialect="postgres").sql() +1171 'DELETE FROM tbl RETURNING *' +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 ) +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 } 1206 -1207class Check(Expression): -1208 pass -1209 +1207 +1208class Filter(Expression): +1209 arg_types = {"this": True, "expression": True} 1210 -1211class Directory(Expression): -1212 # https://spark.apache.org/docs/3.0.0-preview/sql-ref-syntax-dml-insert-overwrite-directory-hive.html -1213 arg_types = {"this": True, "local": False, "row_format": False} +1211 +1212class Check(Expression): +1213 pass 1214 1215 -1216class ForeignKey(Expression): -1217 arg_types = { -1218 "expressions": True, -1219 "reference": False, -1220 "delete": False, -1221 "update": False, -1222 } -1223 -1224 -1225class PrimaryKey(Expression): -1226 arg_types = {"expressions": True, "options": False} -1227 +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} +1219 +1220 +1221class ForeignKey(Expression): +1222 arg_types = { +1223 "expressions": True, +1224 "reference": False, +1225 "delete": False, +1226 "update": False, +1227 } 1228 -1229class Unique(Expression): -1230 arg_types = {"expressions": True} -1231 +1229 +1230class PrimaryKey(Expression): +1231 arg_types = {"expressions": True, "options": False} 1232 -1233# https://www.postgresql.org/docs/9.1/sql-selectinto.html -1234# https://docs.aws.amazon.com/redshift/latest/dg/r_SELECT_INTO.html#r_SELECT_INTO-examples -1235class Into(Expression): -1236 arg_types = {"this": True, "temporary": False, "unlogged": False} +1233 +1234class Unique(Expression): +1235 arg_types = {"expressions": True} +1236 1237 -1238 -1239class From(Expression): -1240 arg_types = {"expressions": True} -1241 +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} 1242 -1243class Having(Expression): -1244 pass -1245 +1243 +1244class From(Expression): +1245 arg_types = {"expressions": True} 1246 -1247class Hint(Expression): -1248 arg_types = {"expressions": True} -1249 +1247 +1248class Having(Expression): +1249 pass 1250 -1251class JoinHint(Expression): -1252 arg_types = {"this": True, "expressions": True} -1253 +1251 +1252class Hint(Expression): +1253 arg_types = {"expressions": True} 1254 -1255class Identifier(Expression): -1256 arg_types = {"this": True, "quoted": False} -1257 -1258 @property -1259 def quoted(self): -1260 return bool(self.args.get("quoted")) -1261 -1262 @property -1263 def hashable_args(self) -> t.Any: -1264 if self.quoted and any(char.isupper() for char in self.this): -1265 return (self.this, self.quoted) -1266 return self.this.lower() -1267 -1268 @property -1269 def output_name(self): -1270 return self.name -1271 +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 -1273class Index(Expression): -1274 arg_types = { -1275 "this": False, -1276 "table": False, -1277 "where": False, -1278 "columns": False, -1279 "unique": False, -1280 "primary": False, -1281 "amp": False, # teradata -1282 } -1283 -1284 -1285class Insert(Expression): -1286 arg_types = { -1287 "with": False, -1288 "this": True, -1289 "expression": False, -1290 "returning": False, -1291 "overwrite": False, -1292 "exists": False, -1293 "partition": False, -1294 "alternative": False, -1295 } -1296 -1297 -1298class Returning(Expression): -1299 arg_types = {"expressions": True} -1300 -1301 -1302# https://dev.mysql.com/doc/refman/8.0/en/charset-introducer.html -1303class Introducer(Expression): -1304 arg_types = {"this": True, "expression": True} -1305 -1306 -1307# national char, like n'utf8' -1308class National(Expression): -1309 pass -1310 -1311 -1312class LoadData(Expression): -1313 arg_types = { -1314 "this": True, -1315 "local": False, -1316 "overwrite": False, -1317 "inpath": True, -1318 "partition": False, -1319 "input_format": False, -1320 "serde": False, -1321 } +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 } +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} +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 -1324class Partition(Expression): -1325 arg_types = {"expressions": True} +1323# national char, like n'utf8' +1324class National(Expression): +1325 pass 1326 1327 -1328class Fetch(Expression): -1329 arg_types = {"direction": False, "count": False} -1330 -1331 -1332class Group(Expression): -1333 arg_types = { -1334 "expressions": False, -1335 "grouping_sets": False, -1336 "cube": False, -1337 "rollup": False, -1338 } +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 } +1338 1339 -1340 -1341class Lambda(Expression): -1342 arg_types = {"this": True, "expressions": True} +1340class Partition(Expression): +1341 arg_types = {"expressions": True} +1342 1343 -1344 -1345class Limit(Expression): -1346 arg_types = {"this": False, "expression": True} -1347 -1348 -1349class Literal(Condition): -1350 arg_types = {"this": True, "is_string": True} +1344class Fetch(Expression): +1345 arg_types = { +1346 "direction": False, +1347 "count": False, +1348 "percent": False, +1349 "with_ties": False, +1350 } 1351 -1352 @property -1353 def hashable_args(self) -> t.Any: -1354 return (self.this, self.args.get("is_string")) -1355 -1356 @classmethod -1357 def number(cls, number) -> Literal: -1358 return cls(this=str(number), is_string=False) -1359 -1360 @classmethod -1361 def string(cls, string) -> Literal: -1362 return cls(this=str(string), is_string=True) -1363 -1364 @property -1365 def output_name(self): -1366 return self.name -1367 +1352 +1353class Group(Expression): +1354 arg_types = { +1355 "expressions": False, +1356 "grouping_sets": False, +1357 "cube": False, +1358 "rollup": False, +1359 } +1360 +1361 +1362class Lambda(Expression): +1363 arg_types = {"this": True, "expressions": True} +1364 +1365 +1366class Limit(Expression): +1367 arg_types = {"this": False, "expression": True} 1368 -1369class Join(Expression): -1370 arg_types = { -1371 "this": True, -1372 "on": False, -1373 "side": False, -1374 "kind": False, -1375 "using": False, -1376 "natural": False, -1377 } -1378 -1379 @property -1380 def kind(self): -1381 return self.text("kind").upper() -1382 -1383 @property -1384 def side(self): -1385 return self.text("side").upper() -1386 -1387 @property -1388 def alias_or_name(self): -1389 return self.this.alias_or_name -1390 -1391 def on(self, *expressions, append=True, dialect=None, copy=True, **opts): -1392 """ -1393 Append to or set the ON expressions. -1394 -1395 Example: -1396 >>> import sqlglot -1397 >>> sqlglot.parse_one("JOIN x", into=Join).on("y = 1").sql() -1398 'JOIN x ON y = 1' -1399 -1400 Args: -1401 *expressions (str | Expression): the SQL code strings to parse. -1402 If an `Expression` instance is passed, it will be used as-is. -1403 Multiple expressions are combined with an AND operator. -1404 append (bool): if `True`, AND the new expressions to any existing expression. -1405 Otherwise, this resets the expression. -1406 dialect (str): the dialect used to parse the input expressions. -1407 copy (bool): if `False`, modify this expression instance in-place. -1408 opts (kwargs): other options to use to parse the input expressions. -1409 -1410 Returns: -1411 Join: the modified join expression. -1412 """ -1413 join = _apply_conjunction_builder( -1414 *expressions, -1415 instance=self, -1416 arg="on", -1417 append=append, -1418 dialect=dialect, -1419 copy=copy, -1420 **opts, -1421 ) -1422 -1423 if join.kind == "CROSS": -1424 join.set("kind", None) +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 +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 } +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() +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' 1425 -1426 return join -1427 -1428 def using(self, *expressions, append=True, dialect=None, copy=True, **opts): -1429 """ -1430 Append to or set the USING expressions. -1431 -1432 Example: -1433 >>> import sqlglot -1434 >>> sqlglot.parse_one("JOIN x", into=Join).using("foo", "bla").sql() -1435 'JOIN x USING (foo, bla)' -1436 -1437 Args: -1438 *expressions (str | Expression): the SQL code strings to parse. -1439 If an `Expression` instance is passed, it will be used as-is. -1440 append (bool): if `True`, concatenate the new expressions to the existing "using" list. -1441 Otherwise, this resets the expression. -1442 dialect (str): the dialect used to parse the input expressions. -1443 copy (bool): if `False`, modify this expression instance in-place. -1444 opts (kwargs): other options to use to parse the input expressions. -1445 -1446 Returns: -1447 Join: the modified join expression. -1448 """ -1449 join = _apply_list_builder( -1450 *expressions, -1451 instance=self, -1452 arg="using", -1453 append=append, -1454 dialect=dialect, -1455 copy=copy, -1456 **opts, -1457 ) -1458 -1459 if join.kind == "CROSS": -1460 join.set("kind", None) -1461 -1462 return join -1463 -1464 -1465class Lateral(UDTF): -1466 arg_types = {"this": True, "view": False, "outer": False, "alias": False} -1467 -1468 -1469class MatchRecognize(Expression): -1470 arg_types = { -1471 "partition_by": False, -1472 "order": False, -1473 "measures": False, -1474 "rows": False, -1475 "after": False, -1476 "pattern": False, -1477 "define": False, -1478 } -1479 -1480 -1481# Clickhouse FROM FINAL modifier -1482# https://clickhouse.com/docs/en/sql-reference/statements/select/from/#final-modifier -1483class Final(Expression): -1484 pass -1485 -1486 -1487class Offset(Expression): -1488 arg_types = {"this": False, "expression": True} +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. +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)' +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 ) +1484 +1485 if join.kind == "CROSS": +1486 join.set("kind", None) +1487 +1488 return join 1489 1490 -1491class Order(Expression): -1492 arg_types = {"this": False, "expressions": True} +1491class Lateral(UDTF): +1492 arg_types = {"this": True, "view": False, "outer": False, "alias": False} 1493 1494 -1495# hive specific sorts -1496# https://cwiki.apache.org/confluence/display/Hive/LanguageManual+SortBy -1497class Cluster(Order): -1498 pass -1499 -1500 -1501class Distribute(Order): -1502 pass -1503 -1504 -1505class Sort(Order): -1506 pass +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 1507 -1508 -1509class Ordered(Expression): -1510 arg_types = {"this": True, "desc": True, "nulls_first": True} -1511 +1508# Clickhouse FROM FINAL modifier +1509# https://clickhouse.com/docs/en/sql-reference/statements/select/from/#final-modifier +1510class Final(Expression): +1511 pass 1512 -1513class Property(Expression): -1514 arg_types = {"this": True, "value": True} -1515 +1513 +1514class Offset(Expression): +1515 arg_types = {"this": False, "expression": True} 1516 -1517class AfterJournalProperty(Property): -1518 arg_types = {"no": True, "dual": False, "local": False} -1519 +1517 +1518class Order(Expression): +1519 arg_types = {"this": False, "expressions": True} 1520 -1521class AlgorithmProperty(Property): -1522 arg_types = {"this": True} -1523 -1524 -1525class AutoIncrementProperty(Property): -1526 arg_types = {"this": True} +1521 +1522# hive specific sorts +1523# https://cwiki.apache.org/confluence/display/Hive/LanguageManual+SortBy +1524class Cluster(Order): +1525 pass +1526 1527 -1528 -1529class BlockCompressionProperty(Property): -1530 arg_types = {"autotemp": False, "always": False, "default": True, "manual": True, "never": True} +1528class Distribute(Order): +1529 pass +1530 1531 -1532 -1533class CharacterSetProperty(Property): -1534 arg_types = {"this": True, "default": True} +1532class Sort(Order): +1533 pass +1534 1535 -1536 -1537class ChecksumProperty(Property): -1538 arg_types = {"on": False, "default": False} +1536class Ordered(Expression): +1537 arg_types = {"this": True, "desc": True, "nulls_first": True} +1538 1539 -1540 -1541class CollateProperty(Property): -1542 arg_types = {"this": True} +1540class Property(Expression): +1541 arg_types = {"this": True, "value": True} +1542 1543 -1544 -1545class DataBlocksizeProperty(Property): -1546 arg_types = {"size": False, "units": False, "min": False, "default": False} +1544class AfterJournalProperty(Property): +1545 arg_types = {"no": True, "dual": False, "local": False} +1546 1547 -1548 -1549class DefinerProperty(Property): -1550 arg_types = {"this": True} +1548class AlgorithmProperty(Property): +1549 arg_types = {"this": True} +1550 1551 -1552 -1553class DistKeyProperty(Property): -1554 arg_types = {"this": True} +1552class AutoIncrementProperty(Property): +1553 arg_types = {"this": True} +1554 1555 -1556 -1557class DistStyleProperty(Property): -1558 arg_types = {"this": True} +1556class BlockCompressionProperty(Property): +1557 arg_types = {"autotemp": False, "always": False, "default": True, "manual": True, "never": True} +1558 1559 -1560 -1561class EngineProperty(Property): -1562 arg_types = {"this": True} +1560class CharacterSetProperty(Property): +1561 arg_types = {"this": True, "default": True} +1562 1563 -1564 -1565class ExecuteAsProperty(Property): -1566 arg_types = {"this": True} +1564class ChecksumProperty(Property): +1565 arg_types = {"on": False, "default": False} +1566 1567 -1568 -1569class ExternalProperty(Property): -1570 arg_types = {"this": False} +1568class CollateProperty(Property): +1569 arg_types = {"this": True} +1570 1571 -1572 -1573class FallbackProperty(Property): -1574 arg_types = {"no": True, "protection": False} +1572class DataBlocksizeProperty(Property): +1573 arg_types = {"size": False, "units": False, "min": False, "default": False} +1574 1575 -1576 -1577class FileFormatProperty(Property): -1578 arg_types = {"this": True} +1576class DefinerProperty(Property): +1577 arg_types = {"this": True} +1578 1579 -1580 -1581class FreespaceProperty(Property): -1582 arg_types = {"this": True, "percent": False} +1580class DistKeyProperty(Property): +1581 arg_types = {"this": True} +1582 1583 -1584 -1585class IsolatedLoadingProperty(Property): -1586 arg_types = { -1587 "no": True, -1588 "concurrent": True, -1589 "for_all": True, -1590 "for_insert": True, -1591 "for_none": True, -1592 } -1593 +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} 1594 -1595class JournalProperty(Property): -1596 arg_types = {"no": True, "dual": False, "before": False} -1597 +1595 +1596class ExternalProperty(Property): +1597 arg_types = {"this": False} 1598 -1599class LanguageProperty(Property): -1600 arg_types = {"this": True} -1601 +1599 +1600class FallbackProperty(Property): +1601 arg_types = {"no": True, "protection": False} 1602 -1603class LikeProperty(Property): -1604 arg_types = {"this": True, "expressions": False} -1605 +1603 +1604class FileFormatProperty(Property): +1605 arg_types = {"this": True} 1606 -1607class LocationProperty(Property): -1608 arg_types = {"this": True} -1609 +1607 +1608class FreespaceProperty(Property): +1609 arg_types = {"this": True, "percent": False} 1610 -1611class LockingProperty(Property): -1612 arg_types = { -1613 "this": False, -1614 "kind": True, -1615 "for_or_in": True, -1616 "lock_type": True, -1617 "override": False, -1618 } -1619 -1620 -1621class LogProperty(Property): -1622 arg_types = {"no": True} -1623 +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 -1625class MaterializedProperty(Property): -1626 arg_types = {"this": False} -1627 +1625 +1626class JournalProperty(Property): +1627 arg_types = {"no": True, "dual": False, "before": False} 1628 -1629class MergeBlockRatioProperty(Property): -1630 arg_types = {"this": False, "no": False, "default": False, "percent": False} -1631 +1629 +1630class LanguageProperty(Property): +1631 arg_types = {"this": True} 1632 -1633class NoPrimaryIndexProperty(Property): -1634 arg_types = {"this": False} -1635 +1633 +1634class LikeProperty(Property): +1635 arg_types = {"this": True, "expressions": False} 1636 -1637class OnCommitProperty(Property): -1638 arg_type = {"this": False} -1639 +1637 +1638class LocationProperty(Property): +1639 arg_types = {"this": True} 1640 -1641class PartitionedByProperty(Property): -1642 arg_types = {"this": True} -1643 -1644 -1645class ReturnsProperty(Property): -1646 arg_types = {"this": True, "is_table": False, "table": False} -1647 -1648 -1649class RowFormatDelimitedProperty(Property): -1650 # https://cwiki.apache.org/confluence/display/hive/languagemanual+dml -1651 arg_types = { -1652 "fields": False, -1653 "escaped": False, -1654 "collection_items": False, -1655 "map_keys": False, -1656 "lines": False, -1657 "null": False, -1658 "serde": False, -1659 } -1660 -1661 -1662class RowFormatSerdeProperty(Property): -1663 arg_types = {"this": True} -1664 -1665 -1666class SchemaCommentProperty(Property): -1667 arg_types = {"this": True} -1668 -1669 -1670class SerdeProperties(Property): -1671 arg_types = {"expressions": True} -1672 -1673 -1674class SetProperty(Property): -1675 arg_types = {"multi": True} -1676 -1677 -1678class SortKeyProperty(Property): -1679 arg_types = {"this": True, "compound": False} -1680 -1681 -1682class SqlSecurityProperty(Property): -1683 arg_types = {"definer": True} -1684 -1685 -1686class TableFormatProperty(Property): -1687 arg_types = {"this": True} -1688 -1689 -1690class TemporaryProperty(Property): -1691 arg_types = {"global_": True} -1692 -1693 -1694class TransientProperty(Property): -1695 arg_types = {"this": False} +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 } +1650 +1651 +1652class LogProperty(Property): +1653 arg_types = {"no": True} +1654 +1655 +1656class MaterializedProperty(Property): +1657 arg_types = {"this": False} +1658 +1659 +1660class MergeBlockRatioProperty(Property): +1661 arg_types = {"this": False, "no": False, "default": False, "percent": False} +1662 +1663 +1664class NoPrimaryIndexProperty(Property): +1665 arg_types = {"this": False} +1666 +1667 +1668class OnCommitProperty(Property): +1669 arg_type = {"this": False} +1670 +1671 +1672class PartitionedByProperty(Property): +1673 arg_types = {"this": True} +1674 +1675 +1676class ReturnsProperty(Property): +1677 arg_types = {"this": True, "is_table": False, "table": False} +1678 +1679 +1680class RowFormatProperty(Property): +1681 arg_types = {"this": True} +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 -1697 -1698class VolatilityProperty(Property): -1699 arg_types = {"this": True} +1697class RowFormatSerdeProperty(Property): +1698 arg_types = {"this": True} +1699 1700 -1701 -1702class WithDataProperty(Property): -1703 arg_types = {"no": True, "statistics": False} +1701class SchemaCommentProperty(Property): +1702 arg_types = {"this": True} +1703 1704 -1705 -1706class WithJournalTableProperty(Property): -1707 arg_types = {"this": True} +1705class SerdeProperties(Property): +1706 arg_types = {"expressions": True} +1707 1708 -1709 -1710class Properties(Expression): -1711 arg_types = {"expressions": True} +1709class SetProperty(Property): +1710 arg_types = {"multi": True} +1711 1712 -1713 NAME_TO_PROPERTY = { -1714 "ALGORITHM": AlgorithmProperty, -1715 "AUTO_INCREMENT": AutoIncrementProperty, -1716 "CHARACTER SET": CharacterSetProperty, -1717 "COLLATE": CollateProperty, -1718 "COMMENT": SchemaCommentProperty, -1719 "DEFINER": DefinerProperty, -1720 "DISTKEY": DistKeyProperty, -1721 "DISTSTYLE": DistStyleProperty, -1722 "ENGINE": EngineProperty, -1723 "EXECUTE AS": ExecuteAsProperty, -1724 "FORMAT": FileFormatProperty, -1725 "LANGUAGE": LanguageProperty, -1726 "LOCATION": LocationProperty, -1727 "PARTITIONED_BY": PartitionedByProperty, -1728 "RETURNS": ReturnsProperty, -1729 "SORTKEY": SortKeyProperty, -1730 "TABLE_FORMAT": TableFormatProperty, -1731 } +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 -1733 PROPERTY_TO_NAME = {v: k for k, v in NAME_TO_PROPERTY.items()} -1734 -1735 # CREATE property locations -1736 # Form: schema specified -1737 # create [POST_CREATE] -1738 # table a [POST_NAME] -1739 # (b int) [POST_SCHEMA] -1740 # with ([POST_WITH]) -1741 # index (b) [POST_INDEX] -1742 # -1743 # Form: alias selection -1744 # create [POST_CREATE] -1745 # table a [POST_NAME] -1746 # as [POST_ALIAS] (select * from b) [POST_EXPRESSION] -1747 # index (c) [POST_INDEX] -1748 class Location(AutoName): -1749 POST_CREATE = auto() -1750 POST_NAME = auto() -1751 POST_SCHEMA = auto() -1752 POST_WITH = auto() -1753 POST_ALIAS = auto() -1754 POST_EXPRESSION = auto() -1755 POST_INDEX = auto() -1756 UNSUPPORTED = auto() -1757 -1758 @classmethod -1759 def from_dict(cls, properties_dict) -> Properties: -1760 expressions = [] -1761 for key, value in properties_dict.items(): -1762 property_cls = cls.NAME_TO_PROPERTY.get(key.upper()) -1763 if property_cls: -1764 expressions.append(property_cls(this=convert(value))) -1765 else: -1766 expressions.append(Property(this=Literal.string(key), value=convert(value))) -1767 -1768 return cls(expressions=expressions) -1769 -1770 -1771class Qualify(Expression): -1772 pass -1773 +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} +1747 +1748 +1749class Properties(Expression): +1750 arg_types = {"expressions": True} +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()} 1774 -1775# https://www.ibm.com/docs/en/ias?topic=procedures-return-statement-in-sql -1776class Return(Expression): -1777 pass -1778 -1779 -1780class Reference(Expression): -1781 arg_types = {"this": True, "expressions": False, "options": False} -1782 -1783 -1784class Tuple(Expression): -1785 arg_types = {"expressions": False} -1786 -1787 -1788class Subqueryable(Unionable): -1789 def subquery(self, alias=None, copy=True) -> Subquery: -1790 """ -1791 Convert this expression to an aliased expression that can be used as a Subquery. -1792 -1793 Example: -1794 >>> subquery = Select().select("x").from_("tbl").subquery() -1795 >>> Select().select("x").from_(subquery).sql() -1796 'SELECT x FROM (SELECT x FROM tbl)' +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() 1797 -1798 Args: -1799 alias (str | Identifier): an optional alias for the subquery -1800 copy (bool): if `False`, modify this expression instance in-place. -1801 -1802 Returns: -1803 Alias: the subquery -1804 """ -1805 instance = _maybe_copy(self, copy) -1806 return Subquery( -1807 this=instance, -1808 alias=TableAlias(this=to_identifier(alias)) if alias else None, -1809 ) +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 -1811 def limit(self, expression, dialect=None, copy=True, **opts) -> Select: -1812 raise NotImplementedError +1811class Qualify(Expression): +1812 pass 1813 -1814 @property -1815 def ctes(self): -1816 with_ = self.args.get("with") -1817 if not with_: -1818 return [] -1819 return with_.expressions -1820 -1821 @property -1822 def selects(self): -1823 raise NotImplementedError("Subqueryable objects must implement `selects`") -1824 -1825 @property -1826 def named_selects(self): -1827 raise NotImplementedError("Subqueryable objects must implement `named_selects`") -1828 -1829 def with_( -1830 self, -1831 alias, -1832 as_, -1833 recursive=None, -1834 append=True, -1835 dialect=None, -1836 copy=True, -1837 **opts, -1838 ): -1839 """ -1840 Append to or set the common table expressions. +1814 +1815# https://www.ibm.com/docs/en/ias?topic=procedures-return-statement-in-sql +1816class Return(Expression): +1817 pass +1818 +1819 +1820class Reference(Expression): +1821 arg_types = {"this": True, "expressions": False, "options": False} +1822 +1823 +1824class Tuple(Expression): +1825 arg_types = {"expressions": False} +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 Example: -1843 >>> Select().with_("tbl2", as_="SELECT * FROM tbl").select("x").from_("tbl2").sql() -1844 'WITH tbl2 AS (SELECT * FROM tbl) SELECT x FROM tbl2' -1845 -1846 Args: -1847 alias (str | Expression): the SQL code string to parse as the table name. -1848 If an `Expression` instance is passed, this is used as-is. -1849 as_ (str | Expression): the SQL code string to parse as the table expression. -1850 If an `Expression` instance is passed, it will be used as-is. -1851 recursive (bool): set the RECURSIVE part of the expression. Defaults to `False`. -1852 append (bool): if `True`, add to any existing expressions. -1853 Otherwise, this resets the expressions. -1854 dialect (str): the dialect used to parse the input expression. -1855 copy (bool): if `False`, modify this expression instance in-place. -1856 opts (kwargs): other options to use to parse the input expressions. -1857 -1858 Returns: -1859 Select: the modified expression. -1860 """ -1861 alias_expression = maybe_parse( -1862 alias, -1863 dialect=dialect, -1864 into=TableAlias, -1865 **opts, -1866 ) -1867 as_expression = maybe_parse( -1868 as_, -1869 dialect=dialect, -1870 **opts, -1871 ) -1872 cte = CTE( -1873 this=as_expression, -1874 alias=alias_expression, -1875 ) -1876 return _apply_child_list_builder( -1877 cte, -1878 instance=self, -1879 arg="with", -1880 append=append, -1881 copy=copy, -1882 into=With, -1883 properties={"recursive": recursive or False}, -1884 ) +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 ) +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 -1887QUERY_MODIFIERS = { -1888 "match": False, -1889 "laterals": False, -1890 "joins": False, -1891 "pivots": False, -1892 "where": False, -1893 "group": False, -1894 "having": False, -1895 "qualify": False, -1896 "windows": False, -1897 "distribute": False, -1898 "sort": False, -1899 "cluster": False, -1900 "order": False, -1901 "limit": False, -1902 "offset": False, -1903 "lock": False, -1904 "sample": False, -1905} -1906 -1907 -1908class Table(Expression): -1909 arg_types = { -1910 "this": True, -1911 "alias": False, -1912 "db": False, -1913 "catalog": False, -1914 "laterals": False, -1915 "joins": False, -1916 "pivots": False, -1917 "hints": False, -1918 "system_time": False, -1919 } -1920 -1921 @property -1922 def db(self) -> str: -1923 return self.text("db") -1924 -1925 @property -1926 def catalog(self) -> str: -1927 return self.text("catalog") -1928 -1929 -1930# See the TSQL "Querying data in a system-versioned temporal table" page -1931class SystemTime(Expression): -1932 arg_types = { -1933 "this": False, -1934 "expression": False, -1935 "kind": True, -1936 } -1937 -1938 -1939class Union(Subqueryable): -1940 arg_types = { -1941 "with": False, -1942 "this": True, -1943 "expression": True, -1944 "distinct": False, -1945 **QUERY_MODIFIERS, -1946 } +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. +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} +1946 1947 -1948 def limit(self, expression, dialect=None, copy=True, **opts) -> Select: -1949 """ -1950 Set the LIMIT expression. -1951 -1952 Example: -1953 >>> select("1").union(select("1")).limit(1).sql() -1954 'SELECT * FROM (SELECT 1 UNION SELECT 1) AS _l_0 LIMIT 1' -1955 -1956 Args: -1957 expression (str | int | Expression): the SQL code string to parse. -1958 This can also be an integer. -1959 If a `Limit` instance is passed, this is used as-is. -1960 If another `Expression` instance is passed, it will be wrapped in a `Limit`. -1961 dialect (str): the dialect used to parse the input expression. -1962 copy (bool): if `False`, modify this expression instance in-place. -1963 opts (kwargs): other options to use to parse the input expressions. +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 } +1960 +1961 @property +1962 def db(self) -> str: +1963 return self.text("db") 1964 -1965 Returns: -1966 Select: The limited subqueryable. -1967 """ -1968 return ( -1969 select("*") -1970 .from_(self.subquery(alias="_l_0", copy=copy)) -1971 .limit(expression, dialect=dialect, copy=False, **opts) -1972 ) -1973 -1974 def select( -1975 self, -1976 *expressions: ExpOrStr, -1977 append: bool = True, -1978 dialect: DialectType = None, -1979 copy: bool = True, -1980 **opts, -1981 ) -> Union: -1982 """Append to or set the SELECT of the union recursively. -1983 -1984 Example: -1985 >>> from sqlglot import parse_one -1986 >>> parse_one("select a from x union select a from y union select a from z").select("b").sql() -1987 'SELECT a, b FROM x UNION SELECT a, b FROM y UNION SELECT a, b FROM z' -1988 -1989 Args: -1990 *expressions: the SQL code strings to parse. -1991 If an `Expression` instance is passed, it will be used as-is. -1992 append: if `True`, add to any existing expressions. -1993 Otherwise, this resets the expressions. -1994 dialect: the dialect used to parse the input expressions. -1995 copy: if `False`, modify this expression instance in-place. -1996 opts: other options to use to parse the input expressions. -1997 -1998 Returns: -1999 Union: the modified expression. -2000 """ -2001 this = self.copy() if copy else self -2002 this.this.unnest().select(*expressions, append=append, dialect=dialect, copy=False, **opts) -2003 this.expression.unnest().select( -2004 *expressions, append=append, dialect=dialect, copy=False, **opts -2005 ) -2006 return this -2007 -2008 @property -2009 def named_selects(self): -2010 return self.this.unnest().named_selects -2011 -2012 @property -2013 def is_star(self) -> bool: -2014 return self.this.is_star or self.expression.is_star -2015 -2016 @property -2017 def selects(self): -2018 return self.this.unnest().selects -2019 -2020 @property -2021 def left(self): -2022 return self.this +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 } +1987 +1988 def limit(self, expression, dialect=None, copy=True, **opts) -> Select: +1989 """ +1990 Set the LIMIT expression. +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. +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 @property -2025 def right(self): -2026 return self.expression -2027 +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 -2029class Except(Union): -2030 pass -2031 -2032 -2033class Intersect(Union): -2034 pass -2035 -2036 -2037class Unnest(UDTF): -2038 arg_types = { -2039 "expressions": True, -2040 "ordinality": False, -2041 "alias": False, -2042 "offset": False, -2043 } -2044 -2045 -2046class Update(Expression): -2047 arg_types = { -2048 "with": False, -2049 "this": False, -2050 "expressions": True, -2051 "from": False, -2052 "where": False, -2053 "returning": False, -2054 } +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 -2057class Values(UDTF): -2058 arg_types = { -2059 "expressions": True, -2060 "ordinality": False, -2061 "alias": False, -2062 } +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 -2065class Var(Expression): -2066 pass +2064 @property +2065 def right(self): +2066 return self.expression 2067 2068 -2069class Schema(Expression): -2070 arg_types = {"this": False, "expressions": False} +2069class Except(Union): +2070 pass 2071 2072 -2073# Used to represent the FOR UPDATE and FOR SHARE locking read types. -2074# https://dev.mysql.com/doc/refman/8.0/en/innodb-locking-reads.html -2075class Lock(Expression): -2076 arg_types = {"update": True} -2077 -2078 -2079class Select(Subqueryable): -2080 arg_types = { -2081 "with": False, -2082 "kind": False, -2083 "expressions": False, -2084 "hint": False, -2085 "distinct": False, -2086 "into": False, -2087 "from": False, -2088 **QUERY_MODIFIERS, -2089 } -2090 -2091 def from_(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: -2092 """ -2093 Set the FROM expression. -2094 -2095 Example: -2096 >>> Select().from_("tbl").select("x").sql() -2097 'SELECT x FROM tbl' -2098 -2099 Args: -2100 *expressions (str | Expression): the SQL code strings to parse. -2101 If a `From` instance is passed, this is used as-is. -2102 If another `Expression` instance is passed, it will be wrapped in a `From`. -2103 append (bool): if `True`, add to any existing expressions. -2104 Otherwise, this flattens all the `From` expression into a single expression. -2105 dialect (str): the dialect used to parse the input expression. -2106 copy (bool): if `False`, modify this expression instance in-place. -2107 opts (kwargs): other options to use to parse the input expressions. +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 -2109 Returns: -2110 Select: the modified expression. -2111 """ -2112 return _apply_child_list_builder( -2113 *expressions, -2114 instance=self, -2115 arg="from", -2116 append=append, -2117 copy=copy, -2118 prefix="FROM", -2119 into=From, -2120 dialect=dialect, -2121 **opts, -2122 ) -2123 -2124 def group_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: -2125 """ -2126 Set the GROUP BY expression. -2127 -2128 Example: -2129 >>> Select().from_("tbl").select("x", "COUNT(1)").group_by("x").sql() -2130 'SELECT x, COUNT(1) FROM tbl GROUP BY x' -2131 -2132 Args: -2133 *expressions (str | Expression): the SQL code strings to parse. -2134 If a `Group` instance is passed, this is used as-is. -2135 If another `Expression` instance is passed, it will be wrapped in a `Group`. -2136 If nothing is passed in then a group by is not applied to the expression -2137 append (bool): if `True`, add to any existing expressions. -2138 Otherwise, this flattens all the `Group` expression into a single expression. -2139 dialect (str): the dialect used to parse the input expression. -2140 copy (bool): if `False`, modify this expression instance in-place. -2141 opts (kwargs): other options to use to parse the input expressions. -2142 -2143 Returns: -2144 Select: the modified expression. -2145 """ -2146 if not expressions: -2147 return self if not copy else self.copy() -2148 return _apply_child_list_builder( -2149 *expressions, -2150 instance=self, -2151 arg="group", -2152 append=append, -2153 copy=copy, -2154 prefix="GROUP BY", -2155 into=Group, -2156 dialect=dialect, -2157 **opts, -2158 ) -2159 -2160 def order_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: -2161 """ -2162 Set the ORDER BY expression. +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 +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 Example: -2165 >>> Select().from_("tbl").select("x").order_by("x DESC").sql() -2166 'SELECT x FROM tbl ORDER BY x DESC' +2164 def group_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: +2165 """ +2166 Set the GROUP BY expression. 2167 -2168 Args: -2169 *expressions (str | Expression): the SQL code strings to parse. -2170 If a `Group` instance is passed, this is used as-is. -2171 If another `Expression` instance is passed, it will be wrapped in a `Order`. -2172 append (bool): if `True`, add to any existing expressions. -2173 Otherwise, this flattens all the `Order` expression into a single expression. -2174 dialect (str): the dialect used to parse the input expression. -2175 copy (bool): if `False`, modify this expression instance in-place. -2176 opts (kwargs): other options to use to parse the input expressions. -2177 -2178 Returns: -2179 Select: the modified expression. -2180 """ -2181 return _apply_child_list_builder( -2182 *expressions, -2183 instance=self, -2184 arg="order", -2185 append=append, -2186 copy=copy, -2187 prefix="ORDER BY", -2188 into=Order, -2189 dialect=dialect, -2190 **opts, -2191 ) -2192 -2193 def sort_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: -2194 """ -2195 Set the SORT BY expression. -2196 -2197 Example: -2198 >>> Select().from_("tbl").select("x").sort_by("x DESC").sql() -2199 'SELECT x FROM tbl SORT BY x DESC' -2200 -2201 Args: -2202 *expressions (str | Expression): the SQL code strings to parse. -2203 If a `Group` instance is passed, this is used as-is. -2204 If another `Expression` instance is passed, it will be wrapped in a `SORT`. -2205 append (bool): if `True`, add to any existing expressions. -2206 Otherwise, this flattens all the `Order` expression into a single expression. -2207 dialect (str): the dialect used to parse the input expression. -2208 copy (bool): if `False`, modify this expression instance in-place. -2209 opts (kwargs): other options to use to parse the input expressions. -2210 -2211 Returns: -2212 Select: the modified expression. -2213 """ -2214 return _apply_child_list_builder( -2215 *expressions, -2216 instance=self, -2217 arg="sort", -2218 append=append, -2219 copy=copy, -2220 prefix="SORT BY", -2221 into=Sort, -2222 dialect=dialect, -2223 **opts, -2224 ) -2225 -2226 def cluster_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: -2227 """ -2228 Set the CLUSTER BY expression. -2229 -2230 Example: -2231 >>> Select().from_("tbl").select("x").cluster_by("x DESC").sql() -2232 'SELECT x FROM tbl CLUSTER BY x DESC' -2233 -2234 Args: -2235 *expressions (str | Expression): the SQL code strings to parse. -2236 If a `Group` instance is passed, this is used as-is. -2237 If another `Expression` instance is passed, it will be wrapped in a `Cluster`. -2238 append (bool): if `True`, add to any existing expressions. -2239 Otherwise, this flattens all the `Order` expression into a single expression. -2240 dialect (str): the dialect used to parse the input expression. -2241 copy (bool): if `False`, modify this expression instance in-place. -2242 opts (kwargs): other options to use to parse the input expressions. -2243 -2244 Returns: -2245 Select: the modified expression. -2246 """ -2247 return _apply_child_list_builder( -2248 *expressions, -2249 instance=self, -2250 arg="cluster", -2251 append=append, -2252 copy=copy, -2253 prefix="CLUSTER BY", -2254 into=Cluster, -2255 dialect=dialect, -2256 **opts, -2257 ) -2258 -2259 def limit(self, expression, dialect=None, copy=True, **opts) -> Select: -2260 """ -2261 Set the LIMIT expression. -2262 -2263 Example: -2264 >>> Select().from_("tbl").select("x").limit(10).sql() -2265 'SELECT x FROM tbl LIMIT 10' -2266 -2267 Args: -2268 expression (str | int | Expression): the SQL code string to parse. -2269 This can also be an integer. -2270 If a `Limit` instance is passed, this is used as-is. -2271 If another `Expression` instance is passed, it will be wrapped in a `Limit`. -2272 dialect (str): the dialect used to parse the input expression. -2273 copy (bool): if `False`, modify this expression instance in-place. -2274 opts (kwargs): other options to use to parse the input expressions. -2275 -2276 Returns: -2277 Select: the modified expression. -2278 """ -2279 return _apply_builder( -2280 expression=expression, -2281 instance=self, -2282 arg="limit", -2283 into=Limit, -2284 prefix="LIMIT", -2285 dialect=dialect, -2286 copy=copy, -2287 **opts, -2288 ) -2289 -2290 def offset(self, expression, dialect=None, copy=True, **opts) -> Select: -2291 """ -2292 Set the OFFSET expression. -2293 -2294 Example: -2295 >>> Select().from_("tbl").select("x").offset(10).sql() -2296 'SELECT x FROM tbl OFFSET 10' -2297 -2298 Args: -2299 expression (str | int | Expression): the SQL code string to parse. -2300 This can also be an integer. -2301 If a `Offset` instance is passed, this is used as-is. -2302 If another `Expression` instance is passed, it will be wrapped in a `Offset`. -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. +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. +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 ) +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' +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' +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 Returns: -2308 Select: the modified expression. -2309 """ -2310 return _apply_builder( -2311 expression=expression, -2312 instance=self, -2313 arg="offset", -2314 into=Offset, -2315 prefix="OFFSET", -2316 dialect=dialect, -2317 copy=copy, -2318 **opts, -2319 ) -2320 -2321 def select( -2322 self, -2323 *expressions: ExpOrStr, -2324 append: bool = True, -2325 dialect: DialectType = None, -2326 copy: bool = True, -2327 **opts, -2328 ) -> Select: -2329 """ -2330 Append to or set the SELECT expressions. -2331 -2332 Example: -2333 >>> Select().select("x", "y").sql() -2334 'SELECT x, y' -2335 -2336 Args: -2337 *expressions: the SQL code strings to parse. -2338 If an `Expression` instance is passed, it will be used as-is. -2339 append: if `True`, add to any existing expressions. -2340 Otherwise, this resets the expressions. -2341 dialect: the dialect used to parse the input expressions. -2342 copy: if `False`, modify this expression instance in-place. -2343 opts: other options to use to parse the input expressions. -2344 -2345 Returns: -2346 Select: the modified expression. -2347 """ -2348 return _apply_list_builder( -2349 *expressions, -2350 instance=self, -2351 arg="expressions", -2352 append=append, -2353 dialect=dialect, -2354 copy=copy, -2355 **opts, -2356 ) -2357 -2358 def lateral(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: -2359 """ -2360 Append to or set the LATERAL expressions. -2361 -2362 Example: -2363 >>> Select().select("x").lateral("OUTER explode(y) tbl2 AS z").from_("tbl").sql() -2364 'SELECT x FROM tbl LATERAL VIEW OUTER EXPLODE(y) tbl2 AS z' -2365 -2366 Args: -2367 *expressions (str | Expression): the SQL code strings to parse. -2368 If an `Expression` instance is passed, it will be used as-is. -2369 append (bool): if `True`, add to any existing expressions. -2370 Otherwise, this resets the expressions. -2371 dialect (str): the dialect used to parse the input expressions. -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_list_builder( -2379 *expressions, -2380 instance=self, -2381 arg="laterals", -2382 append=append, -2383 into=Lateral, -2384 prefix="LATERAL VIEW", -2385 dialect=dialect, -2386 copy=copy, -2387 **opts, -2388 ) -2389 -2390 def join( -2391 self, -2392 expression, -2393 on=None, -2394 using=None, -2395 append=True, -2396 join_type=None, -2397 join_alias=None, -2398 dialect=None, -2399 copy=True, -2400 **opts, -2401 ) -> Select: -2402 """ -2403 Append to or set the JOIN expressions. -2404 -2405 Example: -2406 >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y").sql() -2407 'SELECT * FROM tbl JOIN tbl2 ON tbl1.y = tbl2.y' -2408 -2409 >>> Select().select("1").from_("a").join("b", using=["x", "y", "z"]).sql() -2410 'SELECT 1 FROM a JOIN b USING (x, y, z)' -2411 -2412 Use `join_type` to change the type of join: -2413 -2414 >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y", join_type="left outer").sql() -2415 'SELECT * FROM tbl LEFT OUTER JOIN tbl2 ON tbl1.y = tbl2.y' -2416 -2417 Args: -2418 expression (str | Expression): the SQL code string to parse. -2419 If an `Expression` instance is passed, it will be used as-is. -2420 on (str | Expression): optionally specify the join "on" criteria as a SQL string. -2421 If an `Expression` instance is passed, it will be used as-is. -2422 using (str | Expression): optionally specify the join "using" criteria as a SQL string. -2423 If an `Expression` instance is passed, it will be used as-is. -2424 append (bool): if `True`, add to any existing expressions. -2425 Otherwise, this resets the expressions. -2426 join_type (str): If set, alter the parsed join type -2427 dialect (str): the dialect used to parse the input expressions. -2428 copy (bool): if `False`, modify this expression instance in-place. -2429 opts (kwargs): other options to use to parse the input expressions. -2430 -2431 Returns: -2432 Select: the modified expression. -2433 """ -2434 parse_args = {"dialect": dialect, **opts} -2435 -2436 try: -2437 expression = maybe_parse(expression, into=Join, prefix="JOIN", **parse_args) -2438 except ParseError: -2439 expression = maybe_parse(expression, into=(Join, Expression), **parse_args) -2440 -2441 join = expression if isinstance(expression, Join) else Join(this=expression) -2442 -2443 if isinstance(join.this, Select): -2444 join.this.replace(join.this.subquery()) -2445 -2446 if join_type: -2447 natural: t.Optional[Token] -2448 side: t.Optional[Token] -2449 kind: t.Optional[Token] -2450 -2451 natural, side, kind = maybe_parse(join_type, into="JOIN_TYPE", **parse_args) # type: ignore -2452 -2453 if natural: -2454 join.set("natural", True) -2455 if side: -2456 join.set("side", side.text) -2457 if kind: -2458 join.set("kind", kind.text) -2459 -2460 if on: -2461 on = and_(*ensure_collection(on), dialect=dialect, **opts) -2462 join.set("on", on) -2463 -2464 if using: -2465 join = _apply_list_builder( -2466 *ensure_collection(using), -2467 instance=join, -2468 arg="using", -2469 append=append, -2470 copy=copy, -2471 **opts, -2472 ) -2473 -2474 if join_alias: -2475 join.set("this", alias_(join.this, join_alias, table=True)) -2476 return _apply_list_builder( -2477 join, -2478 instance=self, -2479 arg="joins", -2480 append=append, -2481 copy=copy, -2482 **opts, -2483 ) -2484 -2485 def where(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: -2486 """ -2487 Append to or set the WHERE expressions. -2488 -2489 Example: -2490 >>> Select().select("x").from_("tbl").where("x = 'a' OR x < 'b'").sql() -2491 "SELECT x FROM tbl WHERE x = 'a' OR x < 'b'" +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 ) +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' +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 Args: -2494 *expressions (str | Expression): the SQL code strings to parse. -2495 If an `Expression` instance is passed, it will be used as-is. -2496 Multiple expressions are combined with an AND operator. -2497 append (bool): if `True`, AND the new expressions to any existing expression. -2498 Otherwise, this resets the expression. -2499 dialect (str): the dialect used to parse the input expressions. -2500 copy (bool): if `False`, modify this expression instance in-place. -2501 opts (kwargs): other options to use to parse the input expressions. -2502 -2503 Returns: -2504 Select: the modified expression. -2505 """ -2506 return _apply_conjunction_builder( -2507 *expressions, -2508 instance=self, -2509 arg="where", -2510 append=append, -2511 into=Where, -2512 dialect=dialect, -2513 copy=copy, -2514 **opts, -2515 ) -2516 -2517 def having(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: -2518 """ -2519 Append to or set the HAVING expressions. -2520 -2521 Example: -2522 >>> Select().select("x", "COUNT(y)").from_("tbl").group_by("x").having("COUNT(y) > 3").sql() -2523 'SELECT x, COUNT(y) FROM tbl GROUP BY x HAVING COUNT(y) > 3' +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 ) 2524 -2525 Args: -2526 *expressions (str | Expression): the SQL code strings to parse. -2527 If an `Expression` instance is passed, it will be used as-is. -2528 Multiple expressions are combined with an AND operator. -2529 append (bool): if `True`, AND the new expressions to any existing expression. -2530 Otherwise, this resets the expression. -2531 dialect (str): the dialect used to parse the input expressions. -2532 copy (bool): if `False`, modify this expression instance in-place. -2533 opts (kwargs): other options to use to parse the input expressions. -2534 -2535 Returns: -2536 Select: the modified expression. -2537 """ -2538 return _apply_conjunction_builder( -2539 *expressions, -2540 instance=self, -2541 arg="having", -2542 append=append, -2543 into=Having, -2544 dialect=dialect, -2545 copy=copy, -2546 **opts, -2547 ) -2548 -2549 def window(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: -2550 return _apply_list_builder( -2551 *expressions, -2552 instance=self, -2553 arg="windows", -2554 append=append, -2555 into=Window, -2556 dialect=dialect, -2557 copy=copy, -2558 **opts, -2559 ) +2525 def where(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: +2526 """ +2527 Append to or set the WHERE expressions. +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 def qualify(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select: -2562 return _apply_conjunction_builder( -2563 *expressions, -2564 instance=self, -2565 arg="qualify", -2566 append=append, -2567 into=Qualify, -2568 dialect=dialect, -2569 copy=copy, -2570 **opts, -2571 ) -2572 -2573 def distinct(self, distinct=True, copy=True) -> Select: -2574 """ -2575 Set the OFFSET expression. -2576 -2577 Example: -2578 >>> Select().from_("tbl").select("x").distinct().sql() -2579 'SELECT DISTINCT x FROM tbl' -2580 -2581 Args: -2582 distinct (bool): whether the Select should be distinct -2583 copy (bool): if `False`, modify this expression instance in-place. -2584 -2585 Returns: -2586 Select: the modified expression. -2587 """ -2588 instance = _maybe_copy(self, copy) -2589 instance.set("distinct", Distinct() if distinct else None) -2590 return instance -2591 -2592 def ctas(self, table, properties=None, dialect=None, copy=True, **opts) -> Create: -2593 """ -2594 Convert this expression to a CREATE TABLE AS statement. -2595 -2596 Example: -2597 >>> Select().select("*").from_("tbl").ctas("x").sql() -2598 'CREATE TABLE x AS SELECT * FROM tbl' -2599 -2600 Args: -2601 table (str | Expression): the SQL code string to parse as the table name. -2602 If another `Expression` instance is passed, it will be used as-is. -2603 properties (dict): an optional mapping of table properties -2604 dialect (str): the dialect used to parse the input table. -2605 copy (bool): if `False`, modify this expression instance in-place. -2606 opts (kwargs): other options to use to parse the input table. -2607 -2608 Returns: -2609 Create: the CREATE TABLE AS expression -2610 """ -2611 instance = _maybe_copy(self, copy) -2612 table_expression = maybe_parse( -2613 table, -2614 into=Table, -2615 dialect=dialect, -2616 **opts, -2617 ) -2618 properties_expression = None -2619 if properties: -2620 properties_expression = Properties.from_dict(properties) -2621 -2622 return Create( -2623 this=table_expression, -2624 kind="table", -2625 expression=instance, -2626 properties=properties_expression, -2627 ) -2628 -2629 def lock(self, update: bool = True, copy: bool = True) -> Select: -2630 """ -2631 Set the locking read mode for this expression. -2632 -2633 Examples: -2634 >>> Select().select("x").from_("tbl").where("x = 'a'").lock().sql("mysql") -2635 "SELECT x FROM tbl WHERE x = 'a' FOR UPDATE" -2636 -2637 >>> Select().select("x").from_("tbl").where("x = 'a'").lock(update=False).sql("mysql") -2638 "SELECT x FROM tbl WHERE x = 'a' FOR SHARE" +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. +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 update: if `True`, the locking type will be `FOR UPDATE`, else it will be `FOR SHARE`. -2642 copy: if `False`, modify this expression instance in-place. -2643 -2644 Returns: -2645 The modified expression. -2646 """ +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. 2647 -2648 inst = _maybe_copy(self, copy) -2649 inst.set("lock", Lock(update=update)) -2650 -2651 return inst -2652 -2653 @property -2654 def named_selects(self) -> t.List[str]: -2655 return [e.output_name for e in self.expressions if e.alias_or_name] -2656 -2657 @property -2658 def is_star(self) -> bool: -2659 return any(expression.is_star for expression in self.expressions) -2660 -2661 @property -2662 def selects(self) -> t.List[Expression]: -2663 return self.expressions -2664 -2665 -2666class Subquery(DerivedTable, Unionable): -2667 arg_types = { -2668 "this": True, -2669 "alias": False, -2670 "with": False, -2671 **QUERY_MODIFIERS, -2672 } -2673 -2674 def unnest(self): -2675 """ -2676 Returns the first non subquery. -2677 """ -2678 expression = self -2679 while isinstance(expression, Subquery): -2680 expression = expression.this -2681 return expression -2682 -2683 @property -2684 def is_star(self) -> bool: -2685 return self.this.is_star -2686 -2687 @property -2688 def output_name(self): -2689 return self.alias +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" +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. +2683 +2684 Returns: +2685 The modified expression. +2686 """ +2687 +2688 inst = _maybe_copy(self, copy) +2689 inst.set("lock", Lock(update=update)) 2690 -2691 -2692class TableSample(Expression): -2693 arg_types = { -2694 "this": False, -2695 "method": False, -2696 "bucket_numerator": False, -2697 "bucket_denominator": False, -2698 "bucket_field": False, -2699 "percent": False, -2700 "rows": False, -2701 "size": False, -2702 "seed": False, -2703 "kind": False, -2704 } +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 -2706 -2707class Tag(Expression): -2708 """Tags are used for generating arbitrary sql like SELECT <span>x</span>.""" -2709 -2710 arg_types = { -2711 "this": False, -2712 "prefix": False, -2713 "postfix": False, -2714 } -2715 -2716 -2717class Pivot(Expression): -2718 arg_types = { -2719 "this": False, -2720 "alias": False, -2721 "expressions": True, -2722 "field": True, -2723 "unpivot": True, -2724 } -2725 +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 -2727class Window(Expression): -2728 arg_types = { -2729 "this": True, -2730 "partition_by": False, -2731 "order": False, -2732 "spec": False, -2733 "alias": False, -2734 } -2735 -2736 -2737class WindowSpec(Expression): -2738 arg_types = { -2739 "kind": False, -2740 "start": False, -2741 "start_side": False, -2742 "end": False, -2743 "end_side": False, +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 Where(Expression): -2748 pass +2747class Tag(Expression): +2748 """Tags are used for generating arbitrary sql like SELECT <span>x</span>.""" 2749 -2750 -2751class Star(Expression): -2752 arg_types = {"except": False, "replace": False} -2753 -2754 @property -2755 def name(self) -> str: -2756 return "*" -2757 -2758 @property -2759 def output_name(self): -2760 return self.name -2761 -2762 -2763class Parameter(Expression): -2764 arg_types = {"this": True, "wrapped": False} -2765 +2750 arg_types = { +2751 "this": False, +2752 "prefix": False, +2753 "postfix": False, +2754 } +2755 +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 -2767class SessionParameter(Expression): -2768 arg_types = {"this": True, "kind": False} -2769 -2770 -2771class Placeholder(Expression): -2772 arg_types = {"this": False} -2773 -2774 -2775class Null(Condition): -2776 arg_types: t.Dict[str, t.Any] = {} +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 -2778 @property -2779 def name(self) -> str: -2780 return "NULL" -2781 -2782 -2783class Boolean(Condition): -2784 pass -2785 +2778class WindowSpec(Expression): +2779 arg_types = { +2780 "kind": False, +2781 "start": False, +2782 "start_side": False, +2783 "end": False, +2784 "end_side": False, +2785 } 2786 -2787class DataType(Expression): -2788 arg_types = { -2789 "this": True, -2790 "expressions": False, -2791 "nested": False, -2792 "values": False, -2793 "prefix": False, -2794 } -2795 -2796 class Type(AutoName): -2797 CHAR = auto() -2798 NCHAR = auto() -2799 VARCHAR = auto() -2800 NVARCHAR = auto() -2801 TEXT = auto() -2802 MEDIUMTEXT = auto() -2803 LONGTEXT = auto() -2804 MEDIUMBLOB = auto() -2805 LONGBLOB = auto() -2806 BINARY = auto() -2807 VARBINARY = auto() -2808 INT = auto() -2809 UINT = auto() -2810 TINYINT = auto() -2811 UTINYINT = auto() -2812 SMALLINT = auto() -2813 USMALLINT = auto() -2814 BIGINT = auto() -2815 UBIGINT = auto() -2816 FLOAT = auto() -2817 DOUBLE = auto() -2818 DECIMAL = auto() -2819 BIT = auto() -2820 BOOLEAN = auto() -2821 JSON = auto() -2822 JSONB = auto() -2823 INTERVAL = auto() -2824 TIME = auto() -2825 TIMESTAMP = auto() -2826 TIMESTAMPTZ = auto() -2827 TIMESTAMPLTZ = auto() -2828 DATE = auto() -2829 DATETIME = auto() -2830 ARRAY = auto() -2831 MAP = auto() -2832 UUID = auto() -2833 GEOGRAPHY = auto() -2834 GEOMETRY = auto() -2835 STRUCT = auto() -2836 NULLABLE = auto() -2837 HLLSKETCH = auto() -2838 HSTORE = auto() -2839 SUPER = auto() -2840 SERIAL = auto() -2841 SMALLSERIAL = auto() -2842 BIGSERIAL = auto() -2843 XML = auto() -2844 UNIQUEIDENTIFIER = auto() -2845 MONEY = auto() -2846 SMALLMONEY = auto() -2847 ROWVERSION = auto() -2848 IMAGE = auto() -2849 VARIANT = auto() -2850 OBJECT = auto() -2851 INET = auto() -2852 NULL = auto() -2853 UNKNOWN = auto() # Sentinel value, useful for type annotation -2854 -2855 TEXT_TYPES = { -2856 Type.CHAR, -2857 Type.NCHAR, -2858 Type.VARCHAR, -2859 Type.NVARCHAR, -2860 Type.TEXT, -2861 } -2862 -2863 INTEGER_TYPES = { -2864 Type.INT, -2865 Type.TINYINT, -2866 Type.SMALLINT, -2867 Type.BIGINT, -2868 } -2869 -2870 FLOAT_TYPES = { -2871 Type.FLOAT, -2872 Type.DOUBLE, -2873 } -2874 -2875 NUMERIC_TYPES = {*INTEGER_TYPES, *FLOAT_TYPES} -2876 -2877 TEMPORAL_TYPES = { -2878 Type.TIMESTAMP, -2879 Type.TIMESTAMPTZ, -2880 Type.TIMESTAMPLTZ, -2881 Type.DATE, -2882 Type.DATETIME, -2883 } -2884 -2885 @classmethod -2886 def build( -2887 cls, dtype: str | DataType | DataType.Type, dialect: DialectType = None, **kwargs -2888 ) -> DataType: -2889 from sqlglot import parse_one -2890 -2891 if isinstance(dtype, str): -2892 if dtype.upper() in cls.Type.__members__: -2893 data_type_exp: t.Optional[Expression] = DataType(this=DataType.Type[dtype.upper()]) -2894 else: -2895 data_type_exp = parse_one(dtype, read=dialect, into=DataType) -2896 if data_type_exp is None: -2897 raise ValueError(f"Unparsable data type value: {dtype}") -2898 elif isinstance(dtype, DataType.Type): -2899 data_type_exp = DataType(this=dtype) -2900 elif isinstance(dtype, DataType): -2901 return dtype -2902 else: -2903 raise ValueError(f"Invalid data type: {type(dtype)}. Expected str or DataType.Type") -2904 return DataType(**{**data_type_exp.args, **kwargs}) -2905 -2906 def is_type(self, dtype: DataType.Type) -> bool: -2907 return self.this == dtype -2908 -2909 -2910# https://www.postgresql.org/docs/15/datatype-pseudo.html -2911class PseudoType(Expression): -2912 pass -2913 -2914 -2915class StructKwarg(Expression): -2916 arg_types = {"this": True, "expression": True} -2917 +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 +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 } +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} 2918 -2919# WHERE x <OP> EXISTS|ALL|ANY|SOME(SELECT ...) -2920class SubqueryPredicate(Predicate): -2921 pass -2922 -2923 -2924class All(SubqueryPredicate): -2925 pass +2919 TEMPORAL_TYPES = { +2920 Type.TIMESTAMP, +2921 Type.TIMESTAMPTZ, +2922 Type.TIMESTAMPLTZ, +2923 Type.DATE, +2924 Type.DATETIME, +2925 } 2926 -2927 -2928class Any(SubqueryPredicate): -2929 pass -2930 -2931 -2932class Exists(SubqueryPredicate): -2933 pass -2934 -2935 -2936# Commands to interact with the databases or engines. For most of the command -2937# expressions we parse whatever comes after the command's name as a string. -2938class Command(Expression): -2939 arg_types = {"this": True, "expression": False} -2940 -2941 -2942class Transaction(Expression): -2943 arg_types = {"this": False, "modes": False} -2944 -2945 -2946class Commit(Expression): -2947 arg_types = {"chain": False} -2948 -2949 -2950class Rollback(Expression): -2951 arg_types = {"savepoint": False} -2952 -2953 -2954class AlterTable(Expression): -2955 arg_types = {"this": True, "actions": True, "exists": False} +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 +2950 +2951 +2952# https://www.postgresql.org/docs/15/datatype-pseudo.html +2953class PseudoType(Expression): +2954 pass +2955 2956 -2957 -2958class AddConstraint(Expression): -2959 arg_types = {"this": False, "expression": False, "enforced": False} +2957class StructKwarg(Expression): +2958 arg_types = {"this": True, "expression": True} +2959 2960 -2961 -2962class DropPartition(Expression): -2963 arg_types = {"expressions": True, "exists": False} +2961# WHERE x <OP> EXISTS|ALL|ANY|SOME(SELECT ...) +2962class SubqueryPredicate(Predicate): +2963 pass 2964 2965 -2966# Binary expressions like (ADD a b) -2967class Binary(Expression): -2968 arg_types = {"this": True, "expression": True} +2966class All(SubqueryPredicate): +2967 pass +2968 2969 -2970 @property -2971 def left(self): -2972 return self.this +2970class Any(SubqueryPredicate): +2971 pass +2972 2973 -2974 @property -2975 def right(self): -2976 return self.expression +2974class Exists(SubqueryPredicate): +2975 pass +2976 2977 -2978 -2979class Add(Binary): -2980 pass -2981 +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 -2983class Connector(Binary, Condition): -2984 pass -2985 +2983 +2984class Transaction(Expression): +2985 arg_types = {"this": False, "modes": False} 2986 -2987class And(Connector): -2988 pass -2989 +2987 +2988class Commit(Expression): +2989 arg_types = {"chain": False} 2990 -2991class Or(Connector): -2992 pass -2993 +2991 +2992class Rollback(Expression): +2993 arg_types = {"savepoint": False} 2994 -2995class BitwiseAnd(Binary): -2996 pass -2997 +2995 +2996class AlterTable(Expression): +2997 arg_types = {"this": True, "actions": True, "exists": False} 2998 -2999class BitwiseLeftShift(Binary): -3000 pass -3001 +2999 +3000class AddConstraint(Expression): +3001 arg_types = {"this": False, "expression": False, "enforced": False} 3002 -3003class BitwiseOr(Binary): -3004 pass -3005 +3003 +3004class DropPartition(Expression): +3005 arg_types = {"expressions": True, "exists": False} 3006 -3007class BitwiseRightShift(Binary): -3008 pass -3009 -3010 -3011class BitwiseXor(Binary): -3012 pass -3013 -3014 -3015class Div(Binary): -3016 pass -3017 -3018 -3019class Overlaps(Binary): -3020 pass -3021 -3022 -3023class Dot(Binary): -3024 @property -3025 def name(self) -> str: -3026 return self.expression.name +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 +3023 +3024 +3025class Connector(Binary, Condition): +3026 pass 3027 -3028 @classmethod -3029 def build(self, expressions: t.Sequence[Expression]) -> Dot: -3030 """Build a Dot object with a sequence of expressions.""" -3031 if len(expressions) < 2: -3032 raise ValueError(f"Dot requires >= 2 expressions.") -3033 -3034 a, b, *expressions = expressions -3035 dot = Dot(this=a, expression=b) +3028 +3029class And(Connector): +3030 pass +3031 +3032 +3033class Or(Connector): +3034 pass +3035 3036 -3037 for expression in expressions: -3038 dot = Dot(this=dot, expression=expression) +3037class BitwiseAnd(Binary): +3038 pass 3039 -3040 return dot -3041 -3042 -3043class DPipe(Binary): -3044 pass -3045 -3046 -3047class EQ(Binary, Predicate): -3048 pass -3049 -3050 -3051class NullSafeEQ(Binary, Predicate): -3052 pass -3053 -3054 -3055class NullSafeNEQ(Binary, Predicate): -3056 pass -3057 -3058 -3059class Distance(Binary): -3060 pass -3061 -3062 -3063class Escape(Binary): -3064 pass -3065 -3066 -3067class Glob(Binary, Predicate): -3068 pass +3040 +3041class BitwiseLeftShift(Binary): +3042 pass +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 +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 -3071class GT(Binary, Predicate): -3072 pass -3073 -3074 -3075class GTE(Binary, Predicate): -3076 pass -3077 +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) 3078 -3079class ILike(Binary, Predicate): -3080 pass +3079 for expression in expressions: +3080 dot = Dot(this=dot, expression=expression) 3081 -3082 -3083class ILikeAny(Binary, Predicate): -3084 pass -3085 -3086 -3087class IntDiv(Binary): -3088 pass -3089 -3090 -3091class Is(Binary, Predicate): -3092 pass -3093 -3094 -3095class Kwarg(Binary): -3096 """Kwarg in special functions like func(kwarg => y).""" -3097 -3098 -3099class Like(Binary, Predicate): -3100 pass -3101 -3102 -3103class LikeAny(Binary, Predicate): -3104 pass -3105 -3106 -3107class LT(Binary, Predicate): -3108 pass -3109 -3110 -3111class LTE(Binary, Predicate): -3112 pass -3113 -3114 -3115class Mod(Binary): -3116 pass -3117 -3118 -3119class Mul(Binary): -3120 pass -3121 -3122 -3123class NEQ(Binary, Predicate): -3124 pass -3125 -3126 -3127class SimilarTo(Binary, Predicate): -3128 pass -3129 -3130 -3131class Slice(Binary): -3132 arg_types = {"this": False, "expression": False} -3133 -3134 -3135class Sub(Binary): -3136 pass -3137 -3138 -3139class ArrayOverlaps(Binary): -3140 pass -3141 -3142 -3143# Unary Expressions -3144# (NOT a) -3145class Unary(Expression): +3082 return dot +3083 +3084 +3085class DPipe(Binary): +3086 pass +3087 +3088 +3089class EQ(Binary, Predicate): +3090 pass +3091 +3092 +3093class NullSafeEQ(Binary, Predicate): +3094 pass +3095 +3096 +3097class NullSafeNEQ(Binary, Predicate): +3098 pass +3099 +3100 +3101class Distance(Binary): +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 3147 3148 -3149class BitwiseNot(Unary): +3149class LT(Binary, Predicate): 3150 pass 3151 3152 -3153class Not(Unary, Condition): +3153class LTE(Binary, Predicate): 3154 pass 3155 3156 -3157class Paren(Unary, Condition): -3158 arg_types = {"this": True, "with": False} +3157class Mod(Binary): +3158 pass 3159 3160 -3161class Neg(Unary): +3161class Mul(Binary): 3162 pass 3163 3164 -3165# Special Functions -3166class Alias(Expression): -3167 arg_types = {"this": True, "alias": False} +3165class NEQ(Binary, Predicate): +3166 pass +3167 3168 -3169 @property -3170 def output_name(self): -3171 return self.alias +3169class SimilarTo(Binary, Predicate): +3170 pass +3171 3172 -3173 -3174class Aliases(Expression): -3175 arg_types = {"this": True, "expressions": True} +3173class Slice(Binary): +3174 arg_types = {"this": False, "expression": False} +3175 3176 -3177 @property -3178 def aliases(self): -3179 return self.expressions +3177class Sub(Binary): +3178 pass +3179 3180 -3181 -3182class AtTimeZone(Expression): -3183 arg_types = {"this": True, "zone": True} +3181class ArrayOverlaps(Binary): +3182 pass +3183 3184 -3185 -3186class Between(Predicate): -3187 arg_types = {"this": True, "low": True, "high": True} -3188 +3185# Unary Expressions +3186# (NOT a) +3187class Unary(Expression): +3188 pass 3189 -3190class Bracket(Condition): -3191 arg_types = {"this": True, "expressions": True} -3192 +3190 +3191class BitwiseNot(Unary): +3192 pass 3193 -3194class Distinct(Expression): -3195 arg_types = {"expressions": False, "on": False} -3196 +3194 +3195class Not(Unary, Condition): +3196 pass 3197 -3198class In(Predicate): -3199 arg_types = { -3200 "this": True, -3201 "expressions": False, -3202 "query": False, -3203 "unnest": False, -3204 "field": False, -3205 "is_global": False, -3206 } -3207 -3208 -3209class TimeUnit(Expression): -3210 """Automatically converts unit arg into a var.""" -3211 -3212 arg_types = {"unit": False} +3198 +3199class Paren(Unary, Condition): +3200 arg_types = {"this": True, "with": False} +3201 +3202 +3203class Neg(Unary): +3204 pass +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 -3214 def __init__(self, **args): -3215 unit = args.get("unit") -3216 if isinstance(unit, (Column, Literal)): -3217 args["unit"] = Var(this=unit.name) -3218 elif isinstance(unit, Week): -3219 unit.set("this", Var(this=unit.this.name)) -3220 super().__init__(**args) +3214 +3215class Aliases(Expression): +3216 arg_types = {"this": True, "expressions": True} +3217 +3218 @property +3219 def aliases(self): +3220 return self.expressions 3221 3222 -3223class Interval(TimeUnit): -3224 arg_types = {"this": False, "unit": False} +3223class AtTimeZone(Expression): +3224 arg_types = {"this": True, "zone": True} 3225 3226 -3227class IgnoreNulls(Expression): -3228 pass +3227class Between(Predicate): +3228 arg_types = {"this": True, "low": True, "high": True} 3229 3230 -3231class RespectNulls(Expression): -3232 pass +3231class Bracket(Condition): +3232 arg_types = {"this": True, "expressions": True} 3233 3234 -3235# Functions -3236class Func(Condition): -3237 """ -3238 The base class for all function expressions. -3239 -3240 Attributes: -3241 is_var_len_args (bool): if set to True the last argument defined in arg_types will be -3242 treated as a variable length argument and the argument's value will be stored as a list. -3243 _sql_names (list): determines the SQL name (1st item in the list) and aliases (subsequent items) -3244 for this function expression. These values are used to map this node to a name during parsing -3245 as well as to provide the function's name during SQL string generation. By default the SQL -3246 name is set to the expression's class name transformed to snake case. -3247 """ +3235class Distinct(Expression): +3236 arg_types = {"expressions": False, "on": False} +3237 +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 is_var_len_args = False -3250 -3251 @classmethod -3252 def from_arg_list(cls, args): -3253 if cls.is_var_len_args: -3254 all_arg_keys = list(cls.arg_types) -3255 # If this function supports variable length argument treat the last argument as such. -3256 non_var_len_arg_keys = all_arg_keys[:-1] if cls.is_var_len_args else all_arg_keys -3257 num_non_var = len(non_var_len_arg_keys) -3258 -3259 args_dict = {arg_key: arg for arg, arg_key in zip(args, non_var_len_arg_keys)} -3260 args_dict[all_arg_keys[-1]] = args[num_non_var:] -3261 else: -3262 args_dict = {arg_key: arg for arg, arg_key in zip(args, cls.arg_types)} +3249 +3250class TimeUnit(Expression): +3251 """Automatically converts unit arg into a var.""" +3252 +3253 arg_types = {"unit": False} +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) +3262 3263 -3264 return cls(**args_dict) -3265 -3266 @classmethod -3267 def sql_names(cls): -3268 if cls is Func: -3269 raise NotImplementedError( -3270 "SQL name is only supported by concrete function implementations" -3271 ) -3272 if "_sql_names" not in cls.__dict__: -3273 cls._sql_names = [camel_to_snake_case(cls.__name__)] -3274 return cls._sql_names +3264class Interval(TimeUnit): +3265 arg_types = {"this": False, "unit": False} +3266 +3267 +3268class IgnoreNulls(Expression): +3269 pass +3270 +3271 +3272class RespectNulls(Expression): +3273 pass +3274 3275 -3276 @classmethod -3277 def sql_name(cls): -3278 return cls.sql_names()[0] -3279 -3280 @classmethod -3281 def default_parser_mappings(cls): -3282 return {name: cls.from_arg_list for name in cls.sql_names()} -3283 -3284 -3285class AggFunc(Func): -3286 pass -3287 -3288 -3289class Abs(Func): -3290 pass +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 3291 -3292 -3293class Anonymous(Func): -3294 arg_types = {"this": True, "expressions": False} -3295 is_var_len_args = True -3296 -3297 -3298# https://docs.snowflake.com/en/sql-reference/functions/hll -3299# https://docs.aws.amazon.com/redshift/latest/dg/r_HLL_function.html -3300class Hll(AggFunc): -3301 arg_types = {"this": True, "expressions": False} -3302 is_var_len_args = True -3303 +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) +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 -3305class ApproxDistinct(AggFunc): -3306 arg_types = {"this": True, "accuracy": False} -3307 -3308 -3309class Array(Func): -3310 arg_types = {"expressions": False} -3311 is_var_len_args = True -3312 -3313 -3314# https://docs.snowflake.com/en/sql-reference/functions/to_char -3315class ToChar(Func): -3316 arg_types = {"this": True, "format": False} -3317 -3318 -3319class GenerateSeries(Func): -3320 arg_types = {"start": True, "end": True, "step": False} -3321 -3322 -3323class ArrayAgg(AggFunc): -3324 pass +3305 return cls(**args_dict) +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 +3316 +3317 @classmethod +3318 def sql_name(cls): +3319 return cls.sql_names()[0] +3320 +3321 @classmethod +3322 def default_parser_mappings(cls): +3323 return {name: cls.from_arg_list for name in cls.sql_names()} +3324 3325 -3326 -3327class ArrayAll(Func): -3328 arg_types = {"this": True, "expression": True} +3326class AggFunc(Func): +3327 pass +3328 3329 -3330 -3331class ArrayAny(Func): -3332 arg_types = {"this": True, "expression": True} +3330class Abs(Func): +3331 pass +3332 3333 -3334 -3335class ArrayConcat(Func): -3336 arg_types = {"this": True, "expressions": False} -3337 is_var_len_args = True +3334class Anonymous(Func): +3335 arg_types = {"this": True, "expressions": False} +3336 is_var_len_args = True +3337 3338 -3339 -3340class ArrayContains(Binary, Func): -3341 pass -3342 -3343 -3344class ArrayContained(Binary): -3345 pass -3346 -3347 -3348class ArrayFilter(Func): -3349 arg_types = {"this": True, "expression": True} -3350 _sql_names = ["FILTER", "ARRAY_FILTER"] -3351 -3352 -3353class ArrayJoin(Func): -3354 arg_types = {"this": True, "expression": True, "null": False} -3355 -3356 -3357class ArraySize(Func): -3358 arg_types = {"this": True, "expression": False} +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 +3344 +3345 +3346class ApproxDistinct(AggFunc): +3347 arg_types = {"this": True, "accuracy": False} +3348 +3349 +3350class Array(Func): +3351 arg_types = {"expressions": False} +3352 is_var_len_args = True +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 -3360 -3361class ArraySort(Func): -3362 arg_types = {"this": True, "expression": False} +3360class GenerateSeries(Func): +3361 arg_types = {"start": True, "end": True, "step": False} +3362 3363 -3364 -3365class ArraySum(Func): -3366 pass +3364class ArrayAgg(AggFunc): +3365 pass +3366 3367 -3368 -3369class ArrayUnionAgg(AggFunc): -3370 pass +3368class ArrayAll(Func): +3369 arg_types = {"this": True, "expression": True} +3370 3371 -3372 -3373class Avg(AggFunc): -3374 pass +3372class ArrayAny(Func): +3373 arg_types = {"this": True, "expression": True} +3374 3375 -3376 -3377class AnyValue(AggFunc): -3378 pass +3376class ArrayConcat(Func): +3377 arg_types = {"this": True, "expressions": False} +3378 is_var_len_args = True 3379 3380 -3381class Case(Func): -3382 arg_types = {"this": False, "ifs": True, "default": False} +3381class ArrayContains(Binary, Func): +3382 pass 3383 3384 -3385class Cast(Func): -3386 arg_types = {"this": True, "to": True} +3385class ArrayContained(Binary): +3386 pass 3387 -3388 @property -3389 def name(self) -> str: -3390 return self.this.name -3391 -3392 @property -3393 def to(self): -3394 return self.args["to"] -3395 -3396 @property -3397 def output_name(self): -3398 return self.name -3399 -3400 def is_type(self, dtype: DataType.Type) -> bool: -3401 return self.to.is_type(dtype) -3402 -3403 -3404class Collate(Binary): -3405 pass -3406 -3407 -3408class TryCast(Cast): -3409 pass -3410 -3411 -3412class Ceil(Func): -3413 arg_types = {"this": True, "decimals": False} -3414 _sql_names = ["CEIL", "CEILING"] -3415 +3388 +3389class ArrayFilter(Func): +3390 arg_types = {"this": True, "expression": True} +3391 _sql_names = ["FILTER", "ARRAY_FILTER"] +3392 +3393 +3394class ArrayJoin(Func): +3395 arg_types = {"this": True, "expression": True, "null": False} +3396 +3397 +3398class ArraySize(Func): +3399 arg_types = {"this": True, "expression": False} +3400 +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 3416 -3417class Coalesce(Func): -3418 arg_types = {"this": True, "expressions": False} -3419 is_var_len_args = True +3417 +3418class AnyValue(AggFunc): +3419 pass 3420 3421 -3422class Concat(Func): -3423 arg_types = {"expressions": True} -3424 is_var_len_args = True +3422class Case(Func): +3423 arg_types = {"this": False, "ifs": True, "default": False} +3424 3425 -3426 -3427class ConcatWs(Concat): -3428 _sql_names = ["CONCAT_WS"] -3429 -3430 -3431class Count(AggFunc): -3432 arg_types = {"this": False} -3433 -3434 -3435class CountIf(AggFunc): -3436 pass -3437 -3438 -3439class CurrentDate(Func): -3440 arg_types = {"this": False} -3441 -3442 -3443class CurrentDatetime(Func): -3444 arg_types = {"this": False} -3445 -3446 -3447class CurrentTime(Func): -3448 arg_types = {"this": False} -3449 -3450 -3451class CurrentTimestamp(Func): -3452 arg_types = {"this": False} -3453 -3454 -3455class DateAdd(Func, TimeUnit): -3456 arg_types = {"this": True, "expression": True, "unit": False} +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) +3443 +3444 +3445class Collate(Binary): +3446 pass +3447 +3448 +3449class TryCast(Cast): +3450 pass +3451 +3452 +3453class Ceil(Func): +3454 arg_types = {"this": True, "decimals": False} +3455 _sql_names = ["CEIL", "CEILING"] +3456 3457 -3458 -3459class DateSub(Func, TimeUnit): -3460 arg_types = {"this": True, "expression": True, "unit": False} +3458class Coalesce(Func): +3459 arg_types = {"this": True, "expressions": False} +3460 is_var_len_args = True 3461 3462 -3463class DateDiff(Func, TimeUnit): -3464 _sql_names = ["DATEDIFF", "DATE_DIFF"] -3465 arg_types = {"this": True, "expression": True, "unit": False} +3463class Concat(Func): +3464 arg_types = {"expressions": True} +3465 is_var_len_args = True 3466 3467 -3468class DateTrunc(Func): -3469 arg_types = {"unit": True, "this": True, "zone": False} +3468class ConcatWs(Concat): +3469 _sql_names = ["CONCAT_WS"] 3470 3471 -3472class DatetimeAdd(Func, TimeUnit): -3473 arg_types = {"this": True, "expression": True, "unit": False} +3472class Count(AggFunc): +3473 arg_types = {"this": False} 3474 3475 -3476class DatetimeSub(Func, TimeUnit): -3477 arg_types = {"this": True, "expression": True, "unit": False} +3476class CountIf(AggFunc): +3477 pass 3478 3479 -3480class DatetimeDiff(Func, TimeUnit): -3481 arg_types = {"this": True, "expression": True, "unit": False} +3480class CurrentDate(Func): +3481 arg_types = {"this": False} 3482 3483 -3484class DatetimeTrunc(Func, TimeUnit): -3485 arg_types = {"this": True, "unit": True, "zone": False} +3484class CurrentDatetime(Func): +3485 arg_types = {"this": False} 3486 3487 -3488class DayOfWeek(Func): -3489 _sql_names = ["DAY_OF_WEEK", "DAYOFWEEK"] +3488class CurrentTime(Func): +3489 arg_types = {"this": False} 3490 3491 -3492class DayOfMonth(Func): -3493 _sql_names = ["DAY_OF_MONTH", "DAYOFMONTH"] +3492class CurrentTimestamp(Func): +3493 arg_types = {"this": False} 3494 3495 -3496class DayOfYear(Func): -3497 _sql_names = ["DAY_OF_YEAR", "DAYOFYEAR"] +3496class CurrentUser(Func): +3497 arg_types = {"this": False} 3498 3499 -3500class WeekOfYear(Func): -3501 _sql_names = ["WEEK_OF_YEAR", "WEEKOFYEAR"] +3500class DateAdd(Func, TimeUnit): +3501 arg_types = {"this": True, "expression": True, "unit": False} 3502 3503 -3504class LastDateOfMonth(Func): -3505 pass +3504class DateSub(Func, TimeUnit): +3505 arg_types = {"this": True, "expression": True, "unit": False} 3506 3507 -3508class Extract(Func): -3509 arg_types = {"this": True, "expression": True} -3510 +3508class DateDiff(Func, TimeUnit): +3509 _sql_names = ["DATEDIFF", "DATE_DIFF"] +3510 arg_types = {"this": True, "expression": True, "unit": False} 3511 -3512class TimestampAdd(Func, TimeUnit): -3513 arg_types = {"this": True, "expression": True, "unit": False} -3514 +3512 +3513class DateTrunc(Func): +3514 arg_types = {"unit": True, "this": True, "zone": False} 3515 -3516class TimestampSub(Func, TimeUnit): -3517 arg_types = {"this": True, "expression": True, "unit": False} -3518 +3516 +3517class DatetimeAdd(Func, TimeUnit): +3518 arg_types = {"this": True, "expression": True, "unit": False} 3519 -3520class TimestampDiff(Func, TimeUnit): -3521 arg_types = {"this": True, "expression": True, "unit": False} -3522 +3520 +3521class DatetimeSub(Func, TimeUnit): +3522 arg_types = {"this": True, "expression": True, "unit": False} 3523 -3524class TimestampTrunc(Func, TimeUnit): -3525 arg_types = {"this": True, "unit": True, "zone": False} -3526 +3524 +3525class DatetimeDiff(Func, TimeUnit): +3526 arg_types = {"this": True, "expression": True, "unit": False} 3527 -3528class TimeAdd(Func, TimeUnit): -3529 arg_types = {"this": True, "expression": True, "unit": False} -3530 +3528 +3529class DatetimeTrunc(Func, TimeUnit): +3530 arg_types = {"this": True, "unit": True, "zone": False} 3531 -3532class TimeSub(Func, TimeUnit): -3533 arg_types = {"this": True, "expression": True, "unit": False} -3534 +3532 +3533class DayOfWeek(Func): +3534 _sql_names = ["DAY_OF_WEEK", "DAYOFWEEK"] 3535 -3536class TimeDiff(Func, TimeUnit): -3537 arg_types = {"this": True, "expression": True, "unit": False} -3538 +3536 +3537class DayOfMonth(Func): +3538 _sql_names = ["DAY_OF_MONTH", "DAYOFMONTH"] 3539 -3540class TimeTrunc(Func, TimeUnit): -3541 arg_types = {"this": True, "unit": True, "zone": False} -3542 +3540 +3541class DayOfYear(Func): +3542 _sql_names = ["DAY_OF_YEAR", "DAYOFYEAR"] 3543 -3544class DateFromParts(Func): -3545 _sql_names = ["DATEFROMPARTS"] -3546 arg_types = {"year": True, "month": True, "day": True} +3544 +3545class WeekOfYear(Func): +3546 _sql_names = ["WEEK_OF_YEAR", "WEEKOFYEAR"] 3547 3548 -3549class DateStrToDate(Func): +3549class LastDateOfMonth(Func): 3550 pass 3551 3552 -3553class DateToDateStr(Func): -3554 pass +3553class Extract(Func): +3554 arg_types = {"this": True, "expression": True} 3555 3556 -3557class DateToDi(Func): -3558 pass +3557class TimestampAdd(Func, TimeUnit): +3558 arg_types = {"this": True, "expression": True, "unit": False} 3559 3560 -3561class Day(Func): -3562 pass +3561class TimestampSub(Func, TimeUnit): +3562 arg_types = {"this": True, "expression": True, "unit": False} 3563 3564 -3565class Decode(Func): -3566 arg_types = {"this": True, "charset": True, "replace": False} +3565class TimestampDiff(Func, TimeUnit): +3566 arg_types = {"this": True, "expression": True, "unit": False} 3567 3568 -3569class DiToDate(Func): -3570 pass +3569class TimestampTrunc(Func, TimeUnit): +3570 arg_types = {"this": True, "unit": True, "zone": False} 3571 3572 -3573class Encode(Func): -3574 arg_types = {"this": True, "charset": True} +3573class TimeAdd(Func, TimeUnit): +3574 arg_types = {"this": True, "expression": True, "unit": False} 3575 3576 -3577class Exp(Func): -3578 pass +3577class TimeSub(Func, TimeUnit): +3578 arg_types = {"this": True, "expression": True, "unit": False} 3579 3580 -3581class Explode(Func): -3582 pass +3581class TimeDiff(Func, TimeUnit): +3582 arg_types = {"this": True, "expression": True, "unit": False} 3583 3584 -3585class ExponentialTimeDecayedAvg(AggFunc): -3586 arg_types = {"this": True, "time": False, "decay": False} +3585class TimeTrunc(Func, TimeUnit): +3586 arg_types = {"this": True, "unit": True, "zone": False} 3587 3588 -3589class Floor(Func): -3590 arg_types = {"this": True, "decimals": False} -3591 +3589class DateFromParts(Func): +3590 _sql_names = ["DATEFROMPARTS"] +3591 arg_types = {"year": True, "month": True, "day": True} 3592 -3593class Greatest(Func): -3594 arg_types = {"this": True, "expressions": False} -3595 is_var_len_args = True +3593 +3594class DateStrToDate(Func): +3595 pass 3596 3597 -3598class GroupConcat(Func): -3599 arg_types = {"this": True, "separator": False} +3598class DateToDateStr(Func): +3599 pass 3600 3601 -3602class GroupUniqArray(AggFunc): -3603 arg_types = {"this": True, "size": False} +3602class DateToDi(Func): +3603 pass 3604 3605 -3606class Hex(Func): +3606class Day(Func): 3607 pass 3608 3609 -3610class Histogram(AggFunc): -3611 arg_types = {"this": True, "bins": False} +3610class Decode(Func): +3611 arg_types = {"this": True, "charset": True, "replace": False} 3612 3613 -3614class If(Func): -3615 arg_types = {"this": True, "true": True, "false": False} +3614class DiToDate(Func): +3615 pass 3616 3617 -3618class IfNull(Func): -3619 arg_types = {"this": True, "expression": False} -3620 _sql_names = ["IFNULL", "NVL"] +3618class Encode(Func): +3619 arg_types = {"this": True, "charset": True} +3620 3621 -3622 -3623class Initcap(Func): -3624 pass +3622class Exp(Func): +3623 pass +3624 3625 -3626 -3627class JSONKeyValue(Expression): -3628 arg_types = {"this": True, "expression": True} +3626class Explode(Func): +3627 pass +3628 3629 -3630 -3631class JSONObject(Func): -3632 arg_types = { -3633 "expressions": False, -3634 "null_handling": False, -3635 "unique_keys": False, -3636 "return_type": False, -3637 "format_json": False, -3638 "encoding": False, -3639 } -3640 +3630class ExponentialTimeDecayedAvg(AggFunc): +3631 arg_types = {"this": True, "time": False, "decay": False} +3632 +3633 +3634class Floor(Func): +3635 arg_types = {"this": True, "decimals": False} +3636 +3637 +3638class Greatest(Func): +3639 arg_types = {"this": True, "expressions": False} +3640 is_var_len_args = True 3641 -3642class JSONBContains(Binary): -3643 _sql_names = ["JSONB_CONTAINS"] -3644 +3642 +3643class GroupConcat(Func): +3644 arg_types = {"this": True, "separator": False} 3645 -3646class JSONExtract(Binary, Func): -3647 _sql_names = ["JSON_EXTRACT"] -3648 +3646 +3647class GroupUniqArray(AggFunc): +3648 arg_types = {"this": True, "size": False} 3649 -3650class JSONExtractScalar(JSONExtract): -3651 _sql_names = ["JSON_EXTRACT_SCALAR"] -3652 +3650 +3651class Hex(Func): +3652 pass 3653 -3654class JSONBExtract(JSONExtract): -3655 _sql_names = ["JSONB_EXTRACT"] -3656 +3654 +3655class Histogram(AggFunc): +3656 arg_types = {"this": True, "bins": False} 3657 -3658class JSONBExtractScalar(JSONExtract): -3659 _sql_names = ["JSONB_EXTRACT_SCALAR"] -3660 +3658 +3659class If(Func): +3660 arg_types = {"this": True, "true": True, "false": False} 3661 -3662class JSONFormat(Func): -3663 arg_types = {"this": False, "options": False} -3664 _sql_names = ["JSON_FORMAT"] -3665 +3662 +3663class IfNull(Func): +3664 arg_types = {"this": True, "expression": False} +3665 _sql_names = ["IFNULL", "NVL"] 3666 -3667class Least(Func): -3668 arg_types = {"expressions": False} -3669 is_var_len_args = True +3667 +3668class Initcap(Func): +3669 pass 3670 3671 -3672class Length(Func): -3673 pass +3672class JSONKeyValue(Expression): +3673 arg_types = {"this": True, "expression": True} 3674 3675 -3676class Levenshtein(Func): +3676class JSONObject(Func): 3677 arg_types = { -3678 "this": True, -3679 "expression": False, -3680 "ins_cost": False, -3681 "del_cost": False, -3682 "sub_cost": False, -3683 } -3684 +3678 "expressions": False, +3679 "null_handling": False, +3680 "unique_keys": False, +3681 "return_type": False, +3682 "format_json": False, +3683 "encoding": False, +3684 } 3685 -3686class Ln(Func): -3687 pass -3688 +3686 +3687class JSONBContains(Binary): +3688 _sql_names = ["JSONB_CONTAINS"] 3689 -3690class Log(Func): -3691 arg_types = {"this": True, "expression": False} -3692 +3690 +3691class JSONExtract(Binary, Func): +3692 _sql_names = ["JSON_EXTRACT"] 3693 -3694class Log2(Func): -3695 pass -3696 +3694 +3695class JSONExtractScalar(JSONExtract): +3696 _sql_names = ["JSON_EXTRACT_SCALAR"] 3697 -3698class Log10(Func): -3699 pass -3700 +3698 +3699class JSONBExtract(JSONExtract): +3700 _sql_names = ["JSONB_EXTRACT"] 3701 -3702class LogicalOr(AggFunc): -3703 _sql_names = ["LOGICAL_OR", "BOOL_OR", "BOOLOR_AGG"] -3704 +3702 +3703class JSONBExtractScalar(JSONExtract): +3704 _sql_names = ["JSONB_EXTRACT_SCALAR"] 3705 -3706class LogicalAnd(AggFunc): -3707 _sql_names = ["LOGICAL_AND", "BOOL_AND", "BOOLAND_AGG"] -3708 -3709 -3710class Lower(Func): -3711 _sql_names = ["LOWER", "LCASE"] -3712 -3713 -3714class Map(Func): -3715 arg_types = {"keys": False, "values": False} +3706 +3707class JSONFormat(Func): +3708 arg_types = {"this": False, "options": False} +3709 _sql_names = ["JSON_FORMAT"] +3710 +3711 +3712class Least(Func): +3713 arg_types = {"expressions": False} +3714 is_var_len_args = True +3715 3716 -3717 -3718class VarMap(Func): -3719 arg_types = {"keys": True, "values": True} -3720 is_var_len_args = True -3721 -3722 -3723# https://dev.mysql.com/doc/refman/8.0/en/fulltext-search.html -3724class MatchAgainst(Func): -3725 arg_types = {"this": True, "expressions": True, "modifier": False} -3726 -3727 -3728class Max(AggFunc): -3729 arg_types = {"this": True, "expressions": False} -3730 is_var_len_args = True -3731 -3732 -3733class Min(AggFunc): -3734 arg_types = {"this": True, "expressions": False} -3735 is_var_len_args = True -3736 +3717class Length(Func): +3718 pass +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 +3730 +3731class Ln(Func): +3732 pass +3733 +3734 +3735class Log(Func): +3736 arg_types = {"this": True, "expression": False} 3737 -3738class Month(Func): -3739 pass -3740 +3738 +3739class Log2(Func): +3740 pass 3741 -3742class Nvl2(Func): -3743 arg_types = {"this": True, "true": True, "false": False} -3744 +3742 +3743class Log10(Func): +3744 pass 3745 -3746class Posexplode(Func): -3747 pass -3748 +3746 +3747class LogicalOr(AggFunc): +3748 _sql_names = ["LOGICAL_OR", "BOOL_OR", "BOOLOR_AGG"] 3749 -3750class Pow(Binary, Func): -3751 _sql_names = ["POWER", "POW"] -3752 +3750 +3751class LogicalAnd(AggFunc): +3752 _sql_names = ["LOGICAL_AND", "BOOL_AND", "BOOLAND_AGG"] 3753 -3754class PercentileCont(AggFunc): -3755 pass -3756 +3754 +3755class Lower(Func): +3756 _sql_names = ["LOWER", "LCASE"] 3757 -3758class PercentileDisc(AggFunc): -3759 pass -3760 +3758 +3759class Map(Func): +3760 arg_types = {"keys": False, "values": False} 3761 -3762class Quantile(AggFunc): -3763 arg_types = {"this": True, "quantile": True} -3764 +3762 +3763class StarMap(Func): +3764 pass 3765 -3766# Clickhouse-specific: -3767# https://clickhouse.com/docs/en/sql-reference/aggregate-functions/reference/quantiles/#quantiles -3768class Quantiles(AggFunc): -3769 arg_types = {"parameters": True, "expressions": True} -3770 is_var_len_args = True +3766 +3767class VarMap(Func): +3768 arg_types = {"keys": True, "values": True} +3769 is_var_len_args = True +3770 3771 -3772 -3773class QuantileIf(AggFunc): -3774 arg_types = {"parameters": True, "expressions": True} +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} 3775 3776 -3777class ApproxQuantile(Quantile): -3778 arg_types = {"this": True, "quantile": True, "accuracy": False, "weight": False} -3779 +3777class Max(AggFunc): +3778 arg_types = {"this": True, "expressions": False} +3779 is_var_len_args = True 3780 -3781class RangeN(Func): -3782 arg_types = {"this": True, "expressions": True, "each": False} -3783 +3781 +3782class MD5(Func): +3783 _sql_names = ["MD5"] 3784 -3785class ReadCSV(Func): -3786 _sql_names = ["READ_CSV"] -3787 is_var_len_args = True -3788 arg_types = {"this": True, "expressions": False} +3785 +3786class Min(AggFunc): +3787 arg_types = {"this": True, "expressions": False} +3788 is_var_len_args = True 3789 3790 -3791class Reduce(Func): -3792 arg_types = {"this": True, "initial": True, "merge": True, "finish": False} +3791class Month(Func): +3792 pass 3793 3794 -3795class RegexpExtract(Func): -3796 arg_types = { -3797 "this": True, -3798 "expression": True, -3799 "position": False, -3800 "occurrence": False, -3801 "group": False, -3802 } -3803 -3804 -3805class RegexpLike(Func): -3806 arg_types = {"this": True, "expression": True, "flag": False} -3807 -3808 -3809class RegexpILike(Func): -3810 arg_types = {"this": True, "expression": True, "flag": False} -3811 -3812 -3813# https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.functions.split.html -3814# limit is the number of times a pattern is applied -3815class RegexpSplit(Func): -3816 arg_types = {"this": True, "expression": True, "limit": False} +3795class Nvl2(Func): +3796 arg_types = {"this": True, "true": True, "false": False} +3797 +3798 +3799class Posexplode(Func): +3800 pass +3801 +3802 +3803class Pow(Binary, Func): +3804 _sql_names = ["POWER", "POW"] +3805 +3806 +3807class PercentileCont(AggFunc): +3808 pass +3809 +3810 +3811class PercentileDisc(AggFunc): +3812 pass +3813 +3814 +3815class Quantile(AggFunc): +3816 arg_types = {"this": True, "quantile": True} 3817 3818 -3819class Repeat(Func): -3820 arg_types = {"this": True, "times": True} -3821 -3822 -3823class Round(Func): -3824 arg_types = {"this": True, "decimals": False} +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 -3826 -3827class RowNumber(Func): -3828 arg_types: t.Dict[str, t.Any] = {} +3826class QuantileIf(AggFunc): +3827 arg_types = {"parameters": True, "expressions": True} +3828 3829 -3830 -3831class SafeDivide(Func): -3832 arg_types = {"this": True, "expression": True} +3830class ApproxQuantile(Quantile): +3831 arg_types = {"this": True, "quantile": True, "accuracy": False, "weight": False} +3832 3833 -3834 -3835class SetAgg(AggFunc): -3836 pass +3834class RangeN(Func): +3835 arg_types = {"this": True, "expressions": True, "each": False} +3836 3837 -3838 -3839class SortArray(Func): -3840 arg_types = {"this": True, "asc": False} -3841 +3838class ReadCSV(Func): +3839 _sql_names = ["READ_CSV"] +3840 is_var_len_args = True +3841 arg_types = {"this": True, "expressions": False} 3842 -3843class Split(Func): -3844 arg_types = {"this": True, "expression": True, "limit": False} -3845 +3843 +3844class Reduce(Func): +3845 arg_types = {"this": True, "initial": True, "merge": True, "finish": False} 3846 -3847# Start may be omitted in the case of postgres -3848# https://www.postgresql.org/docs/9.1/functions-string.html @ Table 9-6 -3849class Substring(Func): -3850 arg_types = {"this": True, "start": False, "length": False} -3851 -3852 -3853class StrPosition(Func): -3854 arg_types = { -3855 "this": True, -3856 "substr": True, -3857 "position": False, -3858 "instance": False, -3859 } +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 StrToDate(Func): -3863 arg_types = {"this": True, "format": True} +3862class RegexpILike(Func): +3863 arg_types = {"this": True, "expression": True, "flag": False} 3864 3865 -3866class StrToTime(Func): -3867 arg_types = {"this": True, "format": True} -3868 -3869 -3870# Spark allows unix_timestamp() -3871# https://spark.apache.org/docs/3.1.3/api/python/reference/api/pyspark.sql.functions.unix_timestamp.html -3872class StrToUnix(Func): -3873 arg_types = {"this": False, "format": False} +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 NumberToStr(Func): -3877 arg_types = {"this": True, "format": True} +3876class Round(Func): +3877 arg_types = {"this": True, "decimals": False} 3878 3879 -3880class Struct(Func): -3881 arg_types = {"expressions": True} -3882 is_var_len_args = True +3880class RowNumber(Func): +3881 arg_types: t.Dict[str, t.Any] = {} +3882 3883 -3884 -3885class StructExtract(Func): -3886 arg_types = {"this": True, "expression": True} +3884class SafeDivide(Func): +3885 arg_types = {"this": True, "expression": True} +3886 3887 -3888 -3889class Sum(AggFunc): -3890 pass +3888class SetAgg(AggFunc): +3889 pass +3890 3891 -3892 -3893class Sqrt(Func): -3894 pass +3892class SHA(Func): +3893 _sql_names = ["SHA", "SHA1"] +3894 3895 -3896 -3897class Stddev(AggFunc): -3898 pass +3896class SHA2(Func): +3897 _sql_names = ["SHA2"] +3898 arg_types = {"this": True, "length": False} 3899 3900 -3901class StddevPop(AggFunc): -3902 pass +3901class SortArray(Func): +3902 arg_types = {"this": True, "asc": False} 3903 3904 -3905class StddevSamp(AggFunc): -3906 pass +3905class Split(Func): +3906 arg_types = {"this": True, "expression": True, "limit": False} 3907 3908 -3909class TimeToStr(Func): -3910 arg_types = {"this": True, "format": True} -3911 -3912 -3913class TimeToTimeStr(Func): -3914 pass -3915 -3916 -3917class TimeToUnix(Func): -3918 pass -3919 -3920 -3921class TimeStrToDate(Func): -3922 pass +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} +3913 +3914 +3915class StrPosition(Func): +3916 arg_types = { +3917 "this": True, +3918 "substr": True, +3919 "position": False, +3920 "instance": False, +3921 } +3922 3923 -3924 -3925class TimeStrToTime(Func): -3926 pass +3924class StrToDate(Func): +3925 arg_types = {"this": True, "format": True} +3926 3927 -3928 -3929class TimeStrToUnix(Func): -3930 pass +3928class StrToTime(Func): +3929 arg_types = {"this": True, "format": True} +3930 3931 -3932 -3933class Trim(Func): -3934 arg_types = { -3935 "this": True, -3936 "expression": False, -3937 "position": False, -3938 "collation": False, -3939 } +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} +3936 +3937 +3938class NumberToStr(Func): +3939 arg_types = {"this": True, "format": True} 3940 3941 -3942class TsOrDsAdd(Func, TimeUnit): -3943 arg_types = {"this": True, "expression": True, "unit": False} -3944 +3942class Struct(Func): +3943 arg_types = {"expressions": True} +3944 is_var_len_args = True 3945 -3946class TsOrDsToDateStr(Func): -3947 pass -3948 +3946 +3947class StructExtract(Func): +3948 arg_types = {"this": True, "expression": True} 3949 -3950class TsOrDsToDate(Func): -3951 arg_types = {"this": True, "format": False} -3952 +3950 +3951class Sum(AggFunc): +3952 pass 3953 -3954class TsOrDiToDi(Func): -3955 pass -3956 +3954 +3955class Sqrt(Func): +3956 pass 3957 -3958class Unhex(Func): -3959 pass -3960 +3958 +3959class Stddev(AggFunc): +3960 pass 3961 -3962class UnixToStr(Func): -3963 arg_types = {"this": True, "format": False} -3964 +3962 +3963class StddevPop(AggFunc): +3964 pass 3965 -3966# https://prestodb.io/docs/current/functions/datetime.html -3967# presto has weird zone/hours/minutes -3968class UnixToTime(Func): -3969 arg_types = {"this": True, "scale": False, "zone": False, "hours": False, "minutes": False} +3966 +3967class StddevSamp(AggFunc): +3968 pass +3969 3970 -3971 SECONDS = Literal.string("seconds") -3972 MILLIS = Literal.string("millis") -3973 MICROS = Literal.string("micros") +3971class TimeToStr(Func): +3972 arg_types = {"this": True, "format": True} +3973 3974 -3975 -3976class UnixToTimeStr(Func): -3977 pass +3975class TimeToTimeStr(Func): +3976 pass +3977 3978 -3979 -3980class Upper(Func): -3981 _sql_names = ["UPPER", "UCASE"] +3979class TimeToUnix(Func): +3980 pass +3981 3982 -3983 -3984class Variance(AggFunc): -3985 _sql_names = ["VARIANCE", "VARIANCE_SAMP", "VAR_SAMP"] +3983class TimeStrToDate(Func): +3984 pass +3985 3986 -3987 -3988class VariancePop(AggFunc): -3989 _sql_names = ["VARIANCE_POP", "VAR_POP"] +3987class TimeStrToTime(Func): +3988 pass +3989 3990 -3991 -3992class Week(Func): -3993 arg_types = {"this": True, "mode": False} +3991class TimeStrToUnix(Func): +3992 pass +3993 3994 -3995 -3996class XMLTable(Func): -3997 arg_types = {"this": True, "passing": False, "columns": False, "by_ref": False} -3998 -3999 -4000class Year(Func): -4001 pass +3995class Trim(Func): +3996 arg_types = { +3997 "this": True, +3998 "expression": False, +3999 "position": False, +4000 "collation": False, +4001 } 4002 4003 -4004class Use(Expression): -4005 arg_types = {"this": True, "kind": False} +4004class TsOrDsAdd(Func, TimeUnit): +4005 arg_types = {"this": True, "expression": True, "unit": False} 4006 4007 -4008class Merge(Expression): -4009 arg_types = {"this": True, "using": True, "on": True, "expressions": True} +4008class TsOrDsToDateStr(Func): +4009 pass 4010 4011 -4012class When(Func): -4013 arg_types = {"matched": True, "source": False, "condition": False, "then": True} +4012class TsOrDsToDate(Func): +4013 arg_types = {"this": True, "format": False} 4014 4015 -4016def _norm_arg(arg): -4017 return arg.lower() if type(arg) is str else arg +4016class TsOrDiToDi(Func): +4017 pass 4018 4019 -4020ALL_FUNCTIONS = subclasses(__name__, Func, (AggFunc, Anonymous, Func)) -4021 +4020class Unhex(Func): +4021 pass 4022 -4023# Helpers -4024def maybe_parse( -4025 sql_or_expression: ExpOrStr, -4026 *, -4027 into: t.Optional[IntoType] = None, -4028 dialect: DialectType = None, -4029 prefix: t.Optional[str] = None, -4030 copy: bool = False, -4031 **opts, -4032) -> Expression: -4033 """Gracefully handle a possible string or expression. -4034 -4035 Example: -4036 >>> maybe_parse("1") -4037 (LITERAL this: 1, is_string: False) -4038 >>> maybe_parse(to_identifier("x")) -4039 (IDENTIFIER this: x, quoted: False) +4023 +4024class UnixToStr(Func): +4025 arg_types = {"this": True, "format": False} +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 +4037 +4038class UnixToTimeStr(Func): +4039 pass 4040 -4041 Args: -4042 sql_or_expression: the SQL code string or an expression -4043 into: the SQLGlot Expression to parse into -4044 dialect: the dialect used to parse the input expressions (in the case that an -4045 input expression is a SQL string). -4046 prefix: a string to prefix the sql with before it gets parsed -4047 (automatically includes a space) -4048 copy: whether or not to copy the expression. -4049 **opts: other options to use to parse the input expressions (again, in the case -4050 that an input expression is a SQL string). -4051 -4052 Returns: -4053 Expression: the parsed or given expression. -4054 """ -4055 if isinstance(sql_or_expression, Expression): -4056 if copy: -4057 return sql_or_expression.copy() -4058 return sql_or_expression -4059 -4060 import sqlglot +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} +4056 +4057 +4058class XMLTable(Func): +4059 arg_types = {"this": True, "passing": False, "columns": False, "by_ref": False} +4060 4061 -4062 sql = str(sql_or_expression) -4063 if prefix: -4064 sql = f"{prefix} {sql}" -4065 return sqlglot.parse_one(sql, read=dialect, into=into, **opts) -4066 -4067 -4068def _maybe_copy(instance, copy=True): -4069 return instance.copy() if copy else instance -4070 -4071 -4072def _is_wrong_expression(expression, into): -4073 return isinstance(expression, Expression) and not isinstance(expression, into) -4074 -4075 -4076def _apply_builder( -4077 expression, -4078 instance, -4079 arg, -4080 copy=True, -4081 prefix=None, -4082 into=None, -4083 dialect=None, -4084 **opts, -4085): -4086 if _is_wrong_expression(expression, into): -4087 expression = into(this=expression) -4088 instance = _maybe_copy(instance, copy) -4089 expression = maybe_parse( -4090 sql_or_expression=expression, -4091 prefix=prefix, -4092 into=into, -4093 dialect=dialect, -4094 **opts, -4095 ) -4096 instance.set(arg, expression) -4097 return instance +4062class Year(Func): +4063 pass +4064 +4065 +4066class Use(Expression): +4067 arg_types = {"this": True, "kind": False} +4068 +4069 +4070class Merge(Expression): +4071 arg_types = {"this": True, "using": True, "on": True, "expressions": True} +4072 +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 +4080 +4081 +4082ALL_FUNCTIONS = subclasses(__name__, Func, (AggFunc, Anonymous, Func)) +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 ... +4097 4098 -4099 -4100def _apply_child_list_builder( -4101 *expressions, -4102 instance, -4103 arg, -4104 append=True, -4105 copy=True, -4106 prefix=None, -4107 into=None, -4108 dialect=None, -4109 properties=None, -4110 **opts, -4111): -4112 instance = _maybe_copy(instance, copy) -4113 parsed = [] -4114 for expression in expressions: -4115 if _is_wrong_expression(expression, into): -4116 expression = into(expressions=[expression]) -4117 expression = maybe_parse( -4118 expression, -4119 into=into, -4120 dialect=dialect, -4121 prefix=prefix, -4122 **opts, -4123 ) -4124 parsed.extend(expression.expressions) -4125 -4126 existing = instance.args.get(arg) -4127 if append and existing: -4128 parsed = existing.expressions + parsed -4129 -4130 child = into(expressions=parsed) -4131 for k, v in (properties or {}).items(): -4132 child.set(k, v) -4133 instance.set(arg, child) -4134 return instance -4135 -4136 -4137def _apply_list_builder( -4138 *expressions, -4139 instance, -4140 arg, -4141 append=True, -4142 copy=True, -4143 prefix=None, -4144 into=None, -4145 dialect=None, -4146 **opts, -4147): -4148 inst = _maybe_copy(instance, copy) +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) +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 4149 -4150 expressions = [ -4151 maybe_parse( -4152 sql_or_expression=expression, -4153 into=into, -4154 prefix=prefix, -4155 dialect=dialect, -4156 **opts, -4157 ) -4158 for expression in expressions -4159 ] -4160 -4161 existing_expressions = inst.args.get(arg) -4162 if append and existing_expressions: -4163 expressions = existing_expressions + expressions -4164 -4165 inst.set(arg, expressions) -4166 return inst -4167 -4168 -4169def _apply_conjunction_builder( -4170 *expressions, -4171 instance, -4172 arg, -4173 into=None, -4174 append=True, -4175 copy=True, -4176 dialect=None, -4177 **opts, -4178): -4179 expressions = [exp for exp in expressions if exp is not None and exp != ""] -4180 if not expressions: -4181 return instance -4182 -4183 inst = _maybe_copy(instance, copy) -4184 -4185 existing = inst.args.get(arg) -4186 if append and existing is not None: -4187 expressions = [existing.this if into else existing] + list(expressions) -4188 -4189 node = and_(*expressions, dialect=dialect, **opts) -4190 -4191 inst.set(arg, into(this=node) if into else node) -4192 return inst -4193 -4194 -4195def _combine(expressions, operator, dialect=None, **opts): -4196 expressions = [condition(expression, dialect=dialect, **opts) for expression in expressions] -4197 this = expressions[0] -4198 if expressions[1:]: -4199 this = _wrap_operator(this) -4200 for expression in expressions[1:]: -4201 this = operator(this=this, expression=_wrap_operator(expression)) -4202 return this -4203 -4204 -4205def _wrap_operator(expression): -4206 if isinstance(expression, (And, Or, Not)): -4207 expression = Paren(this=expression) -4208 return expression -4209 -4210 -4211def union(left, right, distinct=True, dialect=None, **opts): -4212 """ -4213 Initializes a syntax tree from one UNION expression. -4214 -4215 Example: -4216 >>> union("SELECT * FROM foo", "SELECT * FROM bla").sql() -4217 'SELECT * FROM foo UNION SELECT * FROM bla' -4218 -4219 Args: -4220 left (str | Expression): the SQL code string corresponding to the left-hand side. -4221 If an `Expression` instance is passed, it will be used as-is. -4222 right (str | Expression): the SQL code string corresponding to the right-hand side. -4223 If an `Expression` instance is passed, it will be used as-is. -4224 distinct (bool): set the DISTINCT flag if and only if this is true. -4225 dialect (str): the dialect used to parse the input expression. -4226 opts (kwargs): other options to use to parse the input expressions. -4227 Returns: -4228 Union: the syntax tree for the UNION expression. -4229 """ -4230 left = maybe_parse(sql_or_expression=left, dialect=dialect, **opts) -4231 right = maybe_parse(sql_or_expression=right, dialect=dialect, **opts) -4232 -4233 return Union(this=left, expression=right, distinct=distinct) -4234 -4235 -4236def intersect(left, right, distinct=True, dialect=None, **opts): -4237 """ -4238 Initializes a syntax tree from one INTERSECT expression. -4239 -4240 Example: -4241 >>> intersect("SELECT * FROM foo", "SELECT * FROM bla").sql() -4242 'SELECT * FROM foo INTERSECT SELECT * FROM bla' -4243 -4244 Args: -4245 left (str | Expression): the SQL code string corresponding to the left-hand side. -4246 If an `Expression` instance is passed, it will be used as-is. -4247 right (str | Expression): the SQL code string corresponding to the right-hand side. -4248 If an `Expression` instance is passed, it will be used as-is. -4249 distinct (bool): set the DISTINCT flag if and only if this is true. -4250 dialect (str): the dialect used to parse the input expression. -4251 opts (kwargs): other options to use to parse the input expressions. -4252 Returns: -4253 Intersect: the syntax tree for the INTERSECT expression. -4254 """ -4255 left = maybe_parse(sql_or_expression=left, dialect=dialect, **opts) -4256 right = maybe_parse(sql_or_expression=right, dialect=dialect, **opts) -4257 -4258 return Intersect(this=left, expression=right, distinct=distinct) -4259 -4260 -4261def except_(left, right, distinct=True, dialect=None, **opts): -4262 """ -4263 Initializes a syntax tree from one EXCEPT expression. -4264 -4265 Example: -4266 >>> except_("SELECT * FROM foo", "SELECT * FROM bla").sql() -4267 'SELECT * FROM foo EXCEPT SELECT * FROM bla' -4268 -4269 Args: -4270 left (str | Expression): the SQL code string corresponding to the left-hand side. -4271 If an `Expression` instance is passed, it will be used as-is. -4272 right (str | Expression): the SQL code string corresponding to the right-hand side. -4273 If an `Expression` instance is passed, it will be used as-is. -4274 distinct (bool): set the DISTINCT flag if and only if this is true. -4275 dialect (str): the dialect used to parse the input expression. -4276 opts (kwargs): other options to use to parse the input expressions. -4277 Returns: -4278 Except: the syntax tree for the EXCEPT statement. -4279 """ -4280 left = maybe_parse(sql_or_expression=left, dialect=dialect, **opts) -4281 right = maybe_parse(sql_or_expression=right, dialect=dialect, **opts) +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) +4154 +4155 +4156def _maybe_copy(instance, copy=True): +4157 return instance.copy() if copy else instance +4158 +4159 +4160def _is_wrong_expression(expression, into): +4161 return isinstance(expression, Expression) and not isinstance(expression, into) +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 +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 -4283 return Except(this=left, expression=right, distinct=distinct) -4284 -4285 -4286def select(*expressions: ExpOrStr, dialect: DialectType = None, **opts) -> Select: -4287 """ -4288 Initializes a syntax tree from one or multiple SELECT expressions. -4289 -4290 Example: -4291 >>> select("col1", "col2").from_("tbl").sql() -4292 'SELECT col1, col2 FROM tbl' -4293 -4294 Args: -4295 *expressions: the SQL code string to parse as the expressions of a -4296 SELECT statement. If an Expression instance is passed, this is used as-is. -4297 dialect: the dialect used to parse the input expressions (in the case that an -4298 input expression is a SQL string). -4299 **opts: other options to use to parse the input expressions (again, in the case -4300 that an input expression is a SQL string). -4301 -4302 Returns: -4303 Select: the syntax tree for the SELECT statement. -4304 """ -4305 return Select().select(*expressions, dialect=dialect, **opts) +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 +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 -4308def from_(*expressions, dialect=None, **opts) -> Select: -4309 """ -4310 Initializes a syntax tree from a FROM expression. -4311 -4312 Example: -4313 >>> from_("tbl").select("col1", "col2").sql() -4314 'SELECT col1, col2 FROM tbl' -4315 -4316 Args: -4317 *expressions (str | Expression): the SQL code string to parse as the FROM expressions of a -4318 SELECT statement. If an Expression instance is passed, this is used as-is. -4319 dialect (str): the dialect used to parse the input expression (in the case that the -4320 input expression is a SQL string). -4321 **opts: other options to use to parse the input expressions (again, in the case -4322 that the input expression is a SQL string). +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 -4324 Returns: -4325 Select: the syntax tree for the SELECT statement. -4326 """ -4327 return Select().from_(*expressions, dialect=dialect, **opts) -4328 -4329 -4330def update( -4331 table: str | Table, -4332 properties: dict, -4333 where: t.Optional[ExpOrStr] = None, -4334 from_: t.Optional[ExpOrStr] = None, -4335 dialect: DialectType = None, -4336 **opts, -4337) -> Update: -4338 """ -4339 Creates an update statement. -4340 -4341 Example: -4342 >>> update("my_table", {"x": 1, "y": "2", "z": None}, from_="baz", where="id > 1").sql() -4343 "UPDATE my_table SET x = 1, y = '2', z = NULL FROM baz WHERE id > 1" -4344 -4345 Args: -4346 *properties: dictionary of properties to set which are -4347 auto converted to sql objects eg None -> NULL -4348 where: sql conditional parsed into a WHERE statement -4349 from_: sql statement parsed into a FROM statement -4350 dialect: the dialect used to parse the input expressions. -4351 **opts: other options to use to parse the input expressions. +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 Returns: -4354 Update: the syntax tree for the UPDATE statement. -4355 """ -4356 update_expr = Update(this=maybe_parse(table, into=Table, dialect=dialect)) -4357 update_expr.set( -4358 "expressions", -4359 [ -4360 EQ(this=maybe_parse(k, dialect=dialect, **opts), expression=convert(v)) -4361 for k, v in properties.items() -4362 ], -4363 ) -4364 if from_: -4365 update_expr.set( -4366 "from", -4367 maybe_parse(from_, into=From, dialect=dialect, prefix="FROM", **opts), -4368 ) -4369 if isinstance(where, Condition): -4370 where = Where(this=where) -4371 if where: -4372 update_expr.set( -4373 "where", -4374 maybe_parse(where, into=Where, dialect=dialect, prefix="WHERE", **opts), -4375 ) -4376 return update_expr +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) +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 -4379def delete( -4380 table: ExpOrStr, -4381 where: t.Optional[ExpOrStr] = None, -4382 returning: t.Optional[ExpOrStr] = None, -4383 dialect: DialectType = None, -4384 **opts, -4385) -> Delete: -4386 """ -4387 Builds a delete statement. -4388 -4389 Example: -4390 >>> delete("my_table", where="id > 1").sql() -4391 'DELETE FROM my_table WHERE id > 1' -4392 -4393 Args: -4394 where: sql conditional parsed into a WHERE statement -4395 returning: sql conditional parsed into a RETURNING statement -4396 dialect: the dialect used to parse the input expressions. -4397 **opts: other options to use to parse the input expressions. -4398 -4399 Returns: -4400 Delete: the syntax tree for the DELETE statement. -4401 """ -4402 delete_expr = Delete().delete(table, dialect=dialect, copy=False, **opts) -4403 if where: -4404 delete_expr = delete_expr.where(where, dialect=dialect, copy=False, **opts) -4405 if returning: -4406 delete_expr = delete_expr.returning(returning, dialect=dialect, copy=False, **opts) -4407 return delete_expr -4408 -4409 -4410def condition(expression, dialect=None, **opts) -> Condition: -4411 """ -4412 Initialize a logical condition expression. -4413 -4414 Example: -4415 >>> condition("x=1").sql() -4416 'x = 1' +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 -4418 This is helpful for composing larger logical syntax trees: -4419 >>> where = condition("x=1") -4420 >>> where = where.and_("y=1") -4421 >>> Select().from_("tbl").select("*").where(where).sql() -4422 'SELECT * FROM tbl WHERE x = 1 AND y = 1' -4423 -4424 Args: -4425 *expression (str | Expression): the SQL code string to parse. -4426 If an Expression instance is passed, this is used as-is. -4427 dialect (str): the dialect used to parse the input expression (in the case that the -4428 input expression is a SQL string). -4429 **opts: other options to use to parse the input expressions (again, in the case -4430 that the input expression is a SQL string). -4431 -4432 Returns: -4433 Condition: the expression -4434 """ -4435 return maybe_parse( # type: ignore -4436 expression, -4437 into=Condition, -4438 dialect=dialect, -4439 **opts, -4440 ) -4441 -4442 -4443def and_(*expressions, dialect=None, **opts) -> And: -4444 """ -4445 Combine multiple conditions with an AND logical operator. -4446 -4447 Example: -4448 >>> and_("x=1", and_("y=1", "z=1")).sql() -4449 'x = 1 AND (y = 1 AND z = 1)' -4450 -4451 Args: -4452 *expressions (str | Expression): the SQL code strings to parse. -4453 If an Expression instance is passed, this is used as-is. -4454 dialect (str): the dialect used to parse the input expression. -4455 **opts: other options to use to parse the input expressions. -4456 -4457 Returns: -4458 And: the new condition -4459 """ -4460 return _combine(expressions, And, dialect, **opts) -4461 -4462 -4463def or_(*expressions, dialect=None, **opts) -> Or: -4464 """ -4465 Combine multiple conditions with an OR logical operator. +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 -4467 Example: -4468 >>> or_("x=1", or_("y=1", "z=1")).sql() -4469 'x = 1 OR (y = 1 OR z = 1)' -4470 -4471 Args: -4472 *expressions (str | Expression): the SQL code strings to parse. -4473 If an Expression instance is passed, this is used as-is. -4474 dialect (str): the dialect used to parse the input expression. -4475 **opts: other options to use to parse the input expressions. +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 Returns: -4478 Or: the new condition -4479 """ -4480 return _combine(expressions, Or, dialect, **opts) -4481 -4482 -4483def not_(expression, dialect=None, **opts) -> Not: -4484 """ -4485 Wrap a condition with a NOT operator. +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 Example: -4488 >>> not_("this_suit='black'").sql() -4489 "NOT this_suit = 'black'" -4490 -4491 Args: -4492 expression (str | Expression): the SQL code strings to parse. -4493 If an Expression instance is passed, this is used as-is. -4494 dialect (str): the dialect used to parse the input expression. -4495 **opts: other options to use to parse the input expressions. +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 4496 -4497 Returns: -4498 Not: the new condition -4499 """ -4500 this = condition( -4501 expression, -4502 dialect=dialect, -4503 **opts, -4504 ) -4505 return Not(this=_wrap_operator(this)) -4506 -4507 -4508def paren(expression) -> Paren: -4509 return Paren(this=expression) -4510 +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 -4512SAFE_IDENTIFIER_RE = re.compile(r"^[_a-zA-Z][\w]*$") -4513 -4514 -4515@t.overload -4516def to_identifier(name: None, quoted: t.Optional[bool] = None) -> None: -4517 ... -4518 +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@t.overload -4521def to_identifier(name: str | Identifier, quoted: t.Optional[bool] = None) -> Identifier: -4522 ... -4523 -4524 -4525def to_identifier(name, quoted=None): -4526 """Builds an identifier. -4527 -4528 Args: -4529 name: The name to turn into an identifier. -4530 quoted: Whether or not force quote the identifier. -4531 -4532 Returns: -4533 The identifier ast node. -4534 """ -4535 -4536 if name is None: -4537 return None +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 if isinstance(name, Identifier): -4540 identifier = name -4541 elif isinstance(name, str): -4542 identifier = Identifier( -4543 this=name, -4544 quoted=not SAFE_IDENTIFIER_RE.match(name) if quoted is None else quoted, -4545 ) -4546 else: -4547 raise ValueError(f"Name needs to be a string or an Identifier, got: {name.__class__}") -4548 return identifier +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 4550 -4551INTERVAL_STRING_RE = re.compile(r"\s*([0-9]+)\s*([a-zA-Z]+)\s*") -4552 -4553 -4554def to_interval(interval: str | Literal) -> Interval: -4555 """Builds an interval expression from a string like '1 day' or '5 months'.""" -4556 if isinstance(interval, Literal): -4557 if not interval.is_string: -4558 raise ValueError("Invalid interval string.") -4559 -4560 interval = interval.this -4561 -4562 interval_parts = INTERVAL_STRING_RE.match(interval) # type: ignore -4563 -4564 if not interval_parts: -4565 raise ValueError("Invalid interval string.") -4566 -4567 return Interval( -4568 this=Literal.string(interval_parts.group(1)), -4569 unit=Var(this=interval_parts.group(2)), -4570 ) -4571 -4572 -4573@t.overload -4574def to_table(sql_path: str | Table, **kwargs) -> Table: -4575 ... -4576 -4577 -4578@t.overload -4579def to_table(sql_path: None, **kwargs) -> None: -4580 ... -4581 -4582 -4583def to_table(sql_path: t.Optional[str | Table], **kwargs) -> t.Optional[Table]: -4584 """ -4585 Create a table expression from a `[catalog].[schema].[table]` sql path. Catalog and schema are optional. -4586 If a table is passed in then that table is returned. -4587 -4588 Args: -4589 sql_path: a `[catalog].[schema].[table]` string. -4590 -4591 Returns: -4592 A table expression. -4593 """ -4594 if sql_path is None or isinstance(sql_path, Table): -4595 return sql_path -4596 if not isinstance(sql_path, str): -4597 raise ValueError(f"Invalid type provided for a table: {type(sql_path)}") +4551def or_(*expressions, dialect=None, **opts) -> Or: +4552 """ +4553 Combine multiple conditions with an OR logical operator. +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 catalog, db, table_name = (to_identifier(x) for x in split_num_words(sql_path, ".", 3)) -4600 return Table(this=table_name, db=db, catalog=catalog, **kwargs) +4599 +4600SAFE_IDENTIFIER_RE = re.compile(r"^[_a-zA-Z][\w]*$") 4601 4602 -4603def to_column(sql_path: str | Column, **kwargs) -> Column: -4604 """ -4605 Create a column from a `[table].[column]` sql path. Schema is optional. +4603@t.overload +4604def to_identifier(name: None, quoted: t.Optional[bool] = None) -> None: +4605 ... 4606 -4607 If a column is passed in then that column is returned. -4608 -4609 Args: -4610 sql_path: `[table].[column]` string -4611 Returns: -4612 Table: A column expression -4613 """ -4614 if sql_path is None or isinstance(sql_path, Column): -4615 return sql_path -4616 if not isinstance(sql_path, str): -4617 raise ValueError(f"Invalid type provided for column: {type(sql_path)}") -4618 return column(*reversed(sql_path.split(".")), **kwargs) # type: ignore +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 -4621def alias_( -4622 expression: ExpOrStr, -4623 alias: str | Identifier, -4624 table: bool | t.Sequence[str | Identifier] = False, -4625 quoted: t.Optional[bool] = None, -4626 dialect: DialectType = None, -4627 **opts, -4628): -4629 """Create an Alias expression. -4630 -4631 Example: -4632 >>> alias_('foo', 'bar').sql() -4633 'foo AS bar' -4634 -4635 >>> alias_('(select 1, 2)', 'bar', table=['a', 'b']).sql() -4636 '(SELECT 1, 2) AS bar(a, b)' +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 4637 -4638 Args: -4639 expression: the SQL code strings to parse. -4640 If an Expression instance is passed, this is used as-is. -4641 alias: the alias name to use. If the name has -4642 special characters it is quoted. -4643 table: Whether or not to create a table alias, can also be a list of columns. -4644 quoted: whether or not to quote the alias -4645 dialect: the dialect used to parse the input expression. -4646 **opts: other options to use to parse the input expressions. +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.") 4647 -4648 Returns: -4649 Alias: the aliased expression -4650 """ -4651 exp = maybe_parse(expression, dialect=dialect, **opts) -4652 alias = to_identifier(alias, quoted=quoted) -4653 -4654 if table: -4655 table_alias = TableAlias(this=alias) -4656 exp.set("alias", table_alias) -4657 -4658 if not isinstance(table, bool): -4659 for column in table: -4660 table_alias.append("columns", to_identifier(column, quoted=quoted)) -4661 -4662 return exp -4663 -4664 # We don't set the "alias" arg for Window expressions, because that would add an IDENTIFIER node in -4665 # the AST, representing a "named_window" [1] construct (eg. bigquery). What we want is an ALIAS node -4666 # for the complete Window expression. -4667 # -4668 # [1]: https://cloud.google.com/bigquery/docs/reference/standard-sql/window-function-calls +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 if "alias" in exp.arg_types and not isinstance(exp, Window): -4671 exp = exp.copy() -4672 exp.set("alias", alias) -4673 return exp -4674 return Alias(this=exp, alias=alias) +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 -4677def subquery(expression, alias=None, dialect=None, **opts): -4678 """ -4679 Build a subquery expression. -4680 -4681 Example: -4682 >>> subquery('select x from tbl', 'bar').select('x').sql() -4683 'SELECT x FROM (SELECT x FROM tbl) AS bar' -4684 -4685 Args: -4686 expression (str | Expression): the SQL code strings to parse. -4687 If an Expression instance is passed, this is used as-is. -4688 alias (str | Expression): the alias name to use. -4689 dialect (str): the dialect used to parse the input expression. -4690 **opts: other options to use to parse the input expressions. -4691 -4692 Returns: -4693 Select: a new select with the subquery expression included -4694 """ -4695 -4696 expression = maybe_parse(expression, dialect=dialect, **opts).subquery(alias) -4697 return Select().from_(expression, dialect=dialect, **opts) -4698 -4699 -4700def column( -4701 col: str | Identifier, -4702 table: t.Optional[str | Identifier] = None, -4703 db: t.Optional[str | Identifier] = None, -4704 catalog: t.Optional[str | Identifier] = None, -4705 quoted: t.Optional[bool] = None, -4706) -> Column: -4707 """ -4708 Build a Column. -4709 -4710 Args: -4711 col: column name -4712 table: table name -4713 db: db name -4714 catalog: catalog name -4715 quoted: whether or not to force quote each part -4716 Returns: -4717 Column: column instance -4718 """ -4719 return Column( -4720 this=to_identifier(col, quoted=quoted), -4721 table=to_identifier(table, quoted=quoted), -4722 db=to_identifier(db, quoted=quoted), -4723 catalog=to_identifier(catalog, quoted=quoted), -4724 ) +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 +4699 Returns: +4700 Table: A column expression +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 +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)' 4725 -4726 -4727def cast(expression: ExpOrStr, to: str | DataType | DataType.Type, **opts) -> Cast: -4728 """Cast an expression to a data type. -4729 -4730 Example: -4731 >>> cast('x + 1', 'int').sql() -4732 'CAST(x + 1 AS INT)' -4733 -4734 Args: -4735 expression: The expression to cast. -4736 to: The datatype to cast to. -4737 -4738 Returns: -4739 A cast node. -4740 """ -4741 expression = maybe_parse(expression, **opts) -4742 return Cast(this=expression, to=DataType.build(to, **opts)) -4743 +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 -4745def table_(table, db=None, catalog=None, quoted=None, alias=None) -> Table: -4746 """Build a Table. +4745 exp = exp.copy() if isinstance(expression, Expression) else exp +4746 exp.set("alias", table_alias) 4747 -4748 Args: -4749 table (str | Expression): column name -4750 db (str | Expression): db name -4751 catalog (str | Expression): catalog name -4752 -4753 Returns: -4754 Table: table instance -4755 """ -4756 return Table( -4757 this=to_identifier(table, quoted=quoted), -4758 db=to_identifier(db, quoted=quoted), -4759 catalog=to_identifier(catalog, quoted=quoted), -4760 alias=TableAlias(this=to_identifier(alias)) if alias else None, -4761 ) -4762 -4763 -4764def values( -4765 values: t.Iterable[t.Tuple[t.Any, ...]], -4766 alias: t.Optional[str] = None, -4767 columns: t.Optional[t.Iterable[str] | t.Dict[str, DataType]] = None, -4768) -> Values: -4769 """Build VALUES statement. +4748 if not isinstance(table, bool): +4749 for column in table: +4750 table_alias.append("columns", to_identifier(column, quoted=quoted)) +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 >>> values([(1, '2')]).sql() -4773 "VALUES (1, '2')" +4772 >>> subquery('select x from tbl', 'bar').select('x').sql() +4773 'SELECT x FROM (SELECT x FROM tbl) AS bar' 4774 4775 Args: -4776 values: values statements that will be converted to SQL -4777 alias: optional alias -4778 columns: Optional list of ordered column names or ordered dictionary of column names to types. -4779 If either are provided then an alias is also required. -4780 If a dictionary is provided then the first column of the values will be casted to the expected type -4781 in order to help with type inference. -4782 -4783 Returns: -4784 Values: the Values expression object -4785 """ -4786 if columns and not alias: -4787 raise ValueError("Alias is required when providing columns") -4788 table_alias = ( -4789 TableAlias(this=to_identifier(alias), columns=[to_identifier(x) for x in columns]) -4790 if columns -4791 else TableAlias(this=to_identifier(alias) if alias else None) -4792 ) -4793 expressions = [convert(tup) for tup in values] -4794 if columns and isinstance(columns, dict): -4795 types = list(columns.values()) -4796 expressions[0].set( -4797 "expressions", -4798 [cast(x, types[i]) for i, x in enumerate(expressions[0].expressions)], -4799 ) -4800 return Values( -4801 expressions=expressions, -4802 alias=table_alias, -4803 ) -4804 -4805 -4806def var(name: t.Optional[ExpOrStr]) -> Var: -4807 """Build a SQL variable. -4808 -4809 Example: -4810 >>> repr(var('x')) -4811 '(VAR this: x)' -4812 -4813 >>> repr(var(column('x', table='y'))) -4814 '(VAR this: x)' +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), +4814 ) 4815 -4816 Args: -4817 name: The name of the var or an expression who's name will become the var. -4818 -4819 Returns: -4820 The new variable node. -4821 """ -4822 if not name: -4823 raise ValueError("Cannot convert empty name into var.") -4824 -4825 if isinstance(name, Expression): -4826 name = name.name -4827 return Var(this=name) -4828 -4829 -4830def rename_table(old_name: str | Table, new_name: str | Table) -> AlterTable: -4831 """Build ALTER TABLE... RENAME... expression -4832 -4833 Args: -4834 old_name: The old name of the table -4835 new_name: The new name of the table -4836 -4837 Returns: -4838 Alter table expression -4839 """ -4840 old_table = to_table(old_name) -4841 new_table = to_table(new_name) -4842 return AlterTable( -4843 this=old_table, -4844 actions=[ -4845 RenameTable(this=new_table), -4846 ], -4847 ) -4848 -4849 -4850def convert(value) -> Expression: -4851 """Convert a python value into an expression object. +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 +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 +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 ) 4852 -4853 Raises an error if a conversion is not possible. -4854 -4855 Args: -4856 value (Any): a python object -4857 -4858 Returns: -4859 Expression: the equivalent expression object -4860 """ -4861 if isinstance(value, Expression): -4862 return value -4863 if value is None: -4864 return NULL -4865 if isinstance(value, bool): -4866 return Boolean(this=value) -4867 if isinstance(value, str): -4868 return Literal.string(value) -4869 if isinstance(value, float) and math.isnan(value): -4870 return NULL -4871 if isinstance(value, numbers.Number): -4872 return Literal.number(value) -4873 if isinstance(value, tuple): -4874 return Tuple(expressions=[convert(v) for v in value]) -4875 if isinstance(value, list): -4876 return Array(expressions=[convert(v) for v in value]) -4877 if isinstance(value, dict): -4878 return Map( -4879 keys=[convert(k) for k in value], -4880 values=[convert(v) for v in value.values()], -4881 ) -4882 if isinstance(value, datetime.datetime): -4883 datetime_literal = Literal.string( -4884 (value if value.tzinfo else value.replace(tzinfo=datetime.timezone.utc)).isoformat() -4885 ) -4886 return TimeStrToTime(this=datetime_literal) -4887 if isinstance(value, datetime.date): -4888 date_literal = Literal.string(value.strftime("%Y-%m-%d")) -4889 return DateStrToDate(this=date_literal) -4890 raise ValueError(f"Cannot convert {value}") -4891 -4892 -4893def replace_children(expression, fun, *args, **kwargs): -4894 """ -4895 Replace children of an expression with the result of a lambda fun(child) -> exp. -4896 """ -4897 for k, v in expression.args.items(): -4898 is_list_arg = type(v) is list -4899 -4900 child_nodes = v if is_list_arg else [v] -4901 new_child_nodes = [] +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')" +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 for cn in child_nodes: -4904 if isinstance(cn, Expression): -4905 for child_node in ensure_collection(fun(cn, *args, **kwargs)): -4906 new_child_nodes.append(child_node) -4907 child_node.parent = expression -4908 child_node.arg_key = k -4909 else: -4910 new_child_nodes.append(cn) -4911 -4912 expression.args[k] = new_child_nodes if is_list_arg else seq_get(new_child_nodes, 0) -4913 +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 -4915def column_table_names(expression): -4916 """ -4917 Return all table names referenced through columns in an expression. +4915 if isinstance(name, Expression): +4916 name = name.name +4917 return Var(this=name) 4918 -4919 Example: -4920 >>> import sqlglot -4921 >>> column_table_names(sqlglot.parse_one("a.b AND c.d AND c.e")) -4922 ['c', 'a'] -4923 -4924 Args: -4925 expression (sqlglot.Expression): expression to find table names +4919 +4920def rename_table(old_name: str | Table, new_name: str | Table) -> AlterTable: +4921 """Build ALTER TABLE... RENAME... expression +4922 +4923 Args: +4924 old_name: The old name of the table +4925 new_name: The new name of the table 4926 4927 Returns: -4928 list: A list of unique names +4928 Alter table expression 4929 """ -4930 return list(dict.fromkeys(column.table for column in expression.find_all(Column))) -4931 -4932 -4933def table_name(table) -> str: -4934 """Get the full name of a table as a string. -4935 -4936 Args: -4937 table (exp.Table | str): table expression node or string. +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 Examples: -4940 >>> from sqlglot import exp, parse_one -4941 >>> table_name(parse_one("select * from a.b.c").find(exp.Table)) -4942 'a.b.c' -4943 -4944 Returns: -4945 The table name. -4946 """ +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. +4944 +4945 Args: +4946 value (Any): a python object 4947 -4948 table = maybe_parse(table, into=Table) -4949 -4950 if not table: -4951 raise ValueError(f"Cannot parse {table}") -4952 -4953 return ".".join( -4954 part -4955 for part in ( -4956 table.text("catalog"), -4957 table.text("db"), -4958 table.name, -4959 ) -4960 if part -4961 ) -4962 -4963 -4964def replace_tables(expression, mapping): -4965 """Replace all tables in expression according to the mapping. -4966 -4967 Args: -4968 expression (sqlglot.Expression): expression node to be transformed and replaced. -4969 mapping (Dict[str, str]): mapping of table names. -4970 -4971 Examples: -4972 >>> from sqlglot import exp, parse_one -4973 >>> replace_tables(parse_one("select * from a.b"), {"a.b": "c"}).sql() -4974 'SELECT * FROM c' -4975 -4976 Returns: -4977 The mapped expression. -4978 """ -4979 -4980 def _replace_tables(node): -4981 if isinstance(node, Table): -4982 new_name = mapping.get(table_name(node)) -4983 if new_name: -4984 return to_table( -4985 new_name, -4986 **{k: v for k, v in node.args.items() if k not in ("this", "db", "catalog")}, -4987 ) -4988 return node +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. +4986 """ +4987 for k, v in expression.args.items(): +4988 is_list_arg = type(v) is list 4989 -4990 return expression.transform(_replace_tables) -4991 +4990 child_nodes = v if is_list_arg else [v] +4991 new_child_nodes = [] 4992 -4993def replace_placeholders(expression, *args, **kwargs): -4994 """Replace placeholders in an expression. -4995 -4996 Args: -4997 expression (sqlglot.Expression): expression node to be transformed and replaced. -4998 args: positional names that will substitute unnamed placeholders in the given order. -4999 kwargs: keyword arguments that will substitute named placeholders. -5000 -5001 Examples: -5002 >>> from sqlglot import exp, parse_one -5003 >>> replace_placeholders( -5004 ... parse_one("select * from :tbl where ? = ?"), -5005 ... exp.to_identifier("str_col"), "b", tbl=exp.to_identifier("foo") -5006 ... ).sql() -5007 "SELECT * FROM foo WHERE str_col = 'b'" +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. 5008 -5009 Returns: -5010 The mapped expression. -5011 """ -5012 -5013 def _replace_placeholders(node, args, **kwargs): -5014 if isinstance(node, Placeholder): -5015 if node.name: -5016 new_name = kwargs.get(node.name) -5017 if new_name: -5018 return convert(new_name) -5019 else: -5020 try: -5021 return convert(next(args)) -5022 except StopIteration: -5023 pass -5024 return node +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 +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 return expression.transform(_replace_placeholders, iter(args), **kwargs) -5027 +5026 Args: +5027 table (exp.Table | str): table expression node or string. 5028 -5029def expand(expression: Expression, sources: t.Dict[str, Subqueryable], copy=True) -> Expression: -5030 """Transforms an expression by expanding all referenced sources into subqueries. -5031 -5032 Examples: -5033 >>> from sqlglot import parse_one -5034 >>> expand(parse_one("select * from x AS z"), {"x": parse_one("select * from y")}).sql() -5035 'SELECT * FROM (SELECT * FROM y) AS z /* source: x */' -5036 -5037 Args: -5038 expression: The expression to expand. -5039 sources: A dictionary of name to Subqueryables. -5040 copy: Whether or not to copy the expression during transformation. Defaults to True. -5041 -5042 Returns: -5043 The transformed expression. -5044 """ -5045 -5046 def _expand(node: Expression): -5047 if isinstance(node, Table): -5048 name = table_name(node) -5049 source = sources.get(name) -5050 if source: -5051 subquery = source.subquery(node.alias or name) -5052 subquery.comments = [f"source: {name}"] -5053 return subquery -5054 return node -5055 -5056 return expression.transform(_expand, copy=copy) -5057 -5058 -5059def func(name: str, *args, dialect: DialectType = None, **kwargs) -> Func: -5060 """ -5061 Returns a Func expression. -5062 -5063 Examples: -5064 >>> func("abs", 5).sql() -5065 'ABS(5)' -5066 -5067 >>> func("cast", this=5, to=DataType.build("DOUBLE")).sql() -5068 'CAST(5 AS DOUBLE)' +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}") +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 ) +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' +5065 +5066 Returns: +5067 The mapped expression. +5068 """ 5069 -5070 Args: -5071 name: the name of the function to build. -5072 args: the args used to instantiate the function of interest. -5073 dialect: the source dialect. -5074 kwargs: the kwargs used to instantiate the function of interest. -5075 -5076 Note: -5077 The arguments `args` and `kwargs` are mutually exclusive. -5078 -5079 Returns: -5080 An instance of the function of interest, or an anonymous function, if `name` doesn't -5081 correspond to an existing `sqlglot.expressions.Func` class. -5082 """ -5083 if args and kwargs: -5084 raise ValueError("Can't use both args and kwargs to instantiate a function.") +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. 5085 -5086 from sqlglot.dialects.dialect import Dialect -5087 -5088 converted = [convert(arg) for arg in args] -5089 kwargs = {key: convert(value) for key, value in kwargs.items()} +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 parser = Dialect.get_or_raise(dialect)().parser() -5092 from_args_list = parser.FUNCTIONS.get(name.upper()) -5093 -5094 if from_args_list: -5095 function = from_args_list(converted) if converted else from_args_list.__self__(**kwargs) # type: ignore -5096 else: -5097 kwargs = kwargs or {"expressions": converted} -5098 function = Anonymous(this=name, **kwargs) -5099 -5100 for error_message in function.error_messages(converted): -5101 raise ValueError(error_message) +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 return function -5104 -5105 -5106def true(): -5107 """ -5108 Returns a true Boolean expression. -5109 """ -5110 return Boolean(this=True) -5111 -5112 -5113def false(): -5114 """ -5115 Returns a false Boolean expression. -5116 """ -5117 return Boolean(this=False) +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 -5119 -5120def null(): -5121 """ -5122 Returns a Null expression. -5123 """ -5124 return Null() -5125 -5126 -5127# TODO: deprecate this -5128TRUE = Boolean(this=True) -5129FALSE = Boolean(this=False) -5130NULL = Null() +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 */' +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 +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()} +5185 +5186 parser = Dialect.get_or_raise(dialect)().parser() +5187 from_args_list = parser.FUNCTIONS.get(name.upper()) +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 +5199 +5200 +5201def true(): +5202 """ +5203 Returns a true Boolean expression. +5204 """ +5205 return Boolean(this=True) +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() @@ -10926,11 +11084,10 @@ If an Expression instance is passed, it w 819 "properties": False, 820 "replace": False, 821 "unique": False, -822 "volatile": False, -823 "indexes": False, -824 "no_schema_binding": False, -825 "begin": False, -826 } +822 "indexes": False, +823 "no_schema_binding": False, +824 "begin": False, +825 } @@ -10993,8 +11150,8 @@ If an Expression instance is passed, it w -
    829class Describe(Expression):
    -830    arg_types = {"this": True, "kind": False}
    +            
    828class Describe(Expression):
    +829    arg_types = {"this": True, "kind": False}
     
    @@ -11057,8 +11214,8 @@ If an Expression instance is passed, it w
    -
    833class Pragma(Expression):
    -834    pass
    +            
    832class Pragma(Expression):
    +833    pass
     
    @@ -11121,8 +11278,8 @@ If an Expression instance is passed, it w
    -
    837class Set(Expression):
    -838    arg_types = {"expressions": False}
    +            
    836class Set(Expression):
    +837    arg_types = {"expressions": False}
     
    @@ -11185,14 +11342,14 @@ If an Expression instance is passed, it w
    -
    841class SetItem(Expression):
    -842    arg_types = {
    -843        "this": False,
    -844        "expressions": False,
    -845        "kind": False,
    -846        "collate": False,  # MySQL SET NAMES statement
    -847        "global": False,
    -848    }
    +            
    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    }
     
    @@ -11255,24 +11412,24 @@ If an Expression instance is passed, it w
    -
    851class Show(Expression):
    -852    arg_types = {
    -853        "this": True,
    -854        "target": False,
    -855        "offset": False,
    -856        "limit": False,
    -857        "like": False,
    -858        "where": False,
    -859        "db": False,
    -860        "full": False,
    -861        "mutex": False,
    -862        "query": False,
    -863        "channel": False,
    -864        "global": False,
    -865        "log": False,
    -866        "position": False,
    -867        "types": False,
    -868    }
    +            
    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    }
     
    @@ -11335,8 +11492,8 @@ If an Expression instance is passed, it w
    -
    871class UserDefinedFunction(Expression):
    -872    arg_types = {"this": True, "expressions": False, "wrapped": False}
    +            
    870class UserDefinedFunction(Expression):
    +871    arg_types = {"this": True, "expressions": False, "wrapped": False}
     
    @@ -11399,8 +11556,8 @@ If an Expression instance is passed, it w
    -
    875class CharacterSet(Expression):
    -876    arg_types = {"this": True, "default": False}
    +            
    874class CharacterSet(Expression):
    +875    arg_types = {"this": True, "default": False}
     
    @@ -11463,12 +11620,12 @@ If an Expression instance is passed, it w
    -
    879class With(Expression):
    -880    arg_types = {"expressions": True, "recursive": False}
    -881
    -882    @property
    -883    def recursive(self) -> bool:
    -884        return bool(self.args.get("recursive"))
    +            
    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"))
     
    @@ -11531,8 +11688,8 @@ If an Expression instance is passed, it w
    -
    887class WithinGroup(Expression):
    -888    arg_types = {"this": True, "expression": False}
    +            
    886class WithinGroup(Expression):
    +887    arg_types = {"this": True, "expression": False}
     
    @@ -11595,8 +11752,8 @@ If an Expression instance is passed, it w
    -
    891class CTE(DerivedTable):
    -892    arg_types = {"this": True, "alias": True}
    +            
    890class CTE(DerivedTable):
    +891    arg_types = {"this": True, "alias": True}
     
    @@ -11659,12 +11816,12 @@ If an Expression instance is passed, it w
    -
    895class TableAlias(Expression):
    -896    arg_types = {"this": False, "columns": False}
    -897
    -898    @property
    -899    def columns(self):
    -900        return self.args.get("columns") or []
    +            
    894class TableAlias(Expression):
    +895    arg_types = {"this": False, "columns": False}
    +896
    +897    @property
    +898    def columns(self):
    +899        return self.args.get("columns") or []
     
    @@ -11727,8 +11884,8 @@ If an Expression instance is passed, it w
    -
    903class BitString(Condition):
    -904    pass
    +            
    902class BitString(Condition):
    +903    pass
     
    @@ -11797,8 +11954,8 @@ If an Expression instance is passed, it w
    -
    907class HexString(Condition):
    -908    pass
    +            
    906class HexString(Condition):
    +907    pass
     
    @@ -11867,8 +12024,8 @@ If an Expression instance is passed, it w
    -
    911class ByteString(Condition):
    -912    pass
    +            
    910class ByteString(Condition):
    +911    pass
     
    @@ -11937,41 +12094,41 @@ If an Expression instance is passed, it w
    -
    915class Column(Condition):
    -916    arg_types = {"this": True, "table": False, "db": False, "catalog": False, "join_mark": False}
    -917
    -918    @property
    -919    def table(self) -> str:
    -920        return self.text("table")
    -921
    -922    @property
    -923    def db(self) -> str:
    -924        return self.text("db")
    -925
    -926    @property
    -927    def catalog(self) -> str:
    -928        return self.text("catalog")
    -929
    -930    @property
    -931    def output_name(self) -> str:
    -932        return self.name
    -933
    -934    @property
    -935    def parts(self) -> t.List[Identifier]:
    -936        """Return the parts of a column in order catalog, db, table, name."""
    -937        return [part for part in reversed(list(self.args.values())) if part]
    -938
    -939    def to_dot(self) -> Dot:
    -940        """Converts the column into a dot expression."""
    -941        parts = self.parts
    -942        parent = self.parent
    -943
    -944        while parent:
    -945            if isinstance(parent, Dot):
    -946                parts.append(parent.expression)
    -947            parent = parent.parent
    -948
    -949        return Dot.build(parts)
    +            
    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)
     
    @@ -12031,17 +12188,17 @@ If an Expression instance is passed, it w
    -
    939    def to_dot(self) -> Dot:
    -940        """Converts the column into a dot expression."""
    -941        parts = self.parts
    -942        parent = self.parent
    -943
    -944        while parent:
    -945            if isinstance(parent, Dot):
    -946                parts.append(parent.expression)
    -947            parent = parent.parent
    -948
    -949        return Dot.build(parts)
    +            
    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)
     
    @@ -12112,8 +12269,8 @@ If an Expression instance is passed, it w
    -
    952class ColumnPosition(Expression):
    -953    arg_types = {"this": False, "position": True}
    +            
    951class ColumnPosition(Expression):
    +952    arg_types = {"this": False, "position": True}
     
    @@ -12176,14 +12333,14 @@ If an Expression instance is passed, it w
    -
    956class ColumnDef(Expression):
    -957    arg_types = {
    -958        "this": True,
    -959        "kind": False,
    -960        "constraints": False,
    -961        "exists": False,
    -962        "position": False,
    -963    }
    +            
    955class ColumnDef(Expression):
    +956    arg_types = {
    +957        "this": True,
    +958        "kind": False,
    +959        "constraints": False,
    +960        "exists": False,
    +961        "position": False,
    +962    }
     
    @@ -12246,15 +12403,15 @@ If an Expression instance is passed, it w
    -
    966class AlterColumn(Expression):
    -967    arg_types = {
    -968        "this": True,
    -969        "dtype": False,
    -970        "collate": False,
    -971        "using": False,
    -972        "default": False,
    -973        "drop": False,
    -974    }
    +            
    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    }
     
    @@ -12317,8 +12474,8 @@ If an Expression instance is passed, it w
    -
    977class RenameTable(Expression):
    -978    pass
    +            
    976class RenameTable(Expression):
    +977    pass
     
    @@ -12381,8 +12538,8 @@ If an Expression instance is passed, it w
    -
    981class SetTag(Expression):
    -982    arg_types = {"expressions": True, "unset": False}
    +            
    980class SetTag(Expression):
    +981    arg_types = {"expressions": True, "unset": False}
     
    @@ -12445,8 +12602,8 @@ If an Expression instance is passed, it w
    -
    985class Comment(Expression):
    -986    arg_types = {"this": True, "kind": True, "expression": True, "exists": False}
    +            
    984class Comment(Expression):
    +985    arg_types = {"this": True, "kind": True, "expression": True, "exists": False}
     
    @@ -12509,8 +12666,8 @@ If an Expression instance is passed, it w
    -
    989class ColumnConstraint(Expression):
    -990    arg_types = {"this": False, "kind": True}
    +            
    988class ColumnConstraint(Expression):
    +989    arg_types = {"this": False, "kind": True}
     
    @@ -12573,8 +12730,8 @@ If an Expression instance is passed, it w
    -
    993class ColumnConstraintKind(Expression):
    -994    pass
    +            
    992class ColumnConstraintKind(Expression):
    +993    pass
     
    @@ -12637,8 +12794,8 @@ If an Expression instance is passed, it w
    -
    997class AutoIncrementColumnConstraint(ColumnConstraintKind):
    -998    pass
    +            
    996class AutoIncrementColumnConstraint(ColumnConstraintKind):
    +997    pass
     
    @@ -12701,8 +12858,8 @@ If an Expression instance is passed, it w
    -
    1001class CaseSpecificColumnConstraint(ColumnConstraintKind):
    -1002    arg_types = {"not_": True}
    +            
    1000class CaseSpecificColumnConstraint(ColumnConstraintKind):
    +1001    arg_types = {"not_": True}
     
    @@ -12765,8 +12922,8 @@ If an Expression instance is passed, it w
    -
    1005class CharacterSetColumnConstraint(ColumnConstraintKind):
    -1006    arg_types = {"this": True}
    +            
    1004class CharacterSetColumnConstraint(ColumnConstraintKind):
    +1005    arg_types = {"this": True}
     
    @@ -12829,8 +12986,8 @@ If an Expression instance is passed, it w
    -
    1009class CheckColumnConstraint(ColumnConstraintKind):
    -1010    pass
    +            
    1008class CheckColumnConstraint(ColumnConstraintKind):
    +1009    pass
     
    @@ -12893,8 +13050,8 @@ If an Expression instance is passed, it w
    -
    1013class CollateColumnConstraint(ColumnConstraintKind):
    -1014    pass
    +            
    1012class CollateColumnConstraint(ColumnConstraintKind):
    +1013    pass
     
    @@ -12957,8 +13114,8 @@ If an Expression instance is passed, it w
    -
    1017class CommentColumnConstraint(ColumnConstraintKind):
    -1018    pass
    +            
    1016class CommentColumnConstraint(ColumnConstraintKind):
    +1017    pass
     
    @@ -13021,8 +13178,8 @@ If an Expression instance is passed, it w
    -
    1021class CompressColumnConstraint(ColumnConstraintKind):
    -1022    pass
    +            
    1020class CompressColumnConstraint(ColumnConstraintKind):
    +1021    pass
     
    @@ -13085,8 +13242,8 @@ If an Expression instance is passed, it w
    -
    1025class DateFormatColumnConstraint(ColumnConstraintKind):
    -1026    arg_types = {"this": True}
    +            
    1024class DateFormatColumnConstraint(ColumnConstraintKind):
    +1025    arg_types = {"this": True}
     
    @@ -13149,8 +13306,8 @@ If an Expression instance is passed, it w
    -
    1029class DefaultColumnConstraint(ColumnConstraintKind):
    -1030    pass
    +            
    1028class DefaultColumnConstraint(ColumnConstraintKind):
    +1029    pass
     
    @@ -13213,8 +13370,8 @@ If an Expression instance is passed, it w
    -
    1033class EncodeColumnConstraint(ColumnConstraintKind):
    -1034    pass
    +            
    1032class EncodeColumnConstraint(ColumnConstraintKind):
    +1033    pass
     
    @@ -13277,16 +13434,16 @@ If an Expression instance is passed, it w
    -
    1037class GeneratedAsIdentityColumnConstraint(ColumnConstraintKind):
    -1038    # this: True -> ALWAYS, this: False -> BY DEFAULT
    -1039    arg_types = {
    -1040        "this": False,
    -1041        "start": False,
    -1042        "increment": False,
    -1043        "minvalue": False,
    -1044        "maxvalue": False,
    -1045        "cycle": False,
    -1046    }
    +            
    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    }
     
    @@ -13349,8 +13506,8 @@ If an Expression instance is passed, it w
    -
    1049class InlineLengthColumnConstraint(ColumnConstraintKind):
    -1050    pass
    +            
    1048class InlineLengthColumnConstraint(ColumnConstraintKind):
    +1049    pass
     
    @@ -13413,8 +13570,8 @@ If an Expression instance is passed, it w
    -
    1053class NotNullColumnConstraint(ColumnConstraintKind):
    -1054    arg_types = {"allow_null": False}
    +            
    1052class NotNullColumnConstraint(ColumnConstraintKind):
    +1053    arg_types = {"allow_null": False}
     
    @@ -13462,6 +13619,70 @@ If an Expression instance is passed, it w
    dump
    load
    +
    + + + +
    + +
    + + class + OnUpdateColumnConstraint(ColumnConstraintKind): + + + +
    + +
    1057class OnUpdateColumnConstraint(ColumnConstraintKind):
    +1058    pass
    +
    + + + + + @@ -13477,8 +13698,8 @@ If an Expression instance is passed, it w -
    1057class PrimaryKeyColumnConstraint(ColumnConstraintKind):
    -1058    arg_types = {"desc": False}
    +            
    1061class PrimaryKeyColumnConstraint(ColumnConstraintKind):
    +1062    arg_types = {"desc": False}
     
    @@ -13541,8 +13762,8 @@ If an Expression instance is passed, it w
    -
    1061class TitleColumnConstraint(ColumnConstraintKind):
    -1062    pass
    +            
    1065class TitleColumnConstraint(ColumnConstraintKind):
    +1066    pass
     
    @@ -13605,8 +13826,8 @@ If an Expression instance is passed, it w
    -
    1065class UniqueColumnConstraint(ColumnConstraintKind):
    -1066    arg_types: t.Dict[str, t.Any] = {}
    +            
    1069class UniqueColumnConstraint(ColumnConstraintKind):
    +1070    arg_types: t.Dict[str, t.Any] = {}
     
    @@ -13669,8 +13890,8 @@ If an Expression instance is passed, it w
    -
    1069class UppercaseColumnConstraint(ColumnConstraintKind):
    -1070    arg_types: t.Dict[str, t.Any] = {}
    +            
    1073class UppercaseColumnConstraint(ColumnConstraintKind):
    +1074    arg_types: t.Dict[str, t.Any] = {}
     
    @@ -13733,8 +13954,8 @@ If an Expression instance is passed, it w
    -
    1073class PathColumnConstraint(ColumnConstraintKind):
    -1074    pass
    +            
    1077class PathColumnConstraint(ColumnConstraintKind):
    +1078    pass
     
    @@ -13797,8 +14018,8 @@ If an Expression instance is passed, it w
    -
    1077class Constraint(Expression):
    -1078    arg_types = {"this": True, "expressions": True}
    +            
    1081class Constraint(Expression):
    +1082    arg_types = {"this": True, "expressions": True}
     
    @@ -13861,115 +14082,115 @@ If an Expression instance is passed, it w
    -
    1081class Delete(Expression):
    -1082    arg_types = {"with": False, "this": False, "using": False, "where": False, "returning": False}
    -1083
    -1084    def delete(
    -1085        self,
    -1086        table: ExpOrStr,
    -1087        dialect: DialectType = None,
    -1088        copy: bool = True,
    -1089        **opts,
    -1090    ) -> Delete:
    -1091        """
    -1092        Create a DELETE expression or replace the table on an existing DELETE expression.
    -1093
    -1094        Example:
    -1095            >>> delete("tbl").sql()
    -1096            'DELETE FROM tbl'
    +            
    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        Args:
    -1099            table: the table from which to delete.
    -1100            dialect: the dialect used to parse the input expression.
    -1101            copy: if `False`, modify this expression instance in-place.
    -1102            opts: other options to use to parse the input expressions.
    -1103
    -1104        Returns:
    -1105            Delete: the modified expression.
    -1106        """
    -1107        return _apply_builder(
    -1108            expression=table,
    -1109            instance=self,
    -1110            arg="this",
    -1111            dialect=dialect,
    -1112            into=Table,
    -1113            copy=copy,
    -1114            **opts,
    -1115        )
    -1116
    -1117    def where(
    -1118        self,
    -1119        *expressions: ExpOrStr,
    -1120        append: bool = True,
    -1121        dialect: DialectType = None,
    -1122        copy: bool = True,
    -1123        **opts,
    -1124    ) -> Delete:
    -1125        """
    -1126        Append to or set the WHERE expressions.
    -1127
    -1128        Example:
    -1129            >>> delete("tbl").where("x = 'a' OR x < 'b'").sql()
    -1130            "DELETE FROM tbl WHERE x = 'a' OR x < 'b'"
    +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        Args:
    -1133            *expressions: the SQL code strings to parse.
    -1134                If an `Expression` instance is passed, it will be used as-is.
    -1135                Multiple expressions are combined with an AND operator.
    -1136            append: if `True`, AND the new expressions to any existing expression.
    -1137                Otherwise, this resets the expression.
    -1138            dialect: the dialect used to parse the input expressions.
    -1139            copy: if `False`, modify this expression instance in-place.
    -1140            opts: other options to use to parse the input expressions.
    -1141
    -1142        Returns:
    -1143            Delete: the modified expression.
    -1144        """
    -1145        return _apply_conjunction_builder(
    -1146            *expressions,
    -1147            instance=self,
    -1148            arg="where",
    -1149            append=append,
    -1150            into=Where,
    -1151            dialect=dialect,
    -1152            copy=copy,
    -1153            **opts,
    -1154        )
    -1155
    -1156    def returning(
    -1157        self,
    -1158        expression: ExpOrStr,
    -1159        dialect: DialectType = None,
    -1160        copy: bool = True,
    -1161        **opts,
    -1162    ) -> Delete:
    -1163        """
    -1164        Set the RETURNING expression. Not supported by all dialects.
    -1165
    -1166        Example:
    -1167            >>> delete("tbl").returning("*", dialect="postgres").sql()
    -1168            'DELETE FROM tbl RETURNING *'
    +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        Args:
    -1171            expression: the SQL code strings to parse.
    -1172                If an `Expression` instance is passed, it will be used as-is.
    -1173            dialect: the dialect used to parse the input expressions.
    -1174            copy: if `False`, modify this expression instance in-place.
    -1175            opts: other options to use to parse the input expressions.
    -1176
    -1177        Returns:
    -1178            Delete: the modified expression.
    -1179        """
    -1180        return _apply_builder(
    -1181            expression=expression,
    -1182            instance=self,
    -1183            arg="returning",
    -1184            prefix="RETURNING",
    -1185            dialect=dialect,
    -1186            copy=copy,
    -1187            into=Returning,
    -1188            **opts,
    -1189        )
    +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        )
     
    @@ -13986,38 +14207,38 @@ If an Expression instance is passed, it w
    -
    1084    def delete(
    -1085        self,
    -1086        table: ExpOrStr,
    -1087        dialect: DialectType = None,
    -1088        copy: bool = True,
    -1089        **opts,
    -1090    ) -> Delete:
    -1091        """
    -1092        Create a DELETE expression or replace the table on an existing DELETE expression.
    -1093
    -1094        Example:
    -1095            >>> delete("tbl").sql()
    -1096            'DELETE FROM tbl'
    +            
    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        Args:
    -1099            table: the table from which to delete.
    -1100            dialect: the dialect used to parse the input expression.
    -1101            copy: if `False`, modify this expression instance in-place.
    -1102            opts: other options to use to parse the input expressions.
    -1103
    -1104        Returns:
    -1105            Delete: the modified expression.
    -1106        """
    -1107        return _apply_builder(
    -1108            expression=table,
    -1109            instance=self,
    -1110            arg="this",
    -1111            dialect=dialect,
    -1112            into=Table,
    -1113            copy=copy,
    -1114            **opts,
    -1115        )
    +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        )
     
    @@ -14062,44 +14283,44 @@ If an Expression instance is passed, it w
    -
    1117    def where(
    -1118        self,
    -1119        *expressions: ExpOrStr,
    -1120        append: bool = True,
    -1121        dialect: DialectType = None,
    -1122        copy: bool = True,
    -1123        **opts,
    -1124    ) -> Delete:
    -1125        """
    -1126        Append to or set the WHERE expressions.
    -1127
    -1128        Example:
    -1129            >>> delete("tbl").where("x = 'a' OR x < 'b'").sql()
    -1130            "DELETE FROM tbl WHERE x = 'a' OR x < 'b'"
    +            
    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        Args:
    -1133            *expressions: the SQL code strings to parse.
    -1134                If an `Expression` instance is passed, it will be used as-is.
    -1135                Multiple expressions are combined with an AND operator.
    -1136            append: if `True`, AND the new expressions to any existing expression.
    -1137                Otherwise, this resets the expression.
    -1138            dialect: the dialect used to parse the input expressions.
    -1139            copy: if `False`, modify this expression instance in-place.
    -1140            opts: other options to use to parse the input expressions.
    -1141
    -1142        Returns:
    -1143            Delete: the modified expression.
    -1144        """
    -1145        return _apply_conjunction_builder(
    -1146            *expressions,
    -1147            instance=self,
    -1148            arg="where",
    -1149            append=append,
    -1150            into=Where,
    -1151            dialect=dialect,
    -1152            copy=copy,
    -1153            **opts,
    -1154        )
    +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        )
     
    @@ -14148,40 +14369,40 @@ Otherwise, this resets the expression.
  • -
    1156    def returning(
    -1157        self,
    -1158        expression: ExpOrStr,
    -1159        dialect: DialectType = None,
    -1160        copy: bool = True,
    -1161        **opts,
    -1162    ) -> Delete:
    -1163        """
    -1164        Set the RETURNING expression. Not supported by all dialects.
    -1165
    -1166        Example:
    -1167            >>> delete("tbl").returning("*", dialect="postgres").sql()
    -1168            'DELETE FROM tbl RETURNING *'
    +            
    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        Args:
    -1171            expression: the SQL code strings to parse.
    -1172                If an `Expression` instance is passed, it will be used as-is.
    -1173            dialect: the dialect used to parse the input expressions.
    -1174            copy: if `False`, modify this expression instance in-place.
    -1175            opts: other options to use to parse the input expressions.
    -1176
    -1177        Returns:
    -1178            Delete: the modified expression.
    -1179        """
    -1180        return _apply_builder(
    -1181            expression=expression,
    -1182            instance=self,
    -1183            arg="returning",
    -1184            prefix="RETURNING",
    -1185            dialect=dialect,
    -1186            copy=copy,
    -1187            into=Returning,
    -1188            **opts,
    -1189        )
    +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        )
     
    @@ -14273,16 +14494,17 @@ If an Expression instance is passed, it w
    -
    1192class Drop(Expression):
    -1193    arg_types = {
    -1194        "this": False,
    -1195        "kind": False,
    -1196        "exists": False,
    -1197        "temporary": False,
    -1198        "materialized": False,
    -1199        "cascade": False,
    -1200        "constraints": False,
    -1201    }
    +            
    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    }
     
    @@ -14345,8 +14567,8 @@ If an Expression instance is passed, it w
    -
    1204class Filter(Expression):
    -1205    arg_types = {"this": True, "expression": True}
    +            
    1209class Filter(Expression):
    +1210    arg_types = {"this": True, "expression": True}
     
    @@ -14409,8 +14631,8 @@ If an Expression instance is passed, it w
    -
    1208class Check(Expression):
    -1209    pass
    +            
    1213class Check(Expression):
    +1214    pass
     
    @@ -14473,9 +14695,9 @@ If an Expression instance is passed, it w
    -
    1212class Directory(Expression):
    -1213    # https://spark.apache.org/docs/3.0.0-preview/sql-ref-syntax-dml-insert-overwrite-directory-hive.html
    -1214    arg_types = {"this": True, "local": False, "row_format": False}
    +            
    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}
     
    @@ -14538,13 +14760,13 @@ If an Expression instance is passed, it w
    -
    1217class ForeignKey(Expression):
    -1218    arg_types = {
    -1219        "expressions": True,
    -1220        "reference": False,
    -1221        "delete": False,
    -1222        "update": False,
    -1223    }
    +            
    1222class ForeignKey(Expression):
    +1223    arg_types = {
    +1224        "expressions": True,
    +1225        "reference": False,
    +1226        "delete": False,
    +1227        "update": False,
    +1228    }
     
    @@ -14607,8 +14829,8 @@ If an Expression instance is passed, it w
    -
    1226class PrimaryKey(Expression):
    -1227    arg_types = {"expressions": True, "options": False}
    +            
    1231class PrimaryKey(Expression):
    +1232    arg_types = {"expressions": True, "options": False}
     
    @@ -14671,8 +14893,8 @@ If an Expression instance is passed, it w
    -
    1230class Unique(Expression):
    -1231    arg_types = {"expressions": True}
    +            
    1235class Unique(Expression):
    +1236    arg_types = {"expressions": True}
     
    @@ -14735,8 +14957,8 @@ If an Expression instance is passed, it w
    -
    1236class Into(Expression):
    -1237    arg_types = {"this": True, "temporary": False, "unlogged": False}
    +            
    1241class Into(Expression):
    +1242    arg_types = {"this": True, "temporary": False, "unlogged": False}
     
    @@ -14799,8 +15021,8 @@ If an Expression instance is passed, it w
    -
    1240class From(Expression):
    -1241    arg_types = {"expressions": True}
    +            
    1245class From(Expression):
    +1246    arg_types = {"expressions": True}
     
    @@ -14863,8 +15085,8 @@ If an Expression instance is passed, it w
    -
    1244class Having(Expression):
    -1245    pass
    +            
    1249class Having(Expression):
    +1250    pass
     
    @@ -14927,8 +15149,8 @@ If an Expression instance is passed, it w
    -
    1248class Hint(Expression):
    -1249    arg_types = {"expressions": True}
    +            
    1253class Hint(Expression):
    +1254    arg_types = {"expressions": True}
     
    @@ -14991,8 +15213,8 @@ If an Expression instance is passed, it w
    -
    1252class JoinHint(Expression):
    -1253    arg_types = {"this": True, "expressions": True}
    +            
    1257class JoinHint(Expression):
    +1258    arg_types = {"this": True, "expressions": True}
     
    @@ -15055,22 +15277,22 @@ If an Expression instance is passed, it w
    -
    1256class Identifier(Expression):
    -1257    arg_types = {"this": True, "quoted": False}
    -1258
    -1259    @property
    -1260    def quoted(self):
    -1261        return bool(self.args.get("quoted"))
    -1262
    -1263    @property
    -1264    def hashable_args(self) -> t.Any:
    -1265        if self.quoted and any(char.isupper() for char in self.this):
    -1266            return (self.this, self.quoted)
    -1267        return self.this.lower()
    -1268
    -1269    @property
    -1270    def output_name(self):
    -1271        return self.name
    +            
    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
     
    @@ -15162,16 +15384,16 @@ If an Expression instance is passed, it w
    -
    1274class Index(Expression):
    -1275    arg_types = {
    -1276        "this": False,
    -1277        "table": False,
    -1278        "where": False,
    -1279        "columns": False,
    -1280        "unique": False,
    -1281        "primary": False,
    -1282        "amp": False,  # teradata
    -1283    }
    +            
    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    }
     
    @@ -15234,17 +15456,18 @@ If an Expression instance is passed, it w
    -
    1286class Insert(Expression):
    -1287    arg_types = {
    -1288        "with": False,
    -1289        "this": True,
    -1290        "expression": False,
    -1291        "returning": False,
    -1292        "overwrite": False,
    -1293        "exists": False,
    -1294        "partition": False,
    -1295        "alternative": False,
    -1296    }
    +            
    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    }
     
    @@ -15292,6 +15515,76 @@ If an Expression instance is passed, it w
    dump
    load
    +
    + + + +
    + +
    + + class + OnConflict(Expression): + + + +
    + +
    1305class OnConflict(Expression):
    +1306    arg_types = {
    +1307        "duplicate": False,
    +1308        "expressions": False,
    +1309        "nothing": False,
    +1310        "key": False,
    +1311        "constraint": False,
    +1312    }
    +
    + + + + + @@ -15307,8 +15600,8 @@ If an Expression instance is passed, it w -
    1299class Returning(Expression):
    -1300    arg_types = {"expressions": True}
    +            
    1315class Returning(Expression):
    +1316    arg_types = {"expressions": True}
     
    @@ -15371,8 +15664,8 @@ If an Expression instance is passed, it w
    -
    1304class Introducer(Expression):
    -1305    arg_types = {"this": True, "expression": True}
    +            
    1320class Introducer(Expression):
    +1321    arg_types = {"this": True, "expression": True}
     
    @@ -15435,8 +15728,8 @@ If an Expression instance is passed, it w
    -
    1309class National(Expression):
    -1310    pass
    +            
    1325class National(Expression):
    +1326    pass
     
    @@ -15499,16 +15792,16 @@ If an Expression instance is passed, it w
    -
    1313class LoadData(Expression):
    -1314    arg_types = {
    -1315        "this": True,
    -1316        "local": False,
    -1317        "overwrite": False,
    -1318        "inpath": True,
    -1319        "partition": False,
    -1320        "input_format": False,
    -1321        "serde": False,
    -1322    }
    +            
    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    }
     
    @@ -15571,8 +15864,8 @@ If an Expression instance is passed, it w
    -
    1325class Partition(Expression):
    -1326    arg_types = {"expressions": True}
    +            
    1341class Partition(Expression):
    +1342    arg_types = {"expressions": True}
     
    @@ -15635,8 +15928,13 @@ If an Expression instance is passed, it w
    -
    1329class Fetch(Expression):
    -1330    arg_types = {"direction": False, "count": False}
    +            
    1345class Fetch(Expression):
    +1346    arg_types = {
    +1347        "direction": False,
    +1348        "count": False,
    +1349        "percent": False,
    +1350        "with_ties": False,
    +1351    }
     
    @@ -15699,13 +15997,13 @@ If an Expression instance is passed, it w
    -
    1333class Group(Expression):
    -1334    arg_types = {
    -1335        "expressions": False,
    -1336        "grouping_sets": False,
    -1337        "cube": False,
    -1338        "rollup": False,
    -1339    }
    +            
    1354class Group(Expression):
    +1355    arg_types = {
    +1356        "expressions": False,
    +1357        "grouping_sets": False,
    +1358        "cube": False,
    +1359        "rollup": False,
    +1360    }
     
    @@ -15768,8 +16066,8 @@ If an Expression instance is passed, it w
    -
    1342class Lambda(Expression):
    -1343    arg_types = {"this": True, "expressions": True}
    +            
    1363class Lambda(Expression):
    +1364    arg_types = {"this": True, "expressions": True}
     
    @@ -15832,8 +16130,8 @@ If an Expression instance is passed, it w
    -
    1346class Limit(Expression):
    -1347    arg_types = {"this": False, "expression": True}
    +            
    1367class Limit(Expression):
    +1368    arg_types = {"this": False, "expression": True}
     
    @@ -15896,24 +16194,24 @@ If an Expression instance is passed, it w
    -
    1350class Literal(Condition):
    -1351    arg_types = {"this": True, "is_string": True}
    -1352
    -1353    @property
    -1354    def hashable_args(self) -> t.Any:
    -1355        return (self.this, self.args.get("is_string"))
    -1356
    -1357    @classmethod
    -1358    def number(cls, number) -> Literal:
    -1359        return cls(this=str(number), is_string=False)
    -1360
    -1361    @classmethod
    -1362    def string(cls, string) -> Literal:
    -1363        return cls(this=str(string), is_string=True)
    -1364
    -1365    @property
    -1366    def output_name(self):
    -1367        return self.name
    +            
    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
     
    @@ -15931,9 +16229,9 @@ If an Expression instance is passed, it w
    -
    1357    @classmethod
    -1358    def number(cls, number) -> Literal:
    -1359        return cls(this=str(number), is_string=False)
    +            
    1378    @classmethod
    +1379    def number(cls, number) -> Literal:
    +1380        return cls(this=str(number), is_string=False)
     
    @@ -15952,9 +16250,9 @@ If an Expression instance is passed, it w
    -
    1361    @classmethod
    -1362    def string(cls, string) -> Literal:
    -1363        return cls(this=str(string), is_string=True)
    +            
    1382    @classmethod
    +1383    def string(cls, string) -> Literal:
    +1384        return cls(this=str(string), is_string=True)
     
    @@ -16053,100 +16351,105 @@ If an Expression instance is passed, it w
    -
    1370class Join(Expression):
    -1371    arg_types = {
    -1372        "this": True,
    -1373        "on": False,
    -1374        "side": False,
    -1375        "kind": False,
    -1376        "using": False,
    -1377        "natural": False,
    -1378    }
    -1379
    -1380    @property
    -1381    def kind(self):
    -1382        return self.text("kind").upper()
    -1383
    -1384    @property
    -1385    def side(self):
    -1386        return self.text("side").upper()
    -1387
    -1388    @property
    -1389    def alias_or_name(self):
    -1390        return self.this.alias_or_name
    -1391
    -1392    def on(self, *expressions, append=True, dialect=None, copy=True, **opts):
    -1393        """
    -1394        Append to or set the ON expressions.
    -1395
    -1396        Example:
    -1397            >>> import sqlglot
    -1398            >>> sqlglot.parse_one("JOIN x", into=Join).on("y = 1").sql()
    -1399            'JOIN x ON y = 1'
    -1400
    -1401        Args:
    -1402            *expressions (str | Expression): the SQL code strings to parse.
    -1403                If an `Expression` instance is passed, it will be used as-is.
    -1404                Multiple expressions are combined with an AND operator.
    -1405            append (bool): if `True`, AND the new expressions to any existing expression.
    -1406                Otherwise, this resets the expression.
    -1407            dialect (str): the dialect used to parse the input expressions.
    -1408            copy (bool): if `False`, modify this expression instance in-place.
    -1409            opts (kwargs): other options to use to parse the input expressions.
    -1410
    -1411        Returns:
    -1412            Join: the modified join expression.
    -1413        """
    -1414        join = _apply_conjunction_builder(
    -1415            *expressions,
    -1416            instance=self,
    -1417            arg="on",
    -1418            append=append,
    -1419            dialect=dialect,
    -1420            copy=copy,
    -1421            **opts,
    -1422        )
    -1423
    -1424        if join.kind == "CROSS":
    -1425            join.set("kind", None)
    +            
    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        return join
    -1428
    -1429    def using(self, *expressions, append=True, dialect=None, copy=True, **opts):
    -1430        """
    -1431        Append to or set the USING expressions.
    -1432
    -1433        Example:
    -1434            >>> import sqlglot
    -1435            >>> sqlglot.parse_one("JOIN x", into=Join).using("foo", "bla").sql()
    -1436            'JOIN x USING (foo, bla)'
    -1437
    -1438        Args:
    -1439            *expressions (str | Expression): the SQL code strings to parse.
    -1440                If an `Expression` instance is passed, it will be used as-is.
    -1441            append (bool): if `True`, concatenate the new expressions to the existing "using" list.
    -1442                Otherwise, this resets the expression.
    -1443            dialect (str): the dialect used to parse the input expressions.
    -1444            copy (bool): if `False`, modify this expression instance in-place.
    -1445            opts (kwargs): other options to use to parse the input expressions.
    -1446
    -1447        Returns:
    -1448            Join: the modified join expression.
    -1449        """
    -1450        join = _apply_list_builder(
    -1451            *expressions,
    -1452            instance=self,
    -1453            arg="using",
    -1454            append=append,
    -1455            dialect=dialect,
    -1456            copy=copy,
    -1457            **opts,
    -1458        )
    -1459
    -1460        if join.kind == "CROSS":
    -1461            join.set("kind", None)
    -1462
    -1463        return join
    +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
     
    @@ -16163,42 +16466,42 @@ If an Expression instance is passed, it w
    -
    1392    def on(self, *expressions, append=True, dialect=None, copy=True, **opts):
    -1393        """
    -1394        Append to or set the ON expressions.
    -1395
    -1396        Example:
    -1397            >>> import sqlglot
    -1398            >>> sqlglot.parse_one("JOIN x", into=Join).on("y = 1").sql()
    -1399            'JOIN x ON y = 1'
    -1400
    -1401        Args:
    -1402            *expressions (str | Expression): the SQL code strings to parse.
    -1403                If an `Expression` instance is passed, it will be used as-is.
    -1404                Multiple expressions are combined with an AND operator.
    -1405            append (bool): if `True`, AND the new expressions to any existing expression.
    -1406                Otherwise, this resets the expression.
    -1407            dialect (str): the dialect used to parse the input expressions.
    -1408            copy (bool): if `False`, modify this expression instance in-place.
    -1409            opts (kwargs): other options to use to parse the input expressions.
    -1410
    -1411        Returns:
    -1412            Join: the modified join expression.
    -1413        """
    -1414        join = _apply_conjunction_builder(
    -1415            *expressions,
    -1416            instance=self,
    -1417            arg="on",
    -1418            append=append,
    -1419            dialect=dialect,
    -1420            copy=copy,
    -1421            **opts,
    -1422        )
    -1423
    -1424        if join.kind == "CROSS":
    -1425            join.set("kind", None)
    +            
    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        return join
    +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
     
    @@ -16248,41 +16551,41 @@ Otherwise, this resets the expression.
    -
    1429    def using(self, *expressions, append=True, dialect=None, copy=True, **opts):
    -1430        """
    -1431        Append to or set the USING expressions.
    -1432
    -1433        Example:
    -1434            >>> import sqlglot
    -1435            >>> sqlglot.parse_one("JOIN x", into=Join).using("foo", "bla").sql()
    -1436            'JOIN x USING (foo, bla)'
    -1437
    -1438        Args:
    -1439            *expressions (str | Expression): the SQL code strings to parse.
    -1440                If an `Expression` instance is passed, it will be used as-is.
    -1441            append (bool): if `True`, concatenate the new expressions to the existing "using" list.
    -1442                Otherwise, this resets the expression.
    -1443            dialect (str): the dialect used to parse the input expressions.
    -1444            copy (bool): if `False`, modify this expression instance in-place.
    -1445            opts (kwargs): other options to use to parse the input expressions.
    -1446
    -1447        Returns:
    -1448            Join: the modified join expression.
    -1449        """
    -1450        join = _apply_list_builder(
    -1451            *expressions,
    -1452            instance=self,
    -1453            arg="using",
    -1454            append=append,
    -1455            dialect=dialect,
    -1456            copy=copy,
    -1457            **opts,
    -1458        )
    -1459
    -1460        if join.kind == "CROSS":
    -1461            join.set("kind", None)
    -1462
    -1463        return join
    +            
    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
     
    @@ -16377,8 +16680,8 @@ Otherwise, this resets the expression.
    -
    1466class Lateral(UDTF):
    -1467    arg_types = {"this": True, "view": False, "outer": False, "alias": False}
    +            
    1492class Lateral(UDTF):
    +1493    arg_types = {"this": True, "view": False, "outer": False, "alias": False}
     
    @@ -16447,16 +16750,17 @@ Otherwise, this resets the expression.
    -
    1470class MatchRecognize(Expression):
    -1471    arg_types = {
    -1472        "partition_by": False,
    -1473        "order": False,
    -1474        "measures": False,
    -1475        "rows": False,
    -1476        "after": False,
    -1477        "pattern": False,
    -1478        "define": False,
    -1479    }
    +            
    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    }
     
    @@ -16519,8 +16823,8 @@ Otherwise, this resets the expression.
    -
    1484class Final(Expression):
    -1485    pass
    +            
    1511class Final(Expression):
    +1512    pass
     
    @@ -16583,8 +16887,8 @@ Otherwise, this resets the expression.
    -
    1488class Offset(Expression):
    -1489    arg_types = {"this": False, "expression": True}
    +            
    1515class Offset(Expression):
    +1516    arg_types = {"this": False, "expression": True}
     
    @@ -16647,8 +16951,8 @@ Otherwise, this resets the expression.
    -
    1492class Order(Expression):
    -1493    arg_types = {"this": False, "expressions": True}
    +            
    1519class Order(Expression):
    +1520    arg_types = {"this": False, "expressions": True}
     
    @@ -16711,8 +17015,8 @@ Otherwise, this resets the expression.
    -
    1498class Cluster(Order):
    -1499    pass
    +            
    1525class Cluster(Order):
    +1526    pass
     
    @@ -16775,8 +17079,8 @@ Otherwise, this resets the expression.
    -
    1502class Distribute(Order):
    -1503    pass
    +            
    1529class Distribute(Order):
    +1530    pass
     
    @@ -16839,8 +17143,8 @@ Otherwise, this resets the expression.
    -
    1506class Sort(Order):
    -1507    pass
    +            
    1533class Sort(Order):
    +1534    pass
     
    @@ -16903,8 +17207,8 @@ Otherwise, this resets the expression.
    -
    1510class Ordered(Expression):
    -1511    arg_types = {"this": True, "desc": True, "nulls_first": True}
    +            
    1537class Ordered(Expression):
    +1538    arg_types = {"this": True, "desc": True, "nulls_first": True}
     
    @@ -16967,8 +17271,8 @@ Otherwise, this resets the expression.
    -
    1514class Property(Expression):
    -1515    arg_types = {"this": True, "value": True}
    +            
    1541class Property(Expression):
    +1542    arg_types = {"this": True, "value": True}
     
    @@ -17031,8 +17335,8 @@ Otherwise, this resets the expression.
    -
    1518class AfterJournalProperty(Property):
    -1519    arg_types = {"no": True, "dual": False, "local": False}
    +            
    1545class AfterJournalProperty(Property):
    +1546    arg_types = {"no": True, "dual": False, "local": False}
     
    @@ -17095,8 +17399,8 @@ Otherwise, this resets the expression.
    -
    1522class AlgorithmProperty(Property):
    -1523    arg_types = {"this": True}
    +            
    1549class AlgorithmProperty(Property):
    +1550    arg_types = {"this": True}
     
    @@ -17159,8 +17463,8 @@ Otherwise, this resets the expression.
    -
    1526class AutoIncrementProperty(Property):
    -1527    arg_types = {"this": True}
    +            
    1553class AutoIncrementProperty(Property):
    +1554    arg_types = {"this": True}
     
    @@ -17223,8 +17527,8 @@ Otherwise, this resets the expression.
    -
    1530class BlockCompressionProperty(Property):
    -1531    arg_types = {"autotemp": False, "always": False, "default": True, "manual": True, "never": True}
    +            
    1557class BlockCompressionProperty(Property):
    +1558    arg_types = {"autotemp": False, "always": False, "default": True, "manual": True, "never": True}
     
    @@ -17287,8 +17591,8 @@ Otherwise, this resets the expression.
    -
    1534class CharacterSetProperty(Property):
    -1535    arg_types = {"this": True, "default": True}
    +            
    1561class CharacterSetProperty(Property):
    +1562    arg_types = {"this": True, "default": True}
     
    @@ -17351,8 +17655,8 @@ Otherwise, this resets the expression.
    -
    1538class ChecksumProperty(Property):
    -1539    arg_types = {"on": False, "default": False}
    +            
    1565class ChecksumProperty(Property):
    +1566    arg_types = {"on": False, "default": False}
     
    @@ -17415,8 +17719,8 @@ Otherwise, this resets the expression.
    -
    1542class CollateProperty(Property):
    -1543    arg_types = {"this": True}
    +            
    1569class CollateProperty(Property):
    +1570    arg_types = {"this": True}
     
    @@ -17479,8 +17783,8 @@ Otherwise, this resets the expression.
    -
    1546class DataBlocksizeProperty(Property):
    -1547    arg_types = {"size": False, "units": False, "min": False, "default": False}
    +            
    1573class DataBlocksizeProperty(Property):
    +1574    arg_types = {"size": False, "units": False, "min": False, "default": False}
     
    @@ -17543,8 +17847,8 @@ Otherwise, this resets the expression.
    -
    1550class DefinerProperty(Property):
    -1551    arg_types = {"this": True}
    +            
    1577class DefinerProperty(Property):
    +1578    arg_types = {"this": True}
     
    @@ -17607,8 +17911,8 @@ Otherwise, this resets the expression.
    -
    1554class DistKeyProperty(Property):
    -1555    arg_types = {"this": True}
    +            
    1581class DistKeyProperty(Property):
    +1582    arg_types = {"this": True}
     
    @@ -17671,8 +17975,8 @@ Otherwise, this resets the expression.
    -
    1558class DistStyleProperty(Property):
    -1559    arg_types = {"this": True}
    +            
    1585class DistStyleProperty(Property):
    +1586    arg_types = {"this": True}
     
    @@ -17735,8 +18039,8 @@ Otherwise, this resets the expression.
    -
    1562class EngineProperty(Property):
    -1563    arg_types = {"this": True}
    +            
    1589class EngineProperty(Property):
    +1590    arg_types = {"this": True}
     
    @@ -17799,8 +18103,8 @@ Otherwise, this resets the expression.
    -
    1566class ExecuteAsProperty(Property):
    -1567    arg_types = {"this": True}
    +            
    1593class ExecuteAsProperty(Property):
    +1594    arg_types = {"this": True}
     
    @@ -17863,8 +18167,8 @@ Otherwise, this resets the expression.
    -
    1570class ExternalProperty(Property):
    -1571    arg_types = {"this": False}
    +            
    1597class ExternalProperty(Property):
    +1598    arg_types = {"this": False}
     
    @@ -17927,8 +18231,8 @@ Otherwise, this resets the expression.
    -
    1574class FallbackProperty(Property):
    -1575    arg_types = {"no": True, "protection": False}
    +            
    1601class FallbackProperty(Property):
    +1602    arg_types = {"no": True, "protection": False}
     
    @@ -17991,8 +18295,8 @@ Otherwise, this resets the expression.
    -
    1578class FileFormatProperty(Property):
    -1579    arg_types = {"this": True}
    +            
    1605class FileFormatProperty(Property):
    +1606    arg_types = {"this": True}
     
    @@ -18055,8 +18359,8 @@ Otherwise, this resets the expression.
    -
    1582class FreespaceProperty(Property):
    -1583    arg_types = {"this": True, "percent": False}
    +            
    1609class FreespaceProperty(Property):
    +1610    arg_types = {"this": True, "percent": False}
     
    @@ -18104,6 +18408,70 @@ Otherwise, this resets the expression.
    dump
    load
    +
    + + +
    +
    + +
    + + class + InputOutputFormat(Expression): + + + +
    + +
    1613class InputOutputFormat(Expression):
    +1614    arg_types = {"input_format": False, "output_format": False}
    +
    + + + + + @@ -18119,14 +18487,14 @@ Otherwise, this resets the expression. -
    1586class IsolatedLoadingProperty(Property):
    -1587    arg_types = {
    -1588        "no": True,
    -1589        "concurrent": True,
    -1590        "for_all": True,
    -1591        "for_insert": True,
    -1592        "for_none": True,
    -1593    }
    +            
    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    }
     
    @@ -18189,8 +18557,8 @@ Otherwise, this resets the expression.
    -
    1596class JournalProperty(Property):
    -1597    arg_types = {"no": True, "dual": False, "before": False}
    +            
    1627class JournalProperty(Property):
    +1628    arg_types = {"no": True, "dual": False, "before": False}
     
    @@ -18253,8 +18621,8 @@ Otherwise, this resets the expression.
    -
    1600class LanguageProperty(Property):
    -1601    arg_types = {"this": True}
    +            
    1631class LanguageProperty(Property):
    +1632    arg_types = {"this": True}
     
    @@ -18317,8 +18685,8 @@ Otherwise, this resets the expression.
    -
    1604class LikeProperty(Property):
    -1605    arg_types = {"this": True, "expressions": False}
    +            
    1635class LikeProperty(Property):
    +1636    arg_types = {"this": True, "expressions": False}
     
    @@ -18381,8 +18749,8 @@ Otherwise, this resets the expression.
    -
    1608class LocationProperty(Property):
    -1609    arg_types = {"this": True}
    +            
    1639class LocationProperty(Property):
    +1640    arg_types = {"this": True}
     
    @@ -18445,14 +18813,14 @@ Otherwise, this resets the expression.
    -
    1612class LockingProperty(Property):
    -1613    arg_types = {
    -1614        "this": False,
    -1615        "kind": True,
    -1616        "for_or_in": True,
    -1617        "lock_type": True,
    -1618        "override": False,
    -1619    }
    +            
    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    }
     
    @@ -18515,8 +18883,8 @@ Otherwise, this resets the expression.
    -
    1622class LogProperty(Property):
    -1623    arg_types = {"no": True}
    +            
    1653class LogProperty(Property):
    +1654    arg_types = {"no": True}
     
    @@ -18579,8 +18947,8 @@ Otherwise, this resets the expression.
    -
    1626class MaterializedProperty(Property):
    -1627    arg_types = {"this": False}
    +            
    1657class MaterializedProperty(Property):
    +1658    arg_types = {"this": False}
     
    @@ -18643,8 +19011,8 @@ Otherwise, this resets the expression.
    -
    1630class MergeBlockRatioProperty(Property):
    -1631    arg_types = {"this": False, "no": False, "default": False, "percent": False}
    +            
    1661class MergeBlockRatioProperty(Property):
    +1662    arg_types = {"this": False, "no": False, "default": False, "percent": False}
     
    @@ -18707,8 +19075,8 @@ Otherwise, this resets the expression.
    -
    1634class NoPrimaryIndexProperty(Property):
    -1635    arg_types = {"this": False}
    +            
    1665class NoPrimaryIndexProperty(Property):
    +1666    arg_types = {"this": False}
     
    @@ -18771,8 +19139,8 @@ Otherwise, this resets the expression.
    -
    1638class OnCommitProperty(Property):
    -1639    arg_type = {"this": False}
    +            
    1669class OnCommitProperty(Property):
    +1670    arg_type = {"this": False}
     
    @@ -18835,8 +19203,8 @@ Otherwise, this resets the expression.
    -
    1642class PartitionedByProperty(Property):
    -1643    arg_types = {"this": True}
    +            
    1673class PartitionedByProperty(Property):
    +1674    arg_types = {"this": True}
     
    @@ -18899,8 +19267,8 @@ Otherwise, this resets the expression.
    -
    1646class ReturnsProperty(Property):
    -1647    arg_types = {"this": True, "is_table": False, "table": False}
    +            
    1677class ReturnsProperty(Property):
    +1678    arg_types = {"this": True, "is_table": False, "table": False}
     
    @@ -18948,6 +19316,70 @@ Otherwise, this resets the expression.
    dump
    load
    +
    + + +
    +
    + +
    + + class + RowFormatProperty(Property): + + + +
    + +
    1681class RowFormatProperty(Property):
    +1682    arg_types = {"this": True}
    +
    + + + + + @@ -18963,17 +19395,17 @@ Otherwise, this resets the expression. -
    1650class RowFormatDelimitedProperty(Property):
    -1651    # https://cwiki.apache.org/confluence/display/hive/languagemanual+dml
    -1652    arg_types = {
    -1653        "fields": False,
    -1654        "escaped": False,
    -1655        "collection_items": False,
    -1656        "map_keys": False,
    -1657        "lines": False,
    -1658        "null": False,
    -1659        "serde": False,
    -1660    }
    +            
    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    }
     
    @@ -19036,8 +19468,8 @@ Otherwise, this resets the expression.
    -
    1663class RowFormatSerdeProperty(Property):
    -1664    arg_types = {"this": True}
    +            
    1698class RowFormatSerdeProperty(Property):
    +1699    arg_types = {"this": True}
     
    @@ -19100,8 +19532,8 @@ Otherwise, this resets the expression.
    -
    1667class SchemaCommentProperty(Property):
    -1668    arg_types = {"this": True}
    +            
    1702class SchemaCommentProperty(Property):
    +1703    arg_types = {"this": True}
     
    @@ -19164,8 +19596,8 @@ Otherwise, this resets the expression.
    -
    1671class SerdeProperties(Property):
    -1672    arg_types = {"expressions": True}
    +            
    1706class SerdeProperties(Property):
    +1707    arg_types = {"expressions": True}
     
    @@ -19228,8 +19660,8 @@ Otherwise, this resets the expression.
    -
    1675class SetProperty(Property):
    -1676    arg_types = {"multi": True}
    +            
    1710class SetProperty(Property):
    +1711    arg_types = {"multi": True}
     
    @@ -19292,8 +19724,8 @@ Otherwise, this resets the expression.
    -
    1679class SortKeyProperty(Property):
    -1680    arg_types = {"this": True, "compound": False}
    +            
    1714class SortKeyProperty(Property):
    +1715    arg_types = {"this": True, "compound": False}
     
    @@ -19356,8 +19788,8 @@ Otherwise, this resets the expression.
    -
    1683class SqlSecurityProperty(Property):
    -1684    arg_types = {"definer": True}
    +            
    1718class SqlSecurityProperty(Property):
    +1719    arg_types = {"definer": True}
     
    @@ -19405,6 +19837,70 @@ Otherwise, this resets the expression.
    dump
    load
    +
    + + +
    +
    + +
    + + class + StabilityProperty(Property): + + + +
    + +
    1722class StabilityProperty(Property):
    +1723    arg_types = {"this": True}
    +
    + + + + + @@ -19420,8 +19916,8 @@ Otherwise, this resets the expression. -
    1687class TableFormatProperty(Property):
    -1688    arg_types = {"this": True}
    +            
    1726class TableFormatProperty(Property):
    +1727    arg_types = {"this": True}
     
    @@ -19484,8 +19980,8 @@ Otherwise, this resets the expression.
    -
    1691class TemporaryProperty(Property):
    -1692    arg_types = {"global_": True}
    +            
    1730class TemporaryProperty(Property):
    +1731    arg_types = {"global_": True}
     
    @@ -19548,8 +20044,8 @@ Otherwise, this resets the expression.
    -
    1695class TransientProperty(Property):
    -1696    arg_types = {"this": False}
    +            
    1734class TransientProperty(Property):
    +1735    arg_types = {"this": False}
     
    @@ -19601,19 +20097,19 @@ Otherwise, this resets the expression.
    -
    - +
    +
    class - VolatilityProperty(Property): + VolatileProperty(Property): - +
    - -
    1699class VolatilityProperty(Property):
    -1700    arg_types = {"this": True}
    +    
    +            
    1738class VolatileProperty(Property):
    +1739    arg_types = {"this": False}
     
    @@ -19623,43 +20119,43 @@ Otherwise, this resets the expression.
    Inherited Members
    @@ -19676,8 +20172,8 @@ Otherwise, this resets the expression.
    -
    1703class WithDataProperty(Property):
    -1704    arg_types = {"no": True, "statistics": False}
    +            
    1742class WithDataProperty(Property):
    +1743    arg_types = {"no": True, "statistics": False}
     
    @@ -19740,8 +20236,8 @@ Otherwise, this resets the expression.
    -
    1707class WithJournalTableProperty(Property):
    -1708    arg_types = {"this": True}
    +            
    1746class WithJournalTableProperty(Property):
    +1747    arg_types = {"this": True}
     
    @@ -19804,65 +20300,66 @@ Otherwise, this resets the expression.
    -
    1711class Properties(Expression):
    -1712    arg_types = {"expressions": True}
    -1713
    -1714    NAME_TO_PROPERTY = {
    -1715        "ALGORITHM": AlgorithmProperty,
    -1716        "AUTO_INCREMENT": AutoIncrementProperty,
    -1717        "CHARACTER SET": CharacterSetProperty,
    -1718        "COLLATE": CollateProperty,
    -1719        "COMMENT": SchemaCommentProperty,
    -1720        "DEFINER": DefinerProperty,
    -1721        "DISTKEY": DistKeyProperty,
    -1722        "DISTSTYLE": DistStyleProperty,
    -1723        "ENGINE": EngineProperty,
    -1724        "EXECUTE AS": ExecuteAsProperty,
    -1725        "FORMAT": FileFormatProperty,
    -1726        "LANGUAGE": LanguageProperty,
    -1727        "LOCATION": LocationProperty,
    -1728        "PARTITIONED_BY": PartitionedByProperty,
    -1729        "RETURNS": ReturnsProperty,
    -1730        "SORTKEY": SortKeyProperty,
    -1731        "TABLE_FORMAT": TableFormatProperty,
    -1732    }
    -1733
    -1734    PROPERTY_TO_NAME = {v: k for k, v in NAME_TO_PROPERTY.items()}
    -1735
    -1736    # CREATE property locations
    -1737    # Form: schema specified
    -1738    #   create [POST_CREATE]
    -1739    #     table a [POST_NAME]
    -1740    #     (b int) [POST_SCHEMA]
    -1741    #     with ([POST_WITH])
    -1742    #     index (b) [POST_INDEX]
    -1743    #
    -1744    # Form: alias selection
    -1745    #   create [POST_CREATE]
    -1746    #     table a [POST_NAME]
    -1747    #     as [POST_ALIAS] (select * from b) [POST_EXPRESSION]
    -1748    #     index (c) [POST_INDEX]
    -1749    class Location(AutoName):
    -1750        POST_CREATE = auto()
    -1751        POST_NAME = auto()
    -1752        POST_SCHEMA = auto()
    -1753        POST_WITH = auto()
    -1754        POST_ALIAS = auto()
    -1755        POST_EXPRESSION = auto()
    -1756        POST_INDEX = auto()
    -1757        UNSUPPORTED = auto()
    -1758
    -1759    @classmethod
    -1760    def from_dict(cls, properties_dict) -> Properties:
    -1761        expressions = []
    -1762        for key, value in properties_dict.items():
    -1763            property_cls = cls.NAME_TO_PROPERTY.get(key.upper())
    -1764            if property_cls:
    -1765                expressions.append(property_cls(this=convert(value)))
    -1766            else:
    -1767                expressions.append(Property(this=Literal.string(key), value=convert(value)))
    -1768
    -1769        return cls(expressions=expressions)
    +            
    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)
     
    @@ -19880,17 +20377,17 @@ Otherwise, this resets the expression.
    -
    1759    @classmethod
    -1760    def from_dict(cls, properties_dict) -> Properties:
    -1761        expressions = []
    -1762        for key, value in properties_dict.items():
    -1763            property_cls = cls.NAME_TO_PROPERTY.get(key.upper())
    -1764            if property_cls:
    -1765                expressions.append(property_cls(this=convert(value)))
    -1766            else:
    -1767                expressions.append(Property(this=Literal.string(key), value=convert(value)))
    -1768
    -1769        return cls(expressions=expressions)
    +            
    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)
     
    @@ -19954,15 +20451,15 @@ Otherwise, this resets the expression.
    -
    1749    class Location(AutoName):
    -1750        POST_CREATE = auto()
    -1751        POST_NAME = auto()
    -1752        POST_SCHEMA = auto()
    -1753        POST_WITH = auto()
    -1754        POST_ALIAS = auto()
    -1755        POST_EXPRESSION = auto()
    -1756        POST_INDEX = auto()
    -1757        UNSUPPORTED = auto()
    +            
    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()
     
    @@ -20088,8 +20585,8 @@ Otherwise, this resets the expression.
    -
    1772class Qualify(Expression):
    -1773    pass
    +            
    1812class Qualify(Expression):
    +1813    pass
     
    @@ -20152,8 +20649,8 @@ Otherwise, this resets the expression.
    -
    1777class Return(Expression):
    -1778    pass
    +            
    1817class Return(Expression):
    +1818    pass
     
    @@ -20216,8 +20713,8 @@ Otherwise, this resets the expression.
    -
    1781class Reference(Expression):
    -1782    arg_types = {"this": True, "expressions": False, "options": False}
    +            
    1821class Reference(Expression):
    +1822    arg_types = {"this": True, "expressions": False, "options": False}
     
    @@ -20280,8 +20777,8 @@ Otherwise, this resets the expression.
    -
    1785class Tuple(Expression):
    -1786    arg_types = {"expressions": False}
    +            
    1825class Tuple(Expression):
    +1826    arg_types = {"expressions": False}
     
    @@ -20344,103 +20841,103 @@ Otherwise, this resets the expression.
    -
    1789class Subqueryable(Unionable):
    -1790    def subquery(self, alias=None, copy=True) -> Subquery:
    -1791        """
    -1792        Convert this expression to an aliased expression that can be used as a Subquery.
    -1793
    -1794        Example:
    -1795            >>> subquery = Select().select("x").from_("tbl").subquery()
    -1796            >>> Select().select("x").from_(subquery).sql()
    -1797            'SELECT x FROM (SELECT x FROM tbl)'
    -1798
    -1799        Args:
    -1800            alias (str | Identifier): an optional alias for the subquery
    -1801            copy (bool): if `False`, modify this expression instance in-place.
    -1802
    -1803        Returns:
    -1804            Alias: the subquery
    -1805        """
    -1806        instance = _maybe_copy(self, copy)
    -1807        return Subquery(
    -1808            this=instance,
    -1809            alias=TableAlias(this=to_identifier(alias)) if alias else None,
    -1810        )
    -1811
    -1812    def limit(self, expression, dialect=None, copy=True, **opts) -> Select:
    -1813        raise NotImplementedError
    -1814
    -1815    @property
    -1816    def ctes(self):
    -1817        with_ = self.args.get("with")
    -1818        if not with_:
    -1819            return []
    -1820        return with_.expressions
    -1821
    -1822    @property
    -1823    def selects(self):
    -1824        raise NotImplementedError("Subqueryable objects must implement `selects`")
    -1825
    -1826    @property
    -1827    def named_selects(self):
    -1828        raise NotImplementedError("Subqueryable objects must implement `named_selects`")
    -1829
    -1830    def with_(
    -1831        self,
    -1832        alias,
    -1833        as_,
    -1834        recursive=None,
    -1835        append=True,
    -1836        dialect=None,
    -1837        copy=True,
    -1838        **opts,
    -1839    ):
    -1840        """
    -1841        Append to or set the common table expressions.
    +            
    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        Example:
    -1844            >>> Select().with_("tbl2", as_="SELECT * FROM tbl").select("x").from_("tbl2").sql()
    -1845            'WITH tbl2 AS (SELECT * FROM tbl) SELECT x FROM tbl2'
    -1846
    -1847        Args:
    -1848            alias (str | Expression): the SQL code string to parse as the table name.
    -1849                If an `Expression` instance is passed, this is used as-is.
    -1850            as_ (str | Expression): the SQL code string to parse as the table expression.
    -1851                If an `Expression` instance is passed, it will be used as-is.
    -1852            recursive (bool): set the RECURSIVE part of the expression. Defaults to `False`.
    -1853            append (bool): if `True`, add to any existing expressions.
    -1854                Otherwise, this resets the expressions.
    -1855            dialect (str): the dialect used to parse the input expression.
    -1856            copy (bool): if `False`, modify this expression instance in-place.
    -1857            opts (kwargs): other options to use to parse the input expressions.
    -1858
    -1859        Returns:
    -1860            Select: the modified expression.
    -1861        """
    -1862        alias_expression = maybe_parse(
    -1863            alias,
    -1864            dialect=dialect,
    -1865            into=TableAlias,
    -1866            **opts,
    -1867        )
    -1868        as_expression = maybe_parse(
    -1869            as_,
    -1870            dialect=dialect,
    -1871            **opts,
    -1872        )
    -1873        cte = CTE(
    -1874            this=as_expression,
    -1875            alias=alias_expression,
    -1876        )
    -1877        return _apply_child_list_builder(
    -1878            cte,
    -1879            instance=self,
    -1880            arg="with",
    -1881            append=append,
    -1882            copy=copy,
    -1883            into=With,
    -1884            properties={"recursive": recursive or False},
    -1885        )
    +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        )
     
    @@ -20457,27 +20954,27 @@ Otherwise, this resets the expression.
    -
    1790    def subquery(self, alias=None, copy=True) -> Subquery:
    -1791        """
    -1792        Convert this expression to an aliased expression that can be used as a Subquery.
    -1793
    -1794        Example:
    -1795            >>> subquery = Select().select("x").from_("tbl").subquery()
    -1796            >>> Select().select("x").from_(subquery).sql()
    -1797            'SELECT x FROM (SELECT x FROM tbl)'
    -1798
    -1799        Args:
    -1800            alias (str | Identifier): an optional alias for the subquery
    -1801            copy (bool): if `False`, modify this expression instance in-place.
    -1802
    -1803        Returns:
    -1804            Alias: the subquery
    -1805        """
    -1806        instance = _maybe_copy(self, copy)
    -1807        return Subquery(
    -1808            this=instance,
    -1809            alias=TableAlias(this=to_identifier(alias)) if alias else None,
    -1810        )
    +            
    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        )
     
    @@ -20521,8 +21018,8 @@ Otherwise, this resets the expression.
    -
    1812    def limit(self, expression, dialect=None, copy=True, **opts) -> Select:
    -1813        raise NotImplementedError
    +            
    1852    def limit(self, expression, dialect=None, copy=True, **opts) -> Select:
    +1853        raise NotImplementedError
     
    @@ -20540,62 +21037,62 @@ Otherwise, this resets the expression.
    -
    1830    def with_(
    -1831        self,
    -1832        alias,
    -1833        as_,
    -1834        recursive=None,
    -1835        append=True,
    -1836        dialect=None,
    -1837        copy=True,
    -1838        **opts,
    -1839    ):
    -1840        """
    -1841        Append to or set the common table expressions.
    -1842
    -1843        Example:
    -1844            >>> Select().with_("tbl2", as_="SELECT * FROM tbl").select("x").from_("tbl2").sql()
    -1845            'WITH tbl2 AS (SELECT * FROM tbl) SELECT x FROM tbl2'
    -1846
    -1847        Args:
    -1848            alias (str | Expression): the SQL code string to parse as the table name.
    -1849                If an `Expression` instance is passed, this is used as-is.
    -1850            as_ (str | Expression): the SQL code string to parse as the table expression.
    -1851                If an `Expression` instance is passed, it will be used as-is.
    -1852            recursive (bool): set the RECURSIVE part of the expression. Defaults to `False`.
    -1853            append (bool): if `True`, add to any existing expressions.
    -1854                Otherwise, this resets the expressions.
    -1855            dialect (str): the dialect used to parse the input expression.
    -1856            copy (bool): if `False`, modify this expression instance in-place.
    -1857            opts (kwargs): other options to use to parse the input expressions.
    -1858
    -1859        Returns:
    -1860            Select: the modified expression.
    -1861        """
    -1862        alias_expression = maybe_parse(
    -1863            alias,
    -1864            dialect=dialect,
    -1865            into=TableAlias,
    -1866            **opts,
    -1867        )
    -1868        as_expression = maybe_parse(
    -1869            as_,
    -1870            dialect=dialect,
    -1871            **opts,
    -1872        )
    -1873        cte = CTE(
    -1874            this=as_expression,
    -1875            alias=alias_expression,
    -1876        )
    -1877        return _apply_child_list_builder(
    -1878            cte,
    -1879            instance=self,
    -1880            arg="with",
    -1881            append=append,
    -1882            copy=copy,
    -1883            into=With,
    -1884            properties={"recursive": recursive or False},
    -1885        )
    +            
    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        )
     
    @@ -20698,26 +21195,26 @@ Otherwise, this resets the expressions.
    -
    1909class Table(Expression):
    -1910    arg_types = {
    -1911        "this": True,
    -1912        "alias": False,
    -1913        "db": False,
    -1914        "catalog": False,
    -1915        "laterals": False,
    -1916        "joins": False,
    -1917        "pivots": False,
    -1918        "hints": False,
    -1919        "system_time": False,
    -1920    }
    -1921
    -1922    @property
    -1923    def db(self) -> str:
    -1924        return self.text("db")
    -1925
    -1926    @property
    -1927    def catalog(self) -> str:
    -1928        return self.text("catalog")
    +            
    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")
     
    @@ -20780,12 +21277,12 @@ Otherwise, this resets the expressions.
    -
    1932class SystemTime(Expression):
    -1933    arg_types = {
    -1934        "this": False,
    -1935        "expression": False,
    -1936        "kind": True,
    -1937    }
    +            
    1972class SystemTime(Expression):
    +1973    arg_types = {
    +1974        "this": False,
    +1975        "expression": False,
    +1976        "kind": True,
    +1977    }
     
    @@ -20848,94 +21345,94 @@ Otherwise, this resets the expressions.
    -
    1940class Union(Subqueryable):
    -1941    arg_types = {
    -1942        "with": False,
    -1943        "this": True,
    -1944        "expression": True,
    -1945        "distinct": False,
    -1946        **QUERY_MODIFIERS,
    -1947    }
    -1948
    -1949    def limit(self, expression, dialect=None, copy=True, **opts) -> Select:
    -1950        """
    -1951        Set the LIMIT expression.
    -1952
    -1953        Example:
    -1954            >>> select("1").union(select("1")).limit(1).sql()
    -1955            'SELECT * FROM (SELECT 1 UNION SELECT 1) AS _l_0 LIMIT 1'
    -1956
    -1957        Args:
    -1958            expression (str | int | Expression): the SQL code string to parse.
    -1959                This can also be an integer.
    -1960                If a `Limit` instance is passed, this is used as-is.
    -1961                If another `Expression` instance is passed, it will be wrapped in a `Limit`.
    -1962            dialect (str): the dialect used to parse the input expression.
    -1963            copy (bool): if `False`, modify this expression instance in-place.
    -1964            opts (kwargs): other options to use to parse the input expressions.
    -1965
    -1966        Returns:
    -1967            Select: The limited subqueryable.
    -1968        """
    -1969        return (
    -1970            select("*")
    -1971            .from_(self.subquery(alias="_l_0", copy=copy))
    -1972            .limit(expression, dialect=dialect, copy=False, **opts)
    -1973        )
    -1974
    -1975    def select(
    -1976        self,
    -1977        *expressions: ExpOrStr,
    -1978        append: bool = True,
    -1979        dialect: DialectType = None,
    -1980        copy: bool = True,
    -1981        **opts,
    -1982    ) -> Union:
    -1983        """Append to or set the SELECT of the union recursively.
    -1984
    -1985        Example:
    -1986            >>> from sqlglot import parse_one
    -1987            >>> parse_one("select a from x union select a from y union select a from z").select("b").sql()
    -1988            'SELECT a, b FROM x UNION SELECT a, b FROM y UNION SELECT a, b FROM z'
    -1989
    -1990        Args:
    -1991            *expressions: the SQL code strings to parse.
    -1992                If an `Expression` instance is passed, it will be used as-is.
    -1993            append: if `True`, add to any existing expressions.
    -1994                Otherwise, this resets the expressions.
    -1995            dialect: the dialect used to parse the input expressions.
    -1996            copy: if `False`, modify this expression instance in-place.
    -1997            opts: other options to use to parse the input expressions.
    -1998
    -1999        Returns:
    -2000            Union: the modified expression.
    -2001        """
    -2002        this = self.copy() if copy else self
    -2003        this.this.unnest().select(*expressions, append=append, dialect=dialect, copy=False, **opts)
    -2004        this.expression.unnest().select(
    -2005            *expressions, append=append, dialect=dialect, copy=False, **opts
    -2006        )
    -2007        return this
    -2008
    -2009    @property
    -2010    def named_selects(self):
    -2011        return self.this.unnest().named_selects
    -2012
    -2013    @property
    -2014    def is_star(self) -> bool:
    -2015        return self.this.is_star or self.expression.is_star
    -2016
    -2017    @property
    -2018    def selects(self):
    -2019        return self.this.unnest().selects
    -2020
    -2021    @property
    -2022    def left(self):
    -2023        return self.this
    +            
    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    @property
    -2026    def right(self):
    -2027        return self.expression
    +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
     
    @@ -20952,31 +21449,31 @@ Otherwise, this resets the expressions.
    -
    1949    def limit(self, expression, dialect=None, copy=True, **opts) -> Select:
    -1950        """
    -1951        Set the LIMIT expression.
    -1952
    -1953        Example:
    -1954            >>> select("1").union(select("1")).limit(1).sql()
    -1955            'SELECT * FROM (SELECT 1 UNION SELECT 1) AS _l_0 LIMIT 1'
    -1956
    -1957        Args:
    -1958            expression (str | int | Expression): the SQL code string to parse.
    -1959                This can also be an integer.
    -1960                If a `Limit` instance is passed, this is used as-is.
    -1961                If another `Expression` instance is passed, it will be wrapped in a `Limit`.
    -1962            dialect (str): the dialect used to parse the input expression.
    -1963            copy (bool): if `False`, modify this expression instance in-place.
    -1964            opts (kwargs): other options to use to parse the input expressions.
    -1965
    -1966        Returns:
    -1967            Select: The limited subqueryable.
    -1968        """
    -1969        return (
    -1970            select("*")
    -1971            .from_(self.subquery(alias="_l_0", copy=copy))
    -1972            .limit(expression, dialect=dialect, copy=False, **opts)
    -1973        )
    +            
    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        )
     
    @@ -21024,39 +21521,39 @@ If another Expression instance is passed,
    -
    1975    def select(
    -1976        self,
    -1977        *expressions: ExpOrStr,
    -1978        append: bool = True,
    -1979        dialect: DialectType = None,
    -1980        copy: bool = True,
    -1981        **opts,
    -1982    ) -> Union:
    -1983        """Append to or set the SELECT of the union recursively.
    -1984
    -1985        Example:
    -1986            >>> from sqlglot import parse_one
    -1987            >>> parse_one("select a from x union select a from y union select a from z").select("b").sql()
    -1988            'SELECT a, b FROM x UNION SELECT a, b FROM y UNION SELECT a, b FROM z'
    -1989
    -1990        Args:
    -1991            *expressions: the SQL code strings to parse.
    -1992                If an `Expression` instance is passed, it will be used as-is.
    -1993            append: if `True`, add to any existing expressions.
    -1994                Otherwise, this resets the expressions.
    -1995            dialect: the dialect used to parse the input expressions.
    -1996            copy: if `False`, modify this expression instance in-place.
    -1997            opts: other options to use to parse the input expressions.
    -1998
    -1999        Returns:
    -2000            Union: the modified expression.
    -2001        """
    -2002        this = self.copy() if copy else self
    -2003        this.this.unnest().select(*expressions, append=append, dialect=dialect, copy=False, **opts)
    -2004        this.expression.unnest().select(
    -2005            *expressions, append=append, dialect=dialect, copy=False, **opts
    -2006        )
    -2007        return this
    +            
    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
     
    @@ -21174,8 +21671,8 @@ Otherwise, this resets the expressions.
    -
    2030class Except(Union):
    -2031    pass
    +            
    2070class Except(Union):
    +2071    pass
     
    @@ -21254,8 +21751,8 @@ Otherwise, this resets the expressions.
    -
    2034class Intersect(Union):
    -2035    pass
    +            
    2074class Intersect(Union):
    +2075    pass
     
    @@ -21334,13 +21831,13 @@ Otherwise, this resets the expressions.
    -
    2038class Unnest(UDTF):
    -2039    arg_types = {
    -2040        "expressions": True,
    -2041        "ordinality": False,
    -2042        "alias": False,
    -2043        "offset": False,
    -2044    }
    +            
    2078class Unnest(UDTF):
    +2079    arg_types = {
    +2080        "expressions": True,
    +2081        "ordinality": False,
    +2082        "alias": False,
    +2083        "offset": False,
    +2084    }
     
    @@ -21409,15 +21906,15 @@ Otherwise, this resets the expressions.
    -
    2047class Update(Expression):
    -2048    arg_types = {
    -2049        "with": False,
    -2050        "this": False,
    -2051        "expressions": True,
    -2052        "from": False,
    -2053        "where": False,
    -2054        "returning": False,
    -2055    }
    +            
    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    }
     
    @@ -21480,12 +21977,12 @@ Otherwise, this resets the expressions.
    -
    2058class Values(UDTF):
    -2059    arg_types = {
    -2060        "expressions": True,
    -2061        "ordinality": False,
    -2062        "alias": False,
    -2063    }
    +            
    2098class Values(UDTF):
    +2099    arg_types = {
    +2100        "expressions": True,
    +2101        "ordinality": False,
    +2102        "alias": False,
    +2103    }
     
    @@ -21554,8 +22051,8 @@ Otherwise, this resets the expressions.
    -
    2066class Var(Expression):
    -2067    pass
    +            
    2106class Var(Expression):
    +2107    pass
     
    @@ -21618,8 +22115,8 @@ Otherwise, this resets the expressions.
    -
    2070class Schema(Expression):
    -2071    arg_types = {"this": False, "expressions": False}
    +            
    2110class Schema(Expression):
    +2111    arg_types = {"this": False, "expressions": False}
     
    @@ -21682,8 +22179,8 @@ Otherwise, this resets the expressions.
    -
    2076class Lock(Expression):
    -2077    arg_types = {"update": True}
    +            
    2116class Lock(Expression):
    +2117    arg_types = {"update": True}
     
    @@ -21746,591 +22243,591 @@ Otherwise, this resets the expressions.
    -
    2080class Select(Subqueryable):
    -2081    arg_types = {
    -2082        "with": False,
    -2083        "kind": False,
    -2084        "expressions": False,
    -2085        "hint": False,
    -2086        "distinct": False,
    -2087        "into": False,
    -2088        "from": False,
    -2089        **QUERY_MODIFIERS,
    -2090    }
    -2091
    -2092    def from_(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2093        """
    -2094        Set the FROM expression.
    -2095
    -2096        Example:
    -2097            >>> Select().from_("tbl").select("x").sql()
    -2098            'SELECT x FROM tbl'
    -2099
    -2100        Args:
    -2101            *expressions (str | Expression): the SQL code strings to parse.
    -2102                If a `From` instance is passed, this is used as-is.
    -2103                If another `Expression` instance is passed, it will be wrapped in a `From`.
    -2104            append (bool): if `True`, add to any existing expressions.
    -2105                Otherwise, this flattens all the `From` expression into a single expression.
    -2106            dialect (str): the dialect used to parse the input expression.
    -2107            copy (bool): if `False`, modify this expression instance in-place.
    -2108            opts (kwargs): other options to use to parse the input expressions.
    -2109
    -2110        Returns:
    -2111            Select: the modified expression.
    -2112        """
    -2113        return _apply_child_list_builder(
    -2114            *expressions,
    -2115            instance=self,
    -2116            arg="from",
    -2117            append=append,
    -2118            copy=copy,
    -2119            prefix="FROM",
    -2120            into=From,
    -2121            dialect=dialect,
    -2122            **opts,
    -2123        )
    -2124
    -2125    def group_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2126        """
    -2127        Set the GROUP BY expression.
    -2128
    -2129        Example:
    -2130            >>> Select().from_("tbl").select("x", "COUNT(1)").group_by("x").sql()
    -2131            'SELECT x, COUNT(1) FROM tbl GROUP BY x'
    -2132
    -2133        Args:
    -2134            *expressions (str | Expression): the SQL code strings to parse.
    -2135                If a `Group` instance is passed, this is used as-is.
    -2136                If another `Expression` instance is passed, it will be wrapped in a `Group`.
    -2137                If nothing is passed in then a group by is not applied to the expression
    -2138            append (bool): if `True`, add to any existing expressions.
    -2139                Otherwise, this flattens all the `Group` expression into a single expression.
    -2140            dialect (str): the dialect used to parse the input expression.
    -2141            copy (bool): if `False`, modify this expression instance in-place.
    -2142            opts (kwargs): other options to use to parse the input expressions.
    -2143
    -2144        Returns:
    -2145            Select: the modified expression.
    -2146        """
    -2147        if not expressions:
    -2148            return self if not copy else self.copy()
    -2149        return _apply_child_list_builder(
    -2150            *expressions,
    -2151            instance=self,
    -2152            arg="group",
    -2153            append=append,
    -2154            copy=copy,
    -2155            prefix="GROUP BY",
    -2156            into=Group,
    -2157            dialect=dialect,
    -2158            **opts,
    -2159        )
    -2160
    -2161    def order_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2162        """
    -2163        Set the ORDER BY expression.
    +            
    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        Example:
    -2166            >>> Select().from_("tbl").select("x").order_by("x DESC").sql()
    -2167            'SELECT x FROM tbl ORDER BY x DESC'
    +2165    def group_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    +2166        """
    +2167        Set the GROUP BY expression.
     2168
    -2169        Args:
    -2170            *expressions (str | Expression): the SQL code strings to parse.
    -2171                If a `Group` instance is passed, this is used as-is.
    -2172                If another `Expression` instance is passed, it will be wrapped in a `Order`.
    -2173            append (bool): if `True`, add to any existing expressions.
    -2174                Otherwise, this flattens all the `Order` expression into a single expression.
    -2175            dialect (str): the dialect used to parse the input expression.
    -2176            copy (bool): if `False`, modify this expression instance in-place.
    -2177            opts (kwargs): other options to use to parse the input expressions.
    -2178
    -2179        Returns:
    -2180            Select: the modified expression.
    -2181        """
    -2182        return _apply_child_list_builder(
    -2183            *expressions,
    -2184            instance=self,
    -2185            arg="order",
    -2186            append=append,
    -2187            copy=copy,
    -2188            prefix="ORDER BY",
    -2189            into=Order,
    -2190            dialect=dialect,
    -2191            **opts,
    -2192        )
    -2193
    -2194    def sort_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2195        """
    -2196        Set the SORT BY expression.
    -2197
    -2198        Example:
    -2199            >>> Select().from_("tbl").select("x").sort_by("x DESC").sql()
    -2200            'SELECT x FROM tbl SORT BY x DESC'
    -2201
    -2202        Args:
    -2203            *expressions (str | Expression): the SQL code strings to parse.
    -2204                If a `Group` instance is passed, this is used as-is.
    -2205                If another `Expression` instance is passed, it will be wrapped in a `SORT`.
    -2206            append (bool): if `True`, add to any existing expressions.
    -2207                Otherwise, this flattens all the `Order` expression into a single expression.
    -2208            dialect (str): the dialect used to parse the input expression.
    -2209            copy (bool): if `False`, modify this expression instance in-place.
    -2210            opts (kwargs): other options to use to parse the input expressions.
    -2211
    -2212        Returns:
    -2213            Select: the modified expression.
    -2214        """
    -2215        return _apply_child_list_builder(
    -2216            *expressions,
    -2217            instance=self,
    -2218            arg="sort",
    -2219            append=append,
    -2220            copy=copy,
    -2221            prefix="SORT BY",
    -2222            into=Sort,
    -2223            dialect=dialect,
    -2224            **opts,
    -2225        )
    -2226
    -2227    def cluster_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2228        """
    -2229        Set the CLUSTER BY expression.
    -2230
    -2231        Example:
    -2232            >>> Select().from_("tbl").select("x").cluster_by("x DESC").sql()
    -2233            'SELECT x FROM tbl CLUSTER BY x DESC'
    -2234
    -2235        Args:
    -2236            *expressions (str | Expression): the SQL code strings to parse.
    -2237                If a `Group` instance is passed, this is used as-is.
    -2238                If another `Expression` instance is passed, it will be wrapped in a `Cluster`.
    -2239            append (bool): if `True`, add to any existing expressions.
    -2240                Otherwise, this flattens all the `Order` expression into a single expression.
    -2241            dialect (str): the dialect used to parse the input expression.
    -2242            copy (bool): if `False`, modify this expression instance in-place.
    -2243            opts (kwargs): other options to use to parse the input expressions.
    -2244
    -2245        Returns:
    -2246            Select: the modified expression.
    -2247        """
    -2248        return _apply_child_list_builder(
    -2249            *expressions,
    -2250            instance=self,
    -2251            arg="cluster",
    -2252            append=append,
    -2253            copy=copy,
    -2254            prefix="CLUSTER BY",
    -2255            into=Cluster,
    -2256            dialect=dialect,
    -2257            **opts,
    -2258        )
    -2259
    -2260    def limit(self, expression, dialect=None, copy=True, **opts) -> Select:
    -2261        """
    -2262        Set the LIMIT expression.
    -2263
    -2264        Example:
    -2265            >>> Select().from_("tbl").select("x").limit(10).sql()
    -2266            'SELECT x FROM tbl LIMIT 10'
    -2267
    -2268        Args:
    -2269            expression (str | int | Expression): the SQL code string to parse.
    -2270                This can also be an integer.
    -2271                If a `Limit` instance is passed, this is used as-is.
    -2272                If another `Expression` instance is passed, it will be wrapped in a `Limit`.
    -2273            dialect (str): the dialect used to parse the input expression.
    -2274            copy (bool): if `False`, modify this expression instance in-place.
    -2275            opts (kwargs): other options to use to parse the input expressions.
    -2276
    -2277        Returns:
    -2278            Select: the modified expression.
    -2279        """
    -2280        return _apply_builder(
    -2281            expression=expression,
    -2282            instance=self,
    -2283            arg="limit",
    -2284            into=Limit,
    -2285            prefix="LIMIT",
    -2286            dialect=dialect,
    -2287            copy=copy,
    -2288            **opts,
    -2289        )
    -2290
    -2291    def offset(self, expression, dialect=None, copy=True, **opts) -> Select:
    -2292        """
    -2293        Set the OFFSET expression.
    -2294
    -2295        Example:
    -2296            >>> Select().from_("tbl").select("x").offset(10).sql()
    -2297            'SELECT x FROM tbl OFFSET 10'
    -2298
    -2299        Args:
    -2300            expression (str | int | Expression): the SQL code string to parse.
    -2301                This can also be an integer.
    -2302                If a `Offset` instance is passed, this is used as-is.
    -2303                If another `Expression` instance is passed, it will be wrapped in a `Offset`.
    -2304            dialect (str): the dialect used to parse the input expression.
    -2305            copy (bool): if `False`, modify this expression instance in-place.
    -2306            opts (kwargs): other options to use to parse the input expressions.
    +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        Returns:
    -2309            Select: the modified expression.
    -2310        """
    -2311        return _apply_builder(
    -2312            expression=expression,
    -2313            instance=self,
    -2314            arg="offset",
    -2315            into=Offset,
    -2316            prefix="OFFSET",
    -2317            dialect=dialect,
    -2318            copy=copy,
    -2319            **opts,
    -2320        )
    -2321
    -2322    def select(
    -2323        self,
    -2324        *expressions: ExpOrStr,
    -2325        append: bool = True,
    -2326        dialect: DialectType = None,
    -2327        copy: bool = True,
    -2328        **opts,
    -2329    ) -> Select:
    -2330        """
    -2331        Append to or set the SELECT expressions.
    -2332
    -2333        Example:
    -2334            >>> Select().select("x", "y").sql()
    -2335            'SELECT x, y'
    -2336
    -2337        Args:
    -2338            *expressions: the SQL code strings to parse.
    -2339                If an `Expression` instance is passed, it will be used as-is.
    -2340            append: if `True`, add to any existing expressions.
    -2341                Otherwise, this resets the expressions.
    -2342            dialect: the dialect used to parse the input expressions.
    -2343            copy: if `False`, modify this expression instance in-place.
    -2344            opts: other options to use to parse the input expressions.
    -2345
    -2346        Returns:
    -2347            Select: the modified expression.
    -2348        """
    -2349        return _apply_list_builder(
    -2350            *expressions,
    -2351            instance=self,
    -2352            arg="expressions",
    -2353            append=append,
    -2354            dialect=dialect,
    -2355            copy=copy,
    -2356            **opts,
    -2357        )
    -2358
    -2359    def lateral(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2360        """
    -2361        Append to or set the LATERAL expressions.
    -2362
    -2363        Example:
    -2364            >>> Select().select("x").lateral("OUTER explode(y) tbl2 AS z").from_("tbl").sql()
    -2365            'SELECT x FROM tbl LATERAL VIEW OUTER EXPLODE(y) tbl2 AS z'
    -2366
    -2367        Args:
    -2368            *expressions (str | Expression): the SQL code strings to parse.
    -2369                If an `Expression` instance is passed, it will be used as-is.
    -2370            append (bool): if `True`, add to any existing expressions.
    -2371                Otherwise, this resets the expressions.
    -2372            dialect (str): the dialect used to parse the input expressions.
    -2373            copy (bool): if `False`, modify this expression instance in-place.
    -2374            opts (kwargs): other options to use to parse the input expressions.
    -2375
    -2376        Returns:
    -2377            Select: the modified expression.
    -2378        """
    -2379        return _apply_list_builder(
    -2380            *expressions,
    -2381            instance=self,
    -2382            arg="laterals",
    -2383            append=append,
    -2384            into=Lateral,
    -2385            prefix="LATERAL VIEW",
    -2386            dialect=dialect,
    -2387            copy=copy,
    -2388            **opts,
    -2389        )
    -2390
    -2391    def join(
    -2392        self,
    -2393        expression,
    -2394        on=None,
    -2395        using=None,
    -2396        append=True,
    -2397        join_type=None,
    -2398        join_alias=None,
    -2399        dialect=None,
    -2400        copy=True,
    -2401        **opts,
    -2402    ) -> Select:
    -2403        """
    -2404        Append to or set the JOIN expressions.
    -2405
    -2406        Example:
    -2407            >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y").sql()
    -2408            'SELECT * FROM tbl JOIN tbl2 ON tbl1.y = tbl2.y'
    -2409
    -2410            >>> Select().select("1").from_("a").join("b", using=["x", "y", "z"]).sql()
    -2411            'SELECT 1 FROM a JOIN b USING (x, y, z)'
    -2412
    -2413            Use `join_type` to change the type of join:
    -2414
    -2415            >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y", join_type="left outer").sql()
    -2416            'SELECT * FROM tbl LEFT OUTER JOIN tbl2 ON tbl1.y = tbl2.y'
    -2417
    -2418        Args:
    -2419            expression (str | Expression): the SQL code string to parse.
    -2420                If an `Expression` instance is passed, it will be used as-is.
    -2421            on (str | Expression): optionally specify the join "on" criteria as a SQL string.
    -2422                If an `Expression` instance is passed, it will be used as-is.
    -2423            using (str | Expression): optionally specify the join "using" criteria as a SQL string.
    -2424                If an `Expression` instance is passed, it will be used as-is.
    -2425            append (bool): if `True`, add to any existing expressions.
    -2426                Otherwise, this resets the expressions.
    -2427            join_type (str): If set, alter the parsed join type
    -2428            dialect (str): the dialect used to parse the input expressions.
    -2429            copy (bool): if `False`, modify this expression instance in-place.
    -2430            opts (kwargs): other options to use to parse the input expressions.
    -2431
    -2432        Returns:
    -2433            Select: the modified expression.
    -2434        """
    -2435        parse_args = {"dialect": dialect, **opts}
    -2436
    -2437        try:
    -2438            expression = maybe_parse(expression, into=Join, prefix="JOIN", **parse_args)
    -2439        except ParseError:
    -2440            expression = maybe_parse(expression, into=(Join, Expression), **parse_args)
    -2441
    -2442        join = expression if isinstance(expression, Join) else Join(this=expression)
    -2443
    -2444        if isinstance(join.this, Select):
    -2445            join.this.replace(join.this.subquery())
    -2446
    -2447        if join_type:
    -2448            natural: t.Optional[Token]
    -2449            side: t.Optional[Token]
    -2450            kind: t.Optional[Token]
    -2451
    -2452            natural, side, kind = maybe_parse(join_type, into="JOIN_TYPE", **parse_args)  # type: ignore
    -2453
    -2454            if natural:
    -2455                join.set("natural", True)
    -2456            if side:
    -2457                join.set("side", side.text)
    -2458            if kind:
    -2459                join.set("kind", kind.text)
    -2460
    -2461        if on:
    -2462            on = and_(*ensure_collection(on), dialect=dialect, **opts)
    -2463            join.set("on", on)
    -2464
    -2465        if using:
    -2466            join = _apply_list_builder(
    -2467                *ensure_collection(using),
    -2468                instance=join,
    -2469                arg="using",
    -2470                append=append,
    -2471                copy=copy,
    -2472                **opts,
    -2473            )
    -2474
    -2475        if join_alias:
    -2476            join.set("this", alias_(join.this, join_alias, table=True))
    -2477        return _apply_list_builder(
    -2478            join,
    -2479            instance=self,
    -2480            arg="joins",
    -2481            append=append,
    -2482            copy=copy,
    -2483            **opts,
    -2484        )
    -2485
    -2486    def where(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2487        """
    -2488        Append to or set the WHERE expressions.
    -2489
    -2490        Example:
    -2491            >>> Select().select("x").from_("tbl").where("x = 'a' OR x < 'b'").sql()
    -2492            "SELECT x FROM tbl WHERE x = 'a' OR x < 'b'"
    +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        )
    +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'
    +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        Args:
    -2495            *expressions (str | Expression): the SQL code strings to parse.
    -2496                If an `Expression` instance is passed, it will be used as-is.
    -2497                Multiple expressions are combined with an AND operator.
    -2498            append (bool): if `True`, AND the new expressions to any existing expression.
    -2499                Otherwise, this resets the expression.
    -2500            dialect (str): the dialect used to parse the input expressions.
    -2501            copy (bool): if `False`, modify this expression instance in-place.
    -2502            opts (kwargs): other options to use to parse the input expressions.
    -2503
    -2504        Returns:
    -2505            Select: the modified expression.
    -2506        """
    -2507        return _apply_conjunction_builder(
    -2508            *expressions,
    -2509            instance=self,
    -2510            arg="where",
    -2511            append=append,
    -2512            into=Where,
    -2513            dialect=dialect,
    -2514            copy=copy,
    -2515            **opts,
    -2516        )
    -2517
    -2518    def having(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2519        """
    -2520        Append to or set the HAVING expressions.
    -2521
    -2522        Example:
    -2523            >>> Select().select("x", "COUNT(y)").from_("tbl").group_by("x").having("COUNT(y) > 3").sql()
    -2524            'SELECT x, COUNT(y) FROM tbl GROUP BY x HAVING COUNT(y) > 3'
    +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        )
     2525
    -2526        Args:
    -2527            *expressions (str | Expression): the SQL code strings to parse.
    -2528                If an `Expression` instance is passed, it will be used as-is.
    -2529                Multiple expressions are combined with an AND operator.
    -2530            append (bool): if `True`, AND the new expressions to any existing expression.
    -2531                Otherwise, this resets the expression.
    -2532            dialect (str): the dialect used to parse the input expressions.
    -2533            copy (bool): if `False`, modify this expression instance in-place.
    -2534            opts (kwargs): other options to use to parse the input expressions.
    -2535
    -2536        Returns:
    -2537            Select: the modified expression.
    -2538        """
    -2539        return _apply_conjunction_builder(
    -2540            *expressions,
    -2541            instance=self,
    -2542            arg="having",
    -2543            append=append,
    -2544            into=Having,
    -2545            dialect=dialect,
    -2546            copy=copy,
    -2547            **opts,
    -2548        )
    -2549
    -2550    def window(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2551        return _apply_list_builder(
    -2552            *expressions,
    -2553            instance=self,
    -2554            arg="windows",
    -2555            append=append,
    -2556            into=Window,
    -2557            dialect=dialect,
    -2558            copy=copy,
    -2559            **opts,
    -2560        )
    +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        )
    +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    def qualify(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2563        return _apply_conjunction_builder(
    -2564            *expressions,
    -2565            instance=self,
    -2566            arg="qualify",
    -2567            append=append,
    -2568            into=Qualify,
    -2569            dialect=dialect,
    -2570            copy=copy,
    -2571            **opts,
    -2572        )
    -2573
    -2574    def distinct(self, distinct=True, copy=True) -> Select:
    -2575        """
    -2576        Set the OFFSET expression.
    -2577
    -2578        Example:
    -2579            >>> Select().from_("tbl").select("x").distinct().sql()
    -2580            'SELECT DISTINCT x FROM tbl'
    -2581
    -2582        Args:
    -2583            distinct (bool): whether the Select should be distinct
    -2584            copy (bool): if `False`, modify this expression instance in-place.
    -2585
    -2586        Returns:
    -2587            Select: the modified expression.
    -2588        """
    -2589        instance = _maybe_copy(self, copy)
    -2590        instance.set("distinct", Distinct() if distinct else None)
    -2591        return instance
    -2592
    -2593    def ctas(self, table, properties=None, dialect=None, copy=True, **opts) -> Create:
    -2594        """
    -2595        Convert this expression to a CREATE TABLE AS statement.
    -2596
    -2597        Example:
    -2598            >>> Select().select("*").from_("tbl").ctas("x").sql()
    -2599            'CREATE TABLE x AS SELECT * FROM tbl'
    -2600
    -2601        Args:
    -2602            table (str | Expression): the SQL code string to parse as the table name.
    -2603                If another `Expression` instance is passed, it will be used as-is.
    -2604            properties (dict): an optional mapping of table properties
    -2605            dialect (str): the dialect used to parse the input table.
    -2606            copy (bool): if `False`, modify this expression instance in-place.
    -2607            opts (kwargs): other options to use to parse the input table.
    -2608
    -2609        Returns:
    -2610            Create: the CREATE TABLE AS expression
    -2611        """
    -2612        instance = _maybe_copy(self, copy)
    -2613        table_expression = maybe_parse(
    -2614            table,
    -2615            into=Table,
    -2616            dialect=dialect,
    -2617            **opts,
    -2618        )
    -2619        properties_expression = None
    -2620        if properties:
    -2621            properties_expression = Properties.from_dict(properties)
    -2622
    -2623        return Create(
    -2624            this=table_expression,
    -2625            kind="table",
    -2626            expression=instance,
    -2627            properties=properties_expression,
    -2628        )
    -2629
    -2630    def lock(self, update: bool = True, copy: bool = True) -> Select:
    -2631        """
    -2632        Set the locking read mode for this expression.
    -2633
    -2634        Examples:
    -2635            >>> Select().select("x").from_("tbl").where("x = 'a'").lock().sql("mysql")
    -2636            "SELECT x FROM tbl WHERE x = 'a' FOR UPDATE"
    -2637
    -2638            >>> Select().select("x").from_("tbl").where("x = 'a'").lock(update=False).sql("mysql")
    -2639            "SELECT x FROM tbl WHERE x = 'a' FOR SHARE"
    +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        )
    +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            update: if `True`, the locking type will be `FOR UPDATE`, else it will be `FOR SHARE`.
    -2643            copy: if `False`, modify this expression instance in-place.
    -2644
    -2645        Returns:
    -2646            The modified expression.
    -2647        """
    +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        inst = _maybe_copy(self, copy)
    -2650        inst.set("lock", Lock(update=update))
    -2651
    -2652        return inst
    -2653
    -2654    @property
    -2655    def named_selects(self) -> t.List[str]:
    -2656        return [e.output_name for e in self.expressions if e.alias_or_name]
    -2657
    -2658    @property
    -2659    def is_star(self) -> bool:
    -2660        return any(expression.is_star for expression in self.expressions)
    -2661
    -2662    @property
    -2663    def selects(self) -> t.List[Expression]:
    -2664        return self.expressions
    +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"
    +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
    +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
     
    @@ -22347,38 +22844,38 @@ Otherwise, this resets the expressions.
    -
    2092    def from_(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2093        """
    -2094        Set the FROM expression.
    -2095
    -2096        Example:
    -2097            >>> Select().from_("tbl").select("x").sql()
    -2098            'SELECT x FROM tbl'
    -2099
    -2100        Args:
    -2101            *expressions (str | Expression): the SQL code strings to parse.
    -2102                If a `From` instance is passed, this is used as-is.
    -2103                If another `Expression` instance is passed, it will be wrapped in a `From`.
    -2104            append (bool): if `True`, add to any existing expressions.
    -2105                Otherwise, this flattens all the `From` expression into a single expression.
    -2106            dialect (str): the dialect used to parse the input expression.
    -2107            copy (bool): if `False`, modify this expression instance in-place.
    -2108            opts (kwargs): other options to use to parse the input expressions.
    -2109
    -2110        Returns:
    -2111            Select: the modified expression.
    -2112        """
    -2113        return _apply_child_list_builder(
    -2114            *expressions,
    -2115            instance=self,
    -2116            arg="from",
    -2117            append=append,
    -2118            copy=copy,
    -2119            prefix="FROM",
    -2120            into=From,
    -2121            dialect=dialect,
    -2122            **opts,
    -2123        )
    +            
    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        )
     
    @@ -22427,41 +22924,41 @@ Otherwise, this flattens all the From expressio
    -
    2125    def group_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2126        """
    -2127        Set the GROUP BY expression.
    -2128
    -2129        Example:
    -2130            >>> Select().from_("tbl").select("x", "COUNT(1)").group_by("x").sql()
    -2131            'SELECT x, COUNT(1) FROM tbl GROUP BY x'
    -2132
    -2133        Args:
    -2134            *expressions (str | Expression): the SQL code strings to parse.
    -2135                If a `Group` instance is passed, this is used as-is.
    -2136                If another `Expression` instance is passed, it will be wrapped in a `Group`.
    -2137                If nothing is passed in then a group by is not applied to the expression
    -2138            append (bool): if `True`, add to any existing expressions.
    -2139                Otherwise, this flattens all the `Group` expression into a single expression.
    -2140            dialect (str): the dialect used to parse the input expression.
    -2141            copy (bool): if `False`, modify this expression instance in-place.
    -2142            opts (kwargs): other options to use to parse the input expressions.
    -2143
    -2144        Returns:
    -2145            Select: the modified expression.
    -2146        """
    -2147        if not expressions:
    -2148            return self if not copy else self.copy()
    -2149        return _apply_child_list_builder(
    -2150            *expressions,
    -2151            instance=self,
    -2152            arg="group",
    -2153            append=append,
    -2154            copy=copy,
    -2155            prefix="GROUP BY",
    -2156            into=Group,
    -2157            dialect=dialect,
    -2158            **opts,
    -2159        )
    +            
    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        )
     
    @@ -22511,38 +23008,38 @@ Otherwise, this flattens all the Group express
    -
    2161    def order_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2162        """
    -2163        Set the ORDER BY expression.
    -2164
    -2165        Example:
    -2166            >>> Select().from_("tbl").select("x").order_by("x DESC").sql()
    -2167            'SELECT x FROM tbl ORDER BY x DESC'
    -2168
    -2169        Args:
    -2170            *expressions (str | Expression): the SQL code strings to parse.
    -2171                If a `Group` instance is passed, this is used as-is.
    -2172                If another `Expression` instance is passed, it will be wrapped in a `Order`.
    -2173            append (bool): if `True`, add to any existing expressions.
    -2174                Otherwise, this flattens all the `Order` expression into a single expression.
    -2175            dialect (str): the dialect used to parse the input expression.
    -2176            copy (bool): if `False`, modify this expression instance in-place.
    -2177            opts (kwargs): other options to use to parse the input expressions.
    -2178
    -2179        Returns:
    -2180            Select: the modified expression.
    -2181        """
    -2182        return _apply_child_list_builder(
    -2183            *expressions,
    -2184            instance=self,
    -2185            arg="order",
    -2186            append=append,
    -2187            copy=copy,
    -2188            prefix="ORDER BY",
    -2189            into=Order,
    -2190            dialect=dialect,
    -2191            **opts,
    -2192        )
    +            
    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        )
     
    @@ -22591,38 +23088,38 @@ Otherwise, this flattens all the Order express
    -
    2194    def sort_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2195        """
    -2196        Set the SORT BY expression.
    -2197
    -2198        Example:
    -2199            >>> Select().from_("tbl").select("x").sort_by("x DESC").sql()
    -2200            'SELECT x FROM tbl SORT BY x DESC'
    -2201
    -2202        Args:
    -2203            *expressions (str | Expression): the SQL code strings to parse.
    -2204                If a `Group` instance is passed, this is used as-is.
    -2205                If another `Expression` instance is passed, it will be wrapped in a `SORT`.
    -2206            append (bool): if `True`, add to any existing expressions.
    -2207                Otherwise, this flattens all the `Order` expression into a single expression.
    -2208            dialect (str): the dialect used to parse the input expression.
    -2209            copy (bool): if `False`, modify this expression instance in-place.
    -2210            opts (kwargs): other options to use to parse the input expressions.
    -2211
    -2212        Returns:
    -2213            Select: the modified expression.
    -2214        """
    -2215        return _apply_child_list_builder(
    -2216            *expressions,
    -2217            instance=self,
    -2218            arg="sort",
    -2219            append=append,
    -2220            copy=copy,
    -2221            prefix="SORT BY",
    -2222            into=Sort,
    -2223            dialect=dialect,
    -2224            **opts,
    -2225        )
    +            
    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        )
     
    @@ -22671,38 +23168,38 @@ Otherwise, this flattens all the Order express
    -
    2227    def cluster_by(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2228        """
    -2229        Set the CLUSTER BY expression.
    -2230
    -2231        Example:
    -2232            >>> Select().from_("tbl").select("x").cluster_by("x DESC").sql()
    -2233            'SELECT x FROM tbl CLUSTER BY x DESC'
    -2234
    -2235        Args:
    -2236            *expressions (str | Expression): the SQL code strings to parse.
    -2237                If a `Group` instance is passed, this is used as-is.
    -2238                If another `Expression` instance is passed, it will be wrapped in a `Cluster`.
    -2239            append (bool): if `True`, add to any existing expressions.
    -2240                Otherwise, this flattens all the `Order` expression into a single expression.
    -2241            dialect (str): the dialect used to parse the input expression.
    -2242            copy (bool): if `False`, modify this expression instance in-place.
    -2243            opts (kwargs): other options to use to parse the input expressions.
    -2244
    -2245        Returns:
    -2246            Select: the modified expression.
    -2247        """
    -2248        return _apply_child_list_builder(
    -2249            *expressions,
    -2250            instance=self,
    -2251            arg="cluster",
    -2252            append=append,
    -2253            copy=copy,
    -2254            prefix="CLUSTER BY",
    -2255            into=Cluster,
    -2256            dialect=dialect,
    -2257            **opts,
    -2258        )
    +            
    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        )
     
    @@ -22751,36 +23248,36 @@ Otherwise, this flattens all the Order express
    -
    2260    def limit(self, expression, dialect=None, copy=True, **opts) -> Select:
    -2261        """
    -2262        Set the LIMIT expression.
    -2263
    -2264        Example:
    -2265            >>> Select().from_("tbl").select("x").limit(10).sql()
    -2266            'SELECT x FROM tbl LIMIT 10'
    -2267
    -2268        Args:
    -2269            expression (str | int | Expression): the SQL code string to parse.
    -2270                This can also be an integer.
    -2271                If a `Limit` instance is passed, this is used as-is.
    -2272                If another `Expression` instance is passed, it will be wrapped in a `Limit`.
    -2273            dialect (str): the dialect used to parse the input expression.
    -2274            copy (bool): if `False`, modify this expression instance in-place.
    -2275            opts (kwargs): other options to use to parse the input expressions.
    -2276
    -2277        Returns:
    -2278            Select: the modified expression.
    -2279        """
    -2280        return _apply_builder(
    -2281            expression=expression,
    -2282            instance=self,
    -2283            arg="limit",
    -2284            into=Limit,
    -2285            prefix="LIMIT",
    -2286            dialect=dialect,
    -2287            copy=copy,
    -2288            **opts,
    -2289        )
    +            
    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        )
     
    @@ -22828,36 +23325,36 @@ If another Expression instance is passed,
    -
    2291    def offset(self, expression, dialect=None, copy=True, **opts) -> Select:
    -2292        """
    -2293        Set the OFFSET expression.
    -2294
    -2295        Example:
    -2296            >>> Select().from_("tbl").select("x").offset(10).sql()
    -2297            'SELECT x FROM tbl OFFSET 10'
    -2298
    -2299        Args:
    -2300            expression (str | int | Expression): the SQL code string to parse.
    -2301                This can also be an integer.
    -2302                If a `Offset` instance is passed, this is used as-is.
    -2303                If another `Expression` instance is passed, it will be wrapped in a `Offset`.
    -2304            dialect (str): the dialect used to parse the input expression.
    -2305            copy (bool): if `False`, modify this expression instance in-place.
    -2306            opts (kwargs): other options to use to parse the input expressions.
    -2307
    -2308        Returns:
    -2309            Select: the modified expression.
    -2310        """
    -2311        return _apply_builder(
    -2312            expression=expression,
    -2313            instance=self,
    -2314            arg="offset",
    -2315            into=Offset,
    -2316            prefix="OFFSET",
    -2317            dialect=dialect,
    -2318            copy=copy,
    -2319            **opts,
    -2320        )
    +            
    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        )
     
    @@ -22905,42 +23402,42 @@ If another Expression instance is passed,
    -
    2322    def select(
    -2323        self,
    -2324        *expressions: ExpOrStr,
    -2325        append: bool = True,
    -2326        dialect: DialectType = None,
    -2327        copy: bool = True,
    -2328        **opts,
    -2329    ) -> Select:
    -2330        """
    -2331        Append to or set the SELECT expressions.
    -2332
    -2333        Example:
    -2334            >>> Select().select("x", "y").sql()
    -2335            'SELECT x, y'
    -2336
    -2337        Args:
    -2338            *expressions: the SQL code strings to parse.
    -2339                If an `Expression` instance is passed, it will be used as-is.
    -2340            append: if `True`, add to any existing expressions.
    -2341                Otherwise, this resets the expressions.
    -2342            dialect: the dialect used to parse the input expressions.
    -2343            copy: if `False`, modify this expression instance in-place.
    -2344            opts: other options to use to parse the input expressions.
    -2345
    -2346        Returns:
    -2347            Select: the modified expression.
    -2348        """
    -2349        return _apply_list_builder(
    -2350            *expressions,
    -2351            instance=self,
    -2352            arg="expressions",
    -2353            append=append,
    -2354            dialect=dialect,
    -2355            copy=copy,
    -2356            **opts,
    -2357        )
    +            
    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        )
     
    @@ -22988,37 +23485,37 @@ Otherwise, this resets the expressions.
    -
    2359    def lateral(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2360        """
    -2361        Append to or set the LATERAL expressions.
    -2362
    -2363        Example:
    -2364            >>> Select().select("x").lateral("OUTER explode(y) tbl2 AS z").from_("tbl").sql()
    -2365            'SELECT x FROM tbl LATERAL VIEW OUTER EXPLODE(y) tbl2 AS z'
    -2366
    -2367        Args:
    -2368            *expressions (str | Expression): the SQL code strings to parse.
    -2369                If an `Expression` instance is passed, it will be used as-is.
    -2370            append (bool): if `True`, add to any existing expressions.
    -2371                Otherwise, this resets the expressions.
    -2372            dialect (str): the dialect used to parse the input expressions.
    -2373            copy (bool): if `False`, modify this expression instance in-place.
    -2374            opts (kwargs): other options to use to parse the input expressions.
    -2375
    -2376        Returns:
    -2377            Select: the modified expression.
    -2378        """
    -2379        return _apply_list_builder(
    -2380            *expressions,
    -2381            instance=self,
    -2382            arg="laterals",
    -2383            append=append,
    -2384            into=Lateral,
    -2385            prefix="LATERAL VIEW",
    -2386            dialect=dialect,
    -2387            copy=copy,
    -2388            **opts,
    -2389        )
    +            
    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        )
     
    @@ -23066,100 +23563,100 @@ Otherwise, this resets the expressions.
    -
    2391    def join(
    -2392        self,
    -2393        expression,
    -2394        on=None,
    -2395        using=None,
    -2396        append=True,
    -2397        join_type=None,
    -2398        join_alias=None,
    -2399        dialect=None,
    -2400        copy=True,
    -2401        **opts,
    -2402    ) -> Select:
    -2403        """
    -2404        Append to or set the JOIN expressions.
    -2405
    -2406        Example:
    -2407            >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y").sql()
    -2408            'SELECT * FROM tbl JOIN tbl2 ON tbl1.y = tbl2.y'
    -2409
    -2410            >>> Select().select("1").from_("a").join("b", using=["x", "y", "z"]).sql()
    -2411            'SELECT 1 FROM a JOIN b USING (x, y, z)'
    -2412
    -2413            Use `join_type` to change the type of join:
    -2414
    -2415            >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y", join_type="left outer").sql()
    -2416            'SELECT * FROM tbl LEFT OUTER JOIN tbl2 ON tbl1.y = tbl2.y'
    -2417
    -2418        Args:
    -2419            expression (str | Expression): the SQL code string to parse.
    -2420                If an `Expression` instance is passed, it will be used as-is.
    -2421            on (str | Expression): optionally specify the join "on" criteria as a SQL string.
    -2422                If an `Expression` instance is passed, it will be used as-is.
    -2423            using (str | Expression): optionally specify the join "using" criteria as a SQL string.
    -2424                If an `Expression` instance is passed, it will be used as-is.
    -2425            append (bool): if `True`, add to any existing expressions.
    -2426                Otherwise, this resets the expressions.
    -2427            join_type (str): If set, alter the parsed join type
    -2428            dialect (str): the dialect used to parse the input expressions.
    -2429            copy (bool): if `False`, modify this expression instance in-place.
    -2430            opts (kwargs): other options to use to parse the input expressions.
    -2431
    -2432        Returns:
    -2433            Select: the modified expression.
    -2434        """
    -2435        parse_args = {"dialect": dialect, **opts}
    -2436
    -2437        try:
    -2438            expression = maybe_parse(expression, into=Join, prefix="JOIN", **parse_args)
    -2439        except ParseError:
    -2440            expression = maybe_parse(expression, into=(Join, Expression), **parse_args)
    -2441
    -2442        join = expression if isinstance(expression, Join) else Join(this=expression)
    -2443
    -2444        if isinstance(join.this, Select):
    -2445            join.this.replace(join.this.subquery())
    -2446
    -2447        if join_type:
    -2448            natural: t.Optional[Token]
    -2449            side: t.Optional[Token]
    -2450            kind: t.Optional[Token]
    -2451
    -2452            natural, side, kind = maybe_parse(join_type, into="JOIN_TYPE", **parse_args)  # type: ignore
    -2453
    -2454            if natural:
    -2455                join.set("natural", True)
    -2456            if side:
    -2457                join.set("side", side.text)
    -2458            if kind:
    -2459                join.set("kind", kind.text)
    -2460
    -2461        if on:
    -2462            on = and_(*ensure_collection(on), dialect=dialect, **opts)
    -2463            join.set("on", on)
    -2464
    -2465        if using:
    -2466            join = _apply_list_builder(
    -2467                *ensure_collection(using),
    -2468                instance=join,
    -2469                arg="using",
    -2470                append=append,
    -2471                copy=copy,
    -2472                **opts,
    -2473            )
    -2474
    -2475        if join_alias:
    -2476            join.set("this", alias_(join.this, join_alias, table=True))
    -2477        return _apply_list_builder(
    -2478            join,
    -2479            instance=self,
    -2480            arg="joins",
    -2481            append=append,
    -2482            copy=copy,
    -2483            **opts,
    -2484        )
    +            
    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        )
     
    @@ -23226,37 +23723,37 @@ Otherwise, this resets the expressions.
    -
    2486    def where(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2487        """
    -2488        Append to or set the WHERE expressions.
    -2489
    -2490        Example:
    -2491            >>> Select().select("x").from_("tbl").where("x = 'a' OR x < 'b'").sql()
    -2492            "SELECT x FROM tbl WHERE x = 'a' OR x < 'b'"
    -2493
    -2494        Args:
    -2495            *expressions (str | Expression): the SQL code strings to parse.
    -2496                If an `Expression` instance is passed, it will be used as-is.
    -2497                Multiple expressions are combined with an AND operator.
    -2498            append (bool): if `True`, AND the new expressions to any existing expression.
    -2499                Otherwise, this resets the expression.
    -2500            dialect (str): the dialect used to parse the input expressions.
    -2501            copy (bool): if `False`, modify this expression instance in-place.
    -2502            opts (kwargs): other options to use to parse the input expressions.
    -2503
    -2504        Returns:
    -2505            Select: the modified expression.
    -2506        """
    -2507        return _apply_conjunction_builder(
    -2508            *expressions,
    -2509            instance=self,
    -2510            arg="where",
    -2511            append=append,
    -2512            into=Where,
    -2513            dialect=dialect,
    -2514            copy=copy,
    -2515            **opts,
    -2516        )
    +            
    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        )
     
    @@ -23305,37 +23802,37 @@ Otherwise, this resets the expression.
    -
    2518    def having(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2519        """
    -2520        Append to or set the HAVING expressions.
    -2521
    -2522        Example:
    -2523            >>> Select().select("x", "COUNT(y)").from_("tbl").group_by("x").having("COUNT(y) > 3").sql()
    -2524            'SELECT x, COUNT(y) FROM tbl GROUP BY x HAVING COUNT(y) > 3'
    -2525
    -2526        Args:
    -2527            *expressions (str | Expression): the SQL code strings to parse.
    -2528                If an `Expression` instance is passed, it will be used as-is.
    -2529                Multiple expressions are combined with an AND operator.
    -2530            append (bool): if `True`, AND the new expressions to any existing expression.
    -2531                Otherwise, this resets the expression.
    -2532            dialect (str): the dialect used to parse the input expressions.
    -2533            copy (bool): if `False`, modify this expression instance in-place.
    -2534            opts (kwargs): other options to use to parse the input expressions.
    -2535
    -2536        Returns:
    -2537            Select: the modified expression.
    -2538        """
    -2539        return _apply_conjunction_builder(
    -2540            *expressions,
    -2541            instance=self,
    -2542            arg="having",
    -2543            append=append,
    -2544            into=Having,
    -2545            dialect=dialect,
    -2546            copy=copy,
    -2547            **opts,
    -2548        )
    +            
    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        )
     
    @@ -23384,17 +23881,17 @@ Otherwise, this resets the expression.
    -
    2550    def window(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2551        return _apply_list_builder(
    -2552            *expressions,
    -2553            instance=self,
    -2554            arg="windows",
    -2555            append=append,
    -2556            into=Window,
    -2557            dialect=dialect,
    -2558            copy=copy,
    -2559            **opts,
    -2560        )
    +            
    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        )
     
    @@ -23412,17 +23909,17 @@ Otherwise, this resets the expression.
    -
    2562    def qualify(self, *expressions, append=True, dialect=None, copy=True, **opts) -> Select:
    -2563        return _apply_conjunction_builder(
    -2564            *expressions,
    -2565            instance=self,
    -2566            arg="qualify",
    -2567            append=append,
    -2568            into=Qualify,
    -2569            dialect=dialect,
    -2570            copy=copy,
    -2571            **opts,
    -2572        )
    +            
    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        )
     
    @@ -23440,24 +23937,24 @@ Otherwise, this resets the expression.
    -
    2574    def distinct(self, distinct=True, copy=True) -> Select:
    -2575        """
    -2576        Set the OFFSET expression.
    -2577
    -2578        Example:
    -2579            >>> Select().from_("tbl").select("x").distinct().sql()
    -2580            'SELECT DISTINCT x FROM tbl'
    -2581
    -2582        Args:
    -2583            distinct (bool): whether the Select should be distinct
    -2584            copy (bool): if `False`, modify this expression instance in-place.
    -2585
    -2586        Returns:
    -2587            Select: the modified expression.
    -2588        """
    -2589        instance = _maybe_copy(self, copy)
    -2590        instance.set("distinct", Distinct() if distinct else None)
    -2591        return instance
    +            
    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
     
    @@ -23500,42 +23997,42 @@ Otherwise, this resets the expression.
    -
    2593    def ctas(self, table, properties=None, dialect=None, copy=True, **opts) -> Create:
    -2594        """
    -2595        Convert this expression to a CREATE TABLE AS statement.
    -2596
    -2597        Example:
    -2598            >>> Select().select("*").from_("tbl").ctas("x").sql()
    -2599            'CREATE TABLE x AS SELECT * FROM tbl'
    -2600
    -2601        Args:
    -2602            table (str | Expression): the SQL code string to parse as the table name.
    -2603                If another `Expression` instance is passed, it will be used as-is.
    -2604            properties (dict): an optional mapping of table properties
    -2605            dialect (str): the dialect used to parse the input table.
    -2606            copy (bool): if `False`, modify this expression instance in-place.
    -2607            opts (kwargs): other options to use to parse the input table.
    -2608
    -2609        Returns:
    -2610            Create: the CREATE TABLE AS expression
    -2611        """
    -2612        instance = _maybe_copy(self, copy)
    -2613        table_expression = maybe_parse(
    -2614            table,
    -2615            into=Table,
    -2616            dialect=dialect,
    -2617            **opts,
    -2618        )
    -2619        properties_expression = None
    -2620        if properties:
    -2621            properties_expression = Properties.from_dict(properties)
    -2622
    -2623        return Create(
    -2624            this=table_expression,
    -2625            kind="table",
    -2626            expression=instance,
    -2627            properties=properties_expression,
    -2628        )
    +            
    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        )
     
    @@ -23582,29 +24079,29 @@ If another Expression instance is passed,
    -
    2630    def lock(self, update: bool = True, copy: bool = True) -> Select:
    -2631        """
    -2632        Set the locking read mode for this expression.
    -2633
    -2634        Examples:
    -2635            >>> Select().select("x").from_("tbl").where("x = 'a'").lock().sql("mysql")
    -2636            "SELECT x FROM tbl WHERE x = 'a' FOR UPDATE"
    -2637
    -2638            >>> Select().select("x").from_("tbl").where("x = 'a'").lock(update=False).sql("mysql")
    -2639            "SELECT x FROM tbl WHERE x = 'a' FOR SHARE"
    -2640
    -2641        Args:
    -2642            update: if `True`, the locking type will be `FOR UPDATE`, else it will be `FOR SHARE`.
    -2643            copy: if `False`, modify this expression instance in-place.
    -2644
    -2645        Returns:
    -2646            The modified expression.
    -2647        """
    -2648
    -2649        inst = _maybe_copy(self, copy)
    -2650        inst.set("lock", Lock(update=update))
    -2651
    -2652        return inst
    +            
    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
     
    @@ -23722,30 +24219,30 @@ If another Expression instance is passed,
    -
    2667class Subquery(DerivedTable, Unionable):
    -2668    arg_types = {
    -2669        "this": True,
    -2670        "alias": False,
    -2671        "with": False,
    -2672        **QUERY_MODIFIERS,
    -2673    }
    -2674
    -2675    def unnest(self):
    -2676        """
    -2677        Returns the first non subquery.
    -2678        """
    -2679        expression = self
    -2680        while isinstance(expression, Subquery):
    -2681            expression = expression.this
    -2682        return expression
    -2683
    -2684    @property
    -2685    def is_star(self) -> bool:
    -2686        return self.this.is_star
    -2687
    -2688    @property
    -2689    def output_name(self):
    -2690        return self.alias
    +            
    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
     
    @@ -23762,14 +24259,14 @@ If another Expression instance is passed,
    -
    2675    def unnest(self):
    -2676        """
    -2677        Returns the first non subquery.
    -2678        """
    -2679        expression = self
    -2680        while isinstance(expression, Subquery):
    -2681            expression = expression.this
    -2682        return expression
    +            
    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
     
    @@ -23881,19 +24378,19 @@ If another Expression instance is passed,
    -
    2693class TableSample(Expression):
    -2694    arg_types = {
    -2695        "this": False,
    -2696        "method": False,
    -2697        "bucket_numerator": False,
    -2698        "bucket_denominator": False,
    -2699        "bucket_field": False,
    -2700        "percent": False,
    -2701        "rows": False,
    -2702        "size": False,
    -2703        "seed": False,
    -2704        "kind": False,
    -2705    }
    +            
    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    }
     
    @@ -23956,14 +24453,14 @@ If another Expression instance is passed,
    -
    2708class Tag(Expression):
    -2709    """Tags are used for generating arbitrary sql like SELECT <span>x</span>."""
    -2710
    -2711    arg_types = {
    -2712        "this": False,
    -2713        "prefix": False,
    -2714        "postfix": False,
    -2715    }
    +            
    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    }
     
    @@ -24028,14 +24525,15 @@ If another Expression instance is passed,
    -
    2718class Pivot(Expression):
    -2719    arg_types = {
    -2720        "this": False,
    -2721        "alias": False,
    -2722        "expressions": True,
    -2723        "field": True,
    -2724        "unpivot": True,
    -2725    }
    +            
    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    }
     
    @@ -24098,14 +24596,14 @@ If another Expression instance is passed,
    -
    2728class Window(Expression):
    -2729    arg_types = {
    -2730        "this": True,
    -2731        "partition_by": False,
    -2732        "order": False,
    -2733        "spec": False,
    -2734        "alias": False,
    -2735    }
    +            
    2769class Window(Expression):
    +2770    arg_types = {
    +2771        "this": True,
    +2772        "partition_by": False,
    +2773        "order": False,
    +2774        "spec": False,
    +2775        "alias": False,
    +2776    }
     
    @@ -24168,14 +24666,14 @@ If another Expression instance is passed,
    -
    2738class WindowSpec(Expression):
    -2739    arg_types = {
    -2740        "kind": False,
    -2741        "start": False,
    -2742        "start_side": False,
    -2743        "end": False,
    -2744        "end_side": False,
    -2745    }
    +            
    2779class WindowSpec(Expression):
    +2780    arg_types = {
    +2781        "kind": False,
    +2782        "start": False,
    +2783        "start_side": False,
    +2784        "end": False,
    +2785        "end_side": False,
    +2786    }
     
    @@ -24238,8 +24736,8 @@ If another Expression instance is passed,
    -
    2748class Where(Expression):
    -2749    pass
    +            
    2789class Where(Expression):
    +2790    pass
     
    @@ -24302,16 +24800,16 @@ If another Expression instance is passed,
    -
    2752class Star(Expression):
    -2753    arg_types = {"except": False, "replace": False}
    -2754
    -2755    @property
    -2756    def name(self) -> str:
    -2757        return "*"
    -2758
    -2759    @property
    -2760    def output_name(self):
    -2761        return self.name
    +            
    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
     
    @@ -24403,8 +24901,8 @@ If another Expression instance is passed,
    -
    2764class Parameter(Expression):
    -2765    arg_types = {"this": True, "wrapped": False}
    +            
    2805class Parameter(Expression):
    +2806    arg_types = {"this": True, "wrapped": False}
     
    @@ -24467,8 +24965,8 @@ If another Expression instance is passed,
    -
    2768class SessionParameter(Expression):
    -2769    arg_types = {"this": True, "kind": False}
    +            
    2809class SessionParameter(Expression):
    +2810    arg_types = {"this": True, "kind": False}
     
    @@ -24531,8 +25029,8 @@ If another Expression instance is passed,
    -
    2772class Placeholder(Expression):
    -2773    arg_types = {"this": False}
    +            
    2813class Placeholder(Expression):
    +2814    arg_types = {"this": False}
     
    @@ -24595,12 +25093,12 @@ If another Expression instance is passed,
    -
    2776class Null(Condition):
    -2777    arg_types: t.Dict[str, t.Any] = {}
    -2778
    -2779    @property
    -2780    def name(self) -> str:
    -2781        return "NULL"
    +            
    2817class Null(Condition):
    +2818    arg_types: t.Dict[str, t.Any] = {}
    +2819
    +2820    @property
    +2821    def name(self) -> str:
    +2822        return "NULL"
     
    @@ -24669,8 +25167,8 @@ If another Expression instance is passed,
    -
    2784class Boolean(Condition):
    -2785    pass
    +            
    2825class Boolean(Condition):
    +2826    pass
     
    @@ -24739,127 +25237,128 @@ If another Expression instance is passed,
    -
    2788class DataType(Expression):
    -2789    arg_types = {
    -2790        "this": True,
    -2791        "expressions": False,
    -2792        "nested": False,
    -2793        "values": False,
    -2794        "prefix": False,
    -2795    }
    -2796
    -2797    class Type(AutoName):
    -2798        CHAR = auto()
    -2799        NCHAR = auto()
    -2800        VARCHAR = auto()
    -2801        NVARCHAR = auto()
    -2802        TEXT = auto()
    -2803        MEDIUMTEXT = auto()
    -2804        LONGTEXT = auto()
    -2805        MEDIUMBLOB = auto()
    -2806        LONGBLOB = auto()
    -2807        BINARY = auto()
    -2808        VARBINARY = auto()
    -2809        INT = auto()
    -2810        UINT = auto()
    -2811        TINYINT = auto()
    -2812        UTINYINT = auto()
    -2813        SMALLINT = auto()
    -2814        USMALLINT = auto()
    -2815        BIGINT = auto()
    -2816        UBIGINT = auto()
    -2817        FLOAT = auto()
    -2818        DOUBLE = auto()
    -2819        DECIMAL = auto()
    -2820        BIT = auto()
    -2821        BOOLEAN = auto()
    -2822        JSON = auto()
    -2823        JSONB = auto()
    -2824        INTERVAL = auto()
    -2825        TIME = auto()
    -2826        TIMESTAMP = auto()
    -2827        TIMESTAMPTZ = auto()
    -2828        TIMESTAMPLTZ = auto()
    -2829        DATE = auto()
    -2830        DATETIME = auto()
    -2831        ARRAY = auto()
    -2832        MAP = auto()
    -2833        UUID = auto()
    -2834        GEOGRAPHY = auto()
    -2835        GEOMETRY = auto()
    -2836        STRUCT = auto()
    -2837        NULLABLE = auto()
    -2838        HLLSKETCH = auto()
    -2839        HSTORE = auto()
    -2840        SUPER = auto()
    -2841        SERIAL = auto()
    -2842        SMALLSERIAL = auto()
    -2843        BIGSERIAL = auto()
    -2844        XML = auto()
    -2845        UNIQUEIDENTIFIER = auto()
    -2846        MONEY = auto()
    -2847        SMALLMONEY = auto()
    -2848        ROWVERSION = auto()
    -2849        IMAGE = auto()
    -2850        VARIANT = auto()
    -2851        OBJECT = auto()
    -2852        INET = auto()
    -2853        NULL = auto()
    -2854        UNKNOWN = auto()  # Sentinel value, useful for type annotation
    -2855
    -2856    TEXT_TYPES = {
    -2857        Type.CHAR,
    -2858        Type.NCHAR,
    -2859        Type.VARCHAR,
    -2860        Type.NVARCHAR,
    -2861        Type.TEXT,
    -2862    }
    -2863
    -2864    INTEGER_TYPES = {
    -2865        Type.INT,
    -2866        Type.TINYINT,
    -2867        Type.SMALLINT,
    -2868        Type.BIGINT,
    -2869    }
    -2870
    -2871    FLOAT_TYPES = {
    -2872        Type.FLOAT,
    -2873        Type.DOUBLE,
    -2874    }
    -2875
    -2876    NUMERIC_TYPES = {*INTEGER_TYPES, *FLOAT_TYPES}
    -2877
    -2878    TEMPORAL_TYPES = {
    -2879        Type.TIMESTAMP,
    -2880        Type.TIMESTAMPTZ,
    -2881        Type.TIMESTAMPLTZ,
    -2882        Type.DATE,
    -2883        Type.DATETIME,
    -2884    }
    -2885
    -2886    @classmethod
    -2887    def build(
    -2888        cls, dtype: str | DataType | DataType.Type, dialect: DialectType = None, **kwargs
    -2889    ) -> DataType:
    -2890        from sqlglot import parse_one
    -2891
    -2892        if isinstance(dtype, str):
    -2893            if dtype.upper() in cls.Type.__members__:
    -2894                data_type_exp: t.Optional[Expression] = DataType(this=DataType.Type[dtype.upper()])
    -2895            else:
    -2896                data_type_exp = parse_one(dtype, read=dialect, into=DataType)
    -2897            if data_type_exp is None:
    -2898                raise ValueError(f"Unparsable data type value: {dtype}")
    -2899        elif isinstance(dtype, DataType.Type):
    -2900            data_type_exp = DataType(this=dtype)
    -2901        elif isinstance(dtype, DataType):
    -2902            return dtype
    -2903        else:
    -2904            raise ValueError(f"Invalid data type: {type(dtype)}. Expected str or DataType.Type")
    -2905        return DataType(**{**data_type_exp.args, **kwargs})
    -2906
    -2907    def is_type(self, dtype: DataType.Type) -> bool:
    -2908        return self.this == dtype
    +            
    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
     
    @@ -24877,26 +25376,26 @@ If another Expression instance is passed,
    -
    2886    @classmethod
    -2887    def build(
    -2888        cls, dtype: str | DataType | DataType.Type, dialect: DialectType = None, **kwargs
    -2889    ) -> DataType:
    -2890        from sqlglot import parse_one
    -2891
    -2892        if isinstance(dtype, str):
    -2893            if dtype.upper() in cls.Type.__members__:
    -2894                data_type_exp: t.Optional[Expression] = DataType(this=DataType.Type[dtype.upper()])
    -2895            else:
    -2896                data_type_exp = parse_one(dtype, read=dialect, into=DataType)
    -2897            if data_type_exp is None:
    -2898                raise ValueError(f"Unparsable data type value: {dtype}")
    -2899        elif isinstance(dtype, DataType.Type):
    -2900            data_type_exp = DataType(this=dtype)
    -2901        elif isinstance(dtype, DataType):
    -2902            return dtype
    -2903        else:
    -2904            raise ValueError(f"Invalid data type: {type(dtype)}. Expected str or DataType.Type")
    -2905        return DataType(**{**data_type_exp.args, **kwargs})
    +            
    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})
     
    @@ -24914,8 +25413,8 @@ If another Expression instance is passed,
    -
    2907    def is_type(self, dtype: DataType.Type) -> bool:
    -2908        return self.this == dtype
    +            
    2949    def is_type(self, dtype: DataType.Type) -> bool:
    +2950        return self.this == dtype
     
    @@ -24979,64 +25478,65 @@ If another Expression instance is passed,
    -
    2797    class Type(AutoName):
    -2798        CHAR = auto()
    -2799        NCHAR = auto()
    -2800        VARCHAR = auto()
    -2801        NVARCHAR = auto()
    -2802        TEXT = auto()
    -2803        MEDIUMTEXT = auto()
    -2804        LONGTEXT = auto()
    -2805        MEDIUMBLOB = auto()
    -2806        LONGBLOB = auto()
    -2807        BINARY = auto()
    -2808        VARBINARY = auto()
    -2809        INT = auto()
    -2810        UINT = auto()
    -2811        TINYINT = auto()
    -2812        UTINYINT = auto()
    -2813        SMALLINT = auto()
    -2814        USMALLINT = auto()
    -2815        BIGINT = auto()
    -2816        UBIGINT = auto()
    -2817        FLOAT = auto()
    -2818        DOUBLE = auto()
    -2819        DECIMAL = auto()
    -2820        BIT = auto()
    -2821        BOOLEAN = auto()
    -2822        JSON = auto()
    -2823        JSONB = auto()
    -2824        INTERVAL = auto()
    -2825        TIME = auto()
    -2826        TIMESTAMP = auto()
    -2827        TIMESTAMPTZ = auto()
    -2828        TIMESTAMPLTZ = auto()
    -2829        DATE = auto()
    -2830        DATETIME = auto()
    -2831        ARRAY = auto()
    -2832        MAP = auto()
    -2833        UUID = auto()
    -2834        GEOGRAPHY = auto()
    -2835        GEOMETRY = auto()
    -2836        STRUCT = auto()
    -2837        NULLABLE = auto()
    -2838        HLLSKETCH = auto()
    -2839        HSTORE = auto()
    -2840        SUPER = auto()
    -2841        SERIAL = auto()
    -2842        SMALLSERIAL = auto()
    -2843        BIGSERIAL = auto()
    -2844        XML = auto()
    -2845        UNIQUEIDENTIFIER = auto()
    -2846        MONEY = auto()
    -2847        SMALLMONEY = auto()
    -2848        ROWVERSION = auto()
    -2849        IMAGE = auto()
    -2850        VARIANT = auto()
    -2851        OBJECT = auto()
    -2852        INET = auto()
    -2853        NULL = auto()
    -2854        UNKNOWN = auto()  # Sentinel value, useful for type annotation
    +            
    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
     
    @@ -25307,6 +25807,18 @@ If another Expression instance is passed, +
    +
    +
    + BIGDECIMAL = +<Type.BIGDECIMAL: 'BIGDECIMAL'> + + +
    + + + +
    @@ -25750,8 +26262,8 @@ If another Expression instance is passed,
    -
    2912class PseudoType(Expression):
    -2913    pass
    +            
    2954class PseudoType(Expression):
    +2955    pass
     
    @@ -25814,8 +26326,8 @@ If another Expression instance is passed,
    -
    2916class StructKwarg(Expression):
    -2917    arg_types = {"this": True, "expression": True}
    +            
    2958class StructKwarg(Expression):
    +2959    arg_types = {"this": True, "expression": True}
     
    @@ -25878,8 +26390,8 @@ If another Expression instance is passed,
    -
    2921class SubqueryPredicate(Predicate):
    -2922    pass
    +            
    2963class SubqueryPredicate(Predicate):
    +2964    pass
     
    @@ -25948,8 +26460,8 @@ If another Expression instance is passed,
    -
    2925class All(SubqueryPredicate):
    -2926    pass
    +            
    2967class All(SubqueryPredicate):
    +2968    pass
     
    @@ -26018,8 +26530,8 @@ If another Expression instance is passed,
    -
    2929class Any(SubqueryPredicate):
    -2930    pass
    +            
    2971class Any(SubqueryPredicate):
    +2972    pass
     
    @@ -26088,8 +26600,8 @@ If another Expression instance is passed,
    -
    2933class Exists(SubqueryPredicate):
    -2934    pass
    +            
    2975class Exists(SubqueryPredicate):
    +2976    pass
     
    @@ -26158,8 +26670,8 @@ If another Expression instance is passed,
    -
    2939class Command(Expression):
    -2940    arg_types = {"this": True, "expression": False}
    +            
    2981class Command(Expression):
    +2982    arg_types = {"this": True, "expression": False}
     
    @@ -26222,8 +26734,8 @@ If another Expression instance is passed,
    -
    2943class Transaction(Expression):
    -2944    arg_types = {"this": False, "modes": False}
    +            
    2985class Transaction(Expression):
    +2986    arg_types = {"this": False, "modes": False}
     
    @@ -26286,8 +26798,8 @@ If another Expression instance is passed,
    -
    2947class Commit(Expression):
    -2948    arg_types = {"chain": False}
    +            
    2989class Commit(Expression):
    +2990    arg_types = {"chain": False}
     
    @@ -26350,8 +26862,8 @@ If another Expression instance is passed,
    -
    2951class Rollback(Expression):
    -2952    arg_types = {"savepoint": False}
    +            
    2993class Rollback(Expression):
    +2994    arg_types = {"savepoint": False}
     
    @@ -26414,8 +26926,8 @@ If another Expression instance is passed,
    -
    2955class AlterTable(Expression):
    -2956    arg_types = {"this": True, "actions": True, "exists": False}
    +            
    2997class AlterTable(Expression):
    +2998    arg_types = {"this": True, "actions": True, "exists": False}
     
    @@ -26478,8 +26990,8 @@ If another Expression instance is passed,
    -
    2959class AddConstraint(Expression):
    -2960    arg_types = {"this": False, "expression": False, "enforced": False}
    +            
    3001class AddConstraint(Expression):
    +3002    arg_types = {"this": False, "expression": False, "enforced": False}
     
    @@ -26542,8 +27054,8 @@ If another Expression instance is passed,
    -
    2963class DropPartition(Expression):
    -2964    arg_types = {"expressions": True, "exists": False}
    +            
    3005class DropPartition(Expression):
    +3006    arg_types = {"expressions": True, "exists": False}
     
    @@ -26606,16 +27118,16 @@ If another Expression instance is passed,
    -
    2968class Binary(Expression):
    -2969    arg_types = {"this": True, "expression": True}
    -2970
    -2971    @property
    -2972    def left(self):
    -2973        return self.this
    -2974
    -2975    @property
    -2976    def right(self):
    -2977        return self.expression
    +            
    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
     
    @@ -26678,8 +27190,8 @@ If another Expression instance is passed,
    -
    2980class Add(Binary):
    -2981    pass
    +            
    3022class Add(Binary):
    +3023    pass
     
    @@ -26742,8 +27254,8 @@ If another Expression instance is passed,
    -
    2984class Connector(Binary, Condition):
    -2985    pass
    +            
    3026class Connector(Binary, Condition):
    +3027    pass
     
    @@ -26812,8 +27324,8 @@ If another Expression instance is passed,
    -
    2988class And(Connector):
    -2989    pass
    +            
    3030class And(Connector):
    +3031    pass
     
    @@ -26882,8 +27394,8 @@ If another Expression instance is passed,
    -
    2992class Or(Connector):
    -2993    pass
    +            
    3034class Or(Connector):
    +3035    pass
     
    @@ -26952,8 +27464,8 @@ If another Expression instance is passed,
    -
    2996class BitwiseAnd(Binary):
    -2997    pass
    +            
    3038class BitwiseAnd(Binary):
    +3039    pass
     
    @@ -27016,8 +27528,8 @@ If another Expression instance is passed,
    -
    3000class BitwiseLeftShift(Binary):
    -3001    pass
    +            
    3042class BitwiseLeftShift(Binary):
    +3043    pass
     
    @@ -27080,8 +27592,8 @@ If another Expression instance is passed,
    -
    3004class BitwiseOr(Binary):
    -3005    pass
    +            
    3046class BitwiseOr(Binary):
    +3047    pass
     
    @@ -27144,8 +27656,8 @@ If another Expression instance is passed,
    -
    3008class BitwiseRightShift(Binary):
    -3009    pass
    +            
    3050class BitwiseRightShift(Binary):
    +3051    pass
     
    @@ -27208,8 +27720,8 @@ If another Expression instance is passed,
    -
    3012class BitwiseXor(Binary):
    -3013    pass
    +            
    3054class BitwiseXor(Binary):
    +3055    pass
     
    @@ -27272,8 +27784,8 @@ If another Expression instance is passed,
    -
    3016class Div(Binary):
    -3017    pass
    +            
    3058class Div(Binary):
    +3059    pass
     
    @@ -27336,8 +27848,8 @@ If another Expression instance is passed,
    -
    3020class Overlaps(Binary):
    -3021    pass
    +            
    3062class Overlaps(Binary):
    +3063    pass
     
    @@ -27400,24 +27912,24 @@ If another Expression instance is passed,
    -
    3024class Dot(Binary):
    -3025    @property
    -3026    def name(self) -> str:
    -3027        return self.expression.name
    -3028
    -3029    @classmethod
    -3030    def build(self, expressions: t.Sequence[Expression]) -> Dot:
    -3031        """Build a Dot object with a sequence of expressions."""
    -3032        if len(expressions) < 2:
    -3033            raise ValueError(f"Dot requires >= 2 expressions.")
    -3034
    -3035        a, b, *expressions = expressions
    -3036        dot = Dot(this=a, expression=b)
    -3037
    -3038        for expression in expressions:
    -3039            dot = Dot(this=dot, expression=expression)
    -3040
    -3041        return dot
    +            
    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
     
    @@ -27435,19 +27947,19 @@ If another Expression instance is passed,
    -
    3029    @classmethod
    -3030    def build(self, expressions: t.Sequence[Expression]) -> Dot:
    -3031        """Build a Dot object with a sequence of expressions."""
    -3032        if len(expressions) < 2:
    -3033            raise ValueError(f"Dot requires >= 2 expressions.")
    -3034
    -3035        a, b, *expressions = expressions
    -3036        dot = Dot(this=a, expression=b)
    -3037
    -3038        for expression in expressions:
    -3039            dot = Dot(this=dot, expression=expression)
    -3040
    -3041        return dot
    +            
    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
     
    @@ -27513,8 +28025,8 @@ If another Expression instance is passed,
    -
    3044class DPipe(Binary):
    -3045    pass
    +            
    3086class DPipe(Binary):
    +3087    pass
     
    @@ -27577,8 +28089,8 @@ If another Expression instance is passed,
    -
    3048class EQ(Binary, Predicate):
    -3049    pass
    +            
    3090class EQ(Binary, Predicate):
    +3091    pass
     
    @@ -27647,8 +28159,8 @@ If another Expression instance is passed,
    -
    3052class NullSafeEQ(Binary, Predicate):
    -3053    pass
    +            
    3094class NullSafeEQ(Binary, Predicate):
    +3095    pass
     
    @@ -27717,8 +28229,8 @@ If another Expression instance is passed,
    -
    3056class NullSafeNEQ(Binary, Predicate):
    -3057    pass
    +            
    3098class NullSafeNEQ(Binary, Predicate):
    +3099    pass
     
    @@ -27787,8 +28299,8 @@ If another Expression instance is passed,
    -
    3060class Distance(Binary):
    -3061    pass
    +            
    3102class Distance(Binary):
    +3103    pass
     
    @@ -27851,8 +28363,8 @@ If another Expression instance is passed,
    -
    3064class Escape(Binary):
    -3065    pass
    +            
    3106class Escape(Binary):
    +3107    pass
     
    @@ -27915,8 +28427,8 @@ If another Expression instance is passed,
    -
    3068class Glob(Binary, Predicate):
    -3069    pass
    +            
    3110class Glob(Binary, Predicate):
    +3111    pass
     
    @@ -27985,8 +28497,8 @@ If another Expression instance is passed,
    -
    3072class GT(Binary, Predicate):
    -3073    pass
    +            
    3114class GT(Binary, Predicate):
    +3115    pass
     
    @@ -28055,8 +28567,8 @@ If another Expression instance is passed,
    -
    3076class GTE(Binary, Predicate):
    -3077    pass
    +            
    3118class GTE(Binary, Predicate):
    +3119    pass
     
    @@ -28125,8 +28637,8 @@ If another Expression instance is passed,
    -
    3080class ILike(Binary, Predicate):
    -3081    pass
    +            
    3122class ILike(Binary, Predicate):
    +3123    pass
     
    @@ -28195,8 +28707,8 @@ If another Expression instance is passed,
    -
    3084class ILikeAny(Binary, Predicate):
    -3085    pass
    +            
    3126class ILikeAny(Binary, Predicate):
    +3127    pass
     
    @@ -28265,8 +28777,8 @@ If another Expression instance is passed,
    -
    3088class IntDiv(Binary):
    -3089    pass
    +            
    3130class IntDiv(Binary):
    +3131    pass
     
    @@ -28329,8 +28841,8 @@ If another Expression instance is passed,
    -
    3092class Is(Binary, Predicate):
    -3093    pass
    +            
    3134class Is(Binary, Predicate):
    +3135    pass
     
    @@ -28399,8 +28911,8 @@ If another Expression instance is passed,
    -
    3096class Kwarg(Binary):
    -3097    """Kwarg in special functions like func(kwarg => y)."""
    +            
    3138class Kwarg(Binary):
    +3139    """Kwarg in special functions like func(kwarg => y)."""
     
    @@ -28465,8 +28977,8 @@ If another Expression instance is passed,
    -
    3100class Like(Binary, Predicate):
    -3101    pass
    +            
    3142class Like(Binary, Predicate):
    +3143    pass
     
    @@ -28535,8 +29047,8 @@ If another Expression instance is passed,
    -
    3104class LikeAny(Binary, Predicate):
    -3105    pass
    +            
    3146class LikeAny(Binary, Predicate):
    +3147    pass
     
    @@ -28605,8 +29117,8 @@ If another Expression instance is passed,
    -
    3108class LT(Binary, Predicate):
    -3109    pass
    +            
    3150class LT(Binary, Predicate):
    +3151    pass
     
    @@ -28675,8 +29187,8 @@ If another Expression instance is passed,
    -
    3112class LTE(Binary, Predicate):
    -3113    pass
    +            
    3154class LTE(Binary, Predicate):
    +3155    pass
     
    @@ -28745,8 +29257,8 @@ If another Expression instance is passed,
    -
    3116class Mod(Binary):
    -3117    pass
    +            
    3158class Mod(Binary):
    +3159    pass
     
    @@ -28809,8 +29321,8 @@ If another Expression instance is passed,
    -
    3120class Mul(Binary):
    -3121    pass
    +            
    3162class Mul(Binary):
    +3163    pass
     
    @@ -28873,8 +29385,8 @@ If another Expression instance is passed,
    -
    3124class NEQ(Binary, Predicate):
    -3125    pass
    +            
    3166class NEQ(Binary, Predicate):
    +3167    pass
     
    @@ -28943,8 +29455,8 @@ If another Expression instance is passed,
    -
    3128class SimilarTo(Binary, Predicate):
    -3129    pass
    +            
    3170class SimilarTo(Binary, Predicate):
    +3171    pass
     
    @@ -29013,8 +29525,8 @@ If another Expression instance is passed,
    -
    3132class Slice(Binary):
    -3133    arg_types = {"this": False, "expression": False}
    +            
    3174class Slice(Binary):
    +3175    arg_types = {"this": False, "expression": False}
     
    @@ -29077,8 +29589,8 @@ If another Expression instance is passed,
    -
    3136class Sub(Binary):
    -3137    pass
    +            
    3178class Sub(Binary):
    +3179    pass
     
    @@ -29141,8 +29653,8 @@ If another Expression instance is passed,
    -
    3140class ArrayOverlaps(Binary):
    -3141    pass
    +            
    3182class ArrayOverlaps(Binary):
    +3183    pass
     
    @@ -29205,8 +29717,8 @@ If another Expression instance is passed,
    -
    3146class Unary(Expression):
    -3147    pass
    +            
    3188class Unary(Expression):
    +3189    pass
     
    @@ -29269,8 +29781,8 @@ If another Expression instance is passed,
    -
    3150class BitwiseNot(Unary):
    -3151    pass
    +            
    3192class BitwiseNot(Unary):
    +3193    pass
     
    @@ -29333,8 +29845,8 @@ If another Expression instance is passed,
    -
    3154class Not(Unary, Condition):
    -3155    pass
    +            
    3196class Not(Unary, Condition):
    +3197    pass
     
    @@ -29403,8 +29915,8 @@ If another Expression instance is passed,
    -
    3158class Paren(Unary, Condition):
    -3159    arg_types = {"this": True, "with": False}
    +            
    3200class Paren(Unary, Condition):
    +3201    arg_types = {"this": True, "with": False}
     
    @@ -29473,8 +29985,8 @@ If another Expression instance is passed,
    -
    3162class Neg(Unary):
    -3163    pass
    +            
    3204class Neg(Unary):
    +3205    pass
     
    @@ -29537,12 +30049,12 @@ If another Expression instance is passed,
    -
    3167class Alias(Expression):
    -3168    arg_types = {"this": True, "alias": False}
    -3169
    -3170    @property
    -3171    def output_name(self):
    -3172        return self.alias
    +            
    3208class Alias(Expression):
    +3209    arg_types = {"this": True, "alias": False}
    +3210
    +3211    @property
    +3212    def output_name(self):
    +3213        return self.alias
     
    @@ -29634,12 +30146,12 @@ If another Expression instance is passed,
    -
    3175class Aliases(Expression):
    -3176    arg_types = {"this": True, "expressions": True}
    -3177
    -3178    @property
    -3179    def aliases(self):
    -3180        return self.expressions
    +            
    3216class Aliases(Expression):
    +3217    arg_types = {"this": True, "expressions": True}
    +3218
    +3219    @property
    +3220    def aliases(self):
    +3221        return self.expressions
     
    @@ -29702,8 +30214,8 @@ If another Expression instance is passed,
    -
    3183class AtTimeZone(Expression):
    -3184    arg_types = {"this": True, "zone": True}
    +            
    3224class AtTimeZone(Expression):
    +3225    arg_types = {"this": True, "zone": True}
     
    @@ -29766,8 +30278,8 @@ If another Expression instance is passed,
    -
    3187class Between(Predicate):
    -3188    arg_types = {"this": True, "low": True, "high": True}
    +            
    3228class Between(Predicate):
    +3229    arg_types = {"this": True, "low": True, "high": True}
     
    @@ -29836,8 +30348,8 @@ If another Expression instance is passed,
    -
    3191class Bracket(Condition):
    -3192    arg_types = {"this": True, "expressions": True}
    +            
    3232class Bracket(Condition):
    +3233    arg_types = {"this": True, "expressions": True}
     
    @@ -29906,8 +30418,8 @@ If another Expression instance is passed,
    -
    3195class Distinct(Expression):
    -3196    arg_types = {"expressions": False, "on": False}
    +            
    3236class Distinct(Expression):
    +3237    arg_types = {"expressions": False, "on": False}
     
    @@ -29970,15 +30482,15 @@ If another Expression instance is passed,
    -
    3199class In(Predicate):
    -3200    arg_types = {
    -3201        "this": True,
    -3202        "expressions": False,
    -3203        "query": False,
    -3204        "unnest": False,
    -3205        "field": False,
    -3206        "is_global": False,
    -3207    }
    +            
    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    }
     
    @@ -30047,18 +30559,18 @@ If another Expression instance is passed,
    -
    3210class TimeUnit(Expression):
    -3211    """Automatically converts unit arg into a var."""
    -3212
    -3213    arg_types = {"unit": False}
    -3214
    -3215    def __init__(self, **args):
    -3216        unit = args.get("unit")
    -3217        if isinstance(unit, (Column, Literal)):
    -3218            args["unit"] = Var(this=unit.name)
    -3219        elif isinstance(unit, Week):
    -3220            unit.set("this", Var(this=unit.this.name))
    -3221        super().__init__(**args)
    +            
    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)
     
    @@ -30076,13 +30588,13 @@ If another Expression instance is passed,
    -
    3215    def __init__(self, **args):
    -3216        unit = args.get("unit")
    -3217        if isinstance(unit, (Column, Literal)):
    -3218            args["unit"] = Var(this=unit.name)
    -3219        elif isinstance(unit, Week):
    -3220            unit.set("this", Var(this=unit.this.name))
    -3221        super().__init__(**args)
    +            
    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)
     
    @@ -30145,8 +30657,8 @@ If another Expression instance is passed,
    -
    3224class Interval(TimeUnit):
    -3225    arg_types = {"this": False, "unit": False}
    +            
    3265class Interval(TimeUnit):
    +3266    arg_types = {"this": False, "unit": False}
     
    @@ -30212,8 +30724,8 @@ If another Expression instance is passed,
    -
    3228class IgnoreNulls(Expression):
    -3229    pass
    +            
    3269class IgnoreNulls(Expression):
    +3270    pass
     
    @@ -30276,8 +30788,8 @@ If another Expression instance is passed,
    -
    3232class RespectNulls(Expression):
    -3233    pass
    +            
    3273class RespectNulls(Expression):
    +3274    pass
     
    @@ -30340,53 +30852,53 @@ If another Expression instance is passed,
    -
    3237class Func(Condition):
    -3238    """
    -3239    The base class for all function expressions.
    -3240
    -3241    Attributes:
    -3242        is_var_len_args (bool): if set to True the last argument defined in arg_types will be
    -3243            treated as a variable length argument and the argument's value will be stored as a list.
    -3244        _sql_names (list): determines the SQL name (1st item in the list) and aliases (subsequent items)
    -3245            for this function expression. These values are used to map this node to a name during parsing
    -3246            as well as to provide the function's name during SQL string generation. By default the SQL
    -3247            name is set to the expression's class name transformed to snake case.
    -3248    """
    -3249
    -3250    is_var_len_args = False
    -3251
    -3252    @classmethod
    -3253    def from_arg_list(cls, args):
    -3254        if cls.is_var_len_args:
    -3255            all_arg_keys = list(cls.arg_types)
    -3256            # If this function supports variable length argument treat the last argument as such.
    -3257            non_var_len_arg_keys = all_arg_keys[:-1] if cls.is_var_len_args else all_arg_keys
    -3258            num_non_var = len(non_var_len_arg_keys)
    -3259
    -3260            args_dict = {arg_key: arg for arg, arg_key in zip(args, non_var_len_arg_keys)}
    -3261            args_dict[all_arg_keys[-1]] = args[num_non_var:]
    -3262        else:
    -3263            args_dict = {arg_key: arg for arg, arg_key in zip(args, cls.arg_types)}
    -3264
    -3265        return cls(**args_dict)
    -3266
    -3267    @classmethod
    -3268    def sql_names(cls):
    -3269        if cls is Func:
    -3270            raise NotImplementedError(
    -3271                "SQL name is only supported by concrete function implementations"
    -3272            )
    -3273        if "_sql_names" not in cls.__dict__:
    -3274            cls._sql_names = [camel_to_snake_case(cls.__name__)]
    -3275        return cls._sql_names
    -3276
    -3277    @classmethod
    -3278    def sql_name(cls):
    -3279        return cls.sql_names()[0]
    -3280
    -3281    @classmethod
    -3282    def default_parser_mappings(cls):
    -3283        return {name: cls.from_arg_list for name in cls.sql_names()}
    +            
    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()}
     
    @@ -30417,20 +30929,20 @@ name is set to the expression's class name transformed to snake case.
    -
    3252    @classmethod
    -3253    def from_arg_list(cls, args):
    -3254        if cls.is_var_len_args:
    -3255            all_arg_keys = list(cls.arg_types)
    -3256            # If this function supports variable length argument treat the last argument as such.
    -3257            non_var_len_arg_keys = all_arg_keys[:-1] if cls.is_var_len_args else all_arg_keys
    -3258            num_non_var = len(non_var_len_arg_keys)
    -3259
    -3260            args_dict = {arg_key: arg for arg, arg_key in zip(args, non_var_len_arg_keys)}
    -3261            args_dict[all_arg_keys[-1]] = args[num_non_var:]
    -3262        else:
    -3263            args_dict = {arg_key: arg for arg, arg_key in zip(args, cls.arg_types)}
    -3264
    -3265        return cls(**args_dict)
    +            
    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)
     
    @@ -30449,15 +30961,15 @@ name is set to the expression's class name transformed to snake case.
    -
    3267    @classmethod
    -3268    def sql_names(cls):
    -3269        if cls is Func:
    -3270            raise NotImplementedError(
    -3271                "SQL name is only supported by concrete function implementations"
    -3272            )
    -3273        if "_sql_names" not in cls.__dict__:
    -3274            cls._sql_names = [camel_to_snake_case(cls.__name__)]
    -3275        return cls._sql_names
    +            
    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
     
    @@ -30476,9 +30988,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3277    @classmethod
    -3278    def sql_name(cls):
    -3279        return cls.sql_names()[0]
    +            
    3318    @classmethod
    +3319    def sql_name(cls):
    +3320        return cls.sql_names()[0]
     
    @@ -30497,9 +31009,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3281    @classmethod
    -3282    def default_parser_mappings(cls):
    -3283        return {name: cls.from_arg_list for name in cls.sql_names()}
    +            
    3322    @classmethod
    +3323    def default_parser_mappings(cls):
    +3324        return {name: cls.from_arg_list for name in cls.sql_names()}
     
    @@ -30569,8 +31081,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3286class AggFunc(Func):
    -3287    pass
    +            
    3327class AggFunc(Func):
    +3328    pass
     
    @@ -30646,8 +31158,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3290class Abs(Func):
    -3291    pass
    +            
    3331class Abs(Func):
    +3332    pass
     
    @@ -30723,9 +31235,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3294class Anonymous(Func):
    -3295    arg_types = {"this": True, "expressions": False}
    -3296    is_var_len_args = True
    +            
    3335class Anonymous(Func):
    +3336    arg_types = {"this": True, "expressions": False}
    +3337    is_var_len_args = True
     
    @@ -30801,9 +31313,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3301class Hll(AggFunc):
    -3302    arg_types = {"this": True, "expressions": False}
    -3303    is_var_len_args = True
    +            
    3342class Hll(AggFunc):
    +3343    arg_types = {"this": True, "expressions": False}
    +3344    is_var_len_args = True
     
    @@ -30879,8 +31391,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3306class ApproxDistinct(AggFunc):
    -3307    arg_types = {"this": True, "accuracy": False}
    +            
    3347class ApproxDistinct(AggFunc):
    +3348    arg_types = {"this": True, "accuracy": False}
     
    @@ -30956,9 +31468,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3310class Array(Func):
    -3311    arg_types = {"expressions": False}
    -3312    is_var_len_args = True
    +            
    3351class Array(Func):
    +3352    arg_types = {"expressions": False}
    +3353    is_var_len_args = True
     
    @@ -31034,8 +31546,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3316class ToChar(Func):
    -3317    arg_types = {"this": True, "format": False}
    +            
    3357class ToChar(Func):
    +3358    arg_types = {"this": True, "format": False}
     
    @@ -31111,8 +31623,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3320class GenerateSeries(Func):
    -3321    arg_types = {"start": True, "end": True, "step": False}
    +            
    3361class GenerateSeries(Func):
    +3362    arg_types = {"start": True, "end": True, "step": False}
     
    @@ -31188,8 +31700,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3324class ArrayAgg(AggFunc):
    -3325    pass
    +            
    3365class ArrayAgg(AggFunc):
    +3366    pass
     
    @@ -31265,8 +31777,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3328class ArrayAll(Func):
    -3329    arg_types = {"this": True, "expression": True}
    +            
    3369class ArrayAll(Func):
    +3370    arg_types = {"this": True, "expression": True}
     
    @@ -31342,8 +31854,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3332class ArrayAny(Func):
    -3333    arg_types = {"this": True, "expression": True}
    +            
    3373class ArrayAny(Func):
    +3374    arg_types = {"this": True, "expression": True}
     
    @@ -31419,9 +31931,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3336class ArrayConcat(Func):
    -3337    arg_types = {"this": True, "expressions": False}
    -3338    is_var_len_args = True
    +            
    3377class ArrayConcat(Func):
    +3378    arg_types = {"this": True, "expressions": False}
    +3379    is_var_len_args = True
     
    @@ -31497,8 +32009,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3341class ArrayContains(Binary, Func):
    -3342    pass
    +            
    3382class ArrayContains(Binary, Func):
    +3383    pass
     
    @@ -31574,8 +32086,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3345class ArrayContained(Binary):
    -3346    pass
    +            
    3386class ArrayContained(Binary):
    +3387    pass
     
    @@ -31638,9 +32150,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3349class ArrayFilter(Func):
    -3350    arg_types = {"this": True, "expression": True}
    -3351    _sql_names = ["FILTER", "ARRAY_FILTER"]
    +            
    3390class ArrayFilter(Func):
    +3391    arg_types = {"this": True, "expression": True}
    +3392    _sql_names = ["FILTER", "ARRAY_FILTER"]
     
    @@ -31716,8 +32228,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3354class ArrayJoin(Func):
    -3355    arg_types = {"this": True, "expression": True, "null": False}
    +            
    3395class ArrayJoin(Func):
    +3396    arg_types = {"this": True, "expression": True, "null": False}
     
    @@ -31793,8 +32305,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3358class ArraySize(Func):
    -3359    arg_types = {"this": True, "expression": False}
    +            
    3399class ArraySize(Func):
    +3400    arg_types = {"this": True, "expression": False}
     
    @@ -31870,8 +32382,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3362class ArraySort(Func):
    -3363    arg_types = {"this": True, "expression": False}
    +            
    3403class ArraySort(Func):
    +3404    arg_types = {"this": True, "expression": False}
     
    @@ -31947,8 +32459,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3366class ArraySum(Func):
    -3367    pass
    +            
    3407class ArraySum(Func):
    +3408    pass
     
    @@ -32024,8 +32536,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3370class ArrayUnionAgg(AggFunc):
    -3371    pass
    +            
    3411class ArrayUnionAgg(AggFunc):
    +3412    pass
     
    @@ -32101,8 +32613,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3374class Avg(AggFunc):
    -3375    pass
    +            
    3415class Avg(AggFunc):
    +3416    pass
     
    @@ -32178,8 +32690,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3378class AnyValue(AggFunc):
    -3379    pass
    +            
    3419class AnyValue(AggFunc):
    +3420    pass
     
    @@ -32255,8 +32767,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3382class Case(Func):
    -3383    arg_types = {"this": False, "ifs": True, "default": False}
    +            
    3423class Case(Func):
    +3424    arg_types = {"this": False, "ifs": True, "default": False}
     
    @@ -32332,23 +32844,23 @@ name is set to the expression's class name transformed to snake case.
    -
    3386class Cast(Func):
    -3387    arg_types = {"this": True, "to": True}
    -3388
    -3389    @property
    -3390    def name(self) -> str:
    -3391        return self.this.name
    -3392
    -3393    @property
    -3394    def to(self):
    -3395        return self.args["to"]
    -3396
    -3397    @property
    -3398    def output_name(self):
    -3399        return self.name
    -3400
    -3401    def is_type(self, dtype: DataType.Type) -> bool:
    -3402        return self.to.is_type(dtype)
    +            
    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)
     
    @@ -32395,8 +32907,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3401    def is_type(self, dtype: DataType.Type) -> bool:
    -3402        return self.to.is_type(dtype)
    +            
    3442    def is_type(self, dtype: DataType.Type) -> bool:
    +3443        return self.to.is_type(dtype)
     
    @@ -32472,8 +32984,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3405class Collate(Binary):
    -3406    pass
    +            
    3446class Collate(Binary):
    +3447    pass
     
    @@ -32536,8 +33048,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3409class TryCast(Cast):
    -3410    pass
    +            
    3450class TryCast(Cast):
    +3451    pass
     
    @@ -32617,9 +33129,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3413class Ceil(Func):
    -3414    arg_types = {"this": True, "decimals": False}
    -3415    _sql_names = ["CEIL", "CEILING"]
    +            
    3454class Ceil(Func):
    +3455    arg_types = {"this": True, "decimals": False}
    +3456    _sql_names = ["CEIL", "CEILING"]
     
    @@ -32695,9 +33207,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3418class Coalesce(Func):
    -3419    arg_types = {"this": True, "expressions": False}
    -3420    is_var_len_args = True
    +            
    3459class Coalesce(Func):
    +3460    arg_types = {"this": True, "expressions": False}
    +3461    is_var_len_args = True
     
    @@ -32773,9 +33285,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3423class Concat(Func):
    -3424    arg_types = {"expressions": True}
    -3425    is_var_len_args = True
    +            
    3464class Concat(Func):
    +3465    arg_types = {"expressions": True}
    +3466    is_var_len_args = True
     
    @@ -32851,8 +33363,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3428class ConcatWs(Concat):
    -3429    _sql_names = ["CONCAT_WS"]
    +            
    3469class ConcatWs(Concat):
    +3470    _sql_names = ["CONCAT_WS"]
     
    @@ -32928,8 +33440,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3432class Count(AggFunc):
    -3433    arg_types = {"this": False}
    +            
    3473class Count(AggFunc):
    +3474    arg_types = {"this": False}
     
    @@ -33005,8 +33517,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3436class CountIf(AggFunc):
    -3437    pass
    +            
    3477class CountIf(AggFunc):
    +3478    pass
     
    @@ -33082,8 +33594,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3440class CurrentDate(Func):
    -3441    arg_types = {"this": False}
    +            
    3481class CurrentDate(Func):
    +3482    arg_types = {"this": False}
     
    @@ -33159,8 +33671,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3444class CurrentDatetime(Func):
    -3445    arg_types = {"this": False}
    +            
    3485class CurrentDatetime(Func):
    +3486    arg_types = {"this": False}
     
    @@ -33236,8 +33748,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3448class CurrentTime(Func):
    -3449    arg_types = {"this": False}
    +            
    3489class CurrentTime(Func):
    +3490    arg_types = {"this": False}
     
    @@ -33313,8 +33825,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3452class CurrentTimestamp(Func):
    -3453    arg_types = {"this": False}
    +            
    3493class CurrentTimestamp(Func):
    +3494    arg_types = {"this": False}
     
    @@ -33375,6 +33887,83 @@ name is set to the expression's class name transformed to snake case.
    or_
    not_
    +
    + +
    +
    +
    + +
    + + class + CurrentUser(Func): + + + +
    + +
    3497class CurrentUser(Func):
    +3498    arg_types = {"this": False}
    +
    + + + + + @@ -33390,8 +33979,8 @@ name is set to the expression's class name transformed to snake case. -
    3456class DateAdd(Func, TimeUnit):
    -3457    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3501class DateAdd(Func, TimeUnit):
    +3502    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -33470,8 +34059,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3460class DateSub(Func, TimeUnit):
    -3461    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3505class DateSub(Func, TimeUnit):
    +3506    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -33550,9 +34139,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3464class DateDiff(Func, TimeUnit):
    -3465    _sql_names = ["DATEDIFF", "DATE_DIFF"]
    -3466    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3509class DateDiff(Func, TimeUnit):
    +3510    _sql_names = ["DATEDIFF", "DATE_DIFF"]
    +3511    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -33631,8 +34220,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3469class DateTrunc(Func):
    -3470    arg_types = {"unit": True, "this": True, "zone": False}
    +            
    3514class DateTrunc(Func):
    +3515    arg_types = {"unit": True, "this": True, "zone": False}
     
    @@ -33708,8 +34297,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3473class DatetimeAdd(Func, TimeUnit):
    -3474    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3518class DatetimeAdd(Func, TimeUnit):
    +3519    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -33788,8 +34377,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3477class DatetimeSub(Func, TimeUnit):
    -3478    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3522class DatetimeSub(Func, TimeUnit):
    +3523    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -33868,8 +34457,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3481class DatetimeDiff(Func, TimeUnit):
    -3482    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3526class DatetimeDiff(Func, TimeUnit):
    +3527    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -33948,8 +34537,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3485class DatetimeTrunc(Func, TimeUnit):
    -3486    arg_types = {"this": True, "unit": True, "zone": False}
    +            
    3530class DatetimeTrunc(Func, TimeUnit):
    +3531    arg_types = {"this": True, "unit": True, "zone": False}
     
    @@ -34028,8 +34617,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3489class DayOfWeek(Func):
    -3490    _sql_names = ["DAY_OF_WEEK", "DAYOFWEEK"]
    +            
    3534class DayOfWeek(Func):
    +3535    _sql_names = ["DAY_OF_WEEK", "DAYOFWEEK"]
     
    @@ -34105,8 +34694,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3493class DayOfMonth(Func):
    -3494    _sql_names = ["DAY_OF_MONTH", "DAYOFMONTH"]
    +            
    3538class DayOfMonth(Func):
    +3539    _sql_names = ["DAY_OF_MONTH", "DAYOFMONTH"]
     
    @@ -34182,8 +34771,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3497class DayOfYear(Func):
    -3498    _sql_names = ["DAY_OF_YEAR", "DAYOFYEAR"]
    +            
    3542class DayOfYear(Func):
    +3543    _sql_names = ["DAY_OF_YEAR", "DAYOFYEAR"]
     
    @@ -34259,8 +34848,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3501class WeekOfYear(Func):
    -3502    _sql_names = ["WEEK_OF_YEAR", "WEEKOFYEAR"]
    +            
    3546class WeekOfYear(Func):
    +3547    _sql_names = ["WEEK_OF_YEAR", "WEEKOFYEAR"]
     
    @@ -34336,8 +34925,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3505class LastDateOfMonth(Func):
    -3506    pass
    +            
    3550class LastDateOfMonth(Func):
    +3551    pass
     
    @@ -34413,8 +35002,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3509class Extract(Func):
    -3510    arg_types = {"this": True, "expression": True}
    +            
    3554class Extract(Func):
    +3555    arg_types = {"this": True, "expression": True}
     
    @@ -34490,8 +35079,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3513class TimestampAdd(Func, TimeUnit):
    -3514    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3558class TimestampAdd(Func, TimeUnit):
    +3559    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -34570,8 +35159,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3517class TimestampSub(Func, TimeUnit):
    -3518    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3562class TimestampSub(Func, TimeUnit):
    +3563    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -34650,8 +35239,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3521class TimestampDiff(Func, TimeUnit):
    -3522    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3566class TimestampDiff(Func, TimeUnit):
    +3567    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -34730,8 +35319,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3525class TimestampTrunc(Func, TimeUnit):
    -3526    arg_types = {"this": True, "unit": True, "zone": False}
    +            
    3570class TimestampTrunc(Func, TimeUnit):
    +3571    arg_types = {"this": True, "unit": True, "zone": False}
     
    @@ -34810,8 +35399,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3529class TimeAdd(Func, TimeUnit):
    -3530    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3574class TimeAdd(Func, TimeUnit):
    +3575    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -34890,8 +35479,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3533class TimeSub(Func, TimeUnit):
    -3534    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3578class TimeSub(Func, TimeUnit):
    +3579    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -34970,8 +35559,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3537class TimeDiff(Func, TimeUnit):
    -3538    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    3582class TimeDiff(Func, TimeUnit):
    +3583    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -35050,8 +35639,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3541class TimeTrunc(Func, TimeUnit):
    -3542    arg_types = {"this": True, "unit": True, "zone": False}
    +            
    3586class TimeTrunc(Func, TimeUnit):
    +3587    arg_types = {"this": True, "unit": True, "zone": False}
     
    @@ -35130,9 +35719,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3545class DateFromParts(Func):
    -3546    _sql_names = ["DATEFROMPARTS"]
    -3547    arg_types = {"year": True, "month": True, "day": True}
    +            
    3590class DateFromParts(Func):
    +3591    _sql_names = ["DATEFROMPARTS"]
    +3592    arg_types = {"year": True, "month": True, "day": True}
     
    @@ -35208,8 +35797,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3550class DateStrToDate(Func):
    -3551    pass
    +            
    3595class DateStrToDate(Func):
    +3596    pass
     
    @@ -35285,8 +35874,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3554class DateToDateStr(Func):
    -3555    pass
    +            
    3599class DateToDateStr(Func):
    +3600    pass
     
    @@ -35362,8 +35951,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3558class DateToDi(Func):
    -3559    pass
    +            
    3603class DateToDi(Func):
    +3604    pass
     
    @@ -35439,8 +36028,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3562class Day(Func):
    -3563    pass
    +            
    3607class Day(Func):
    +3608    pass
     
    @@ -35516,8 +36105,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3566class Decode(Func):
    -3567    arg_types = {"this": True, "charset": True, "replace": False}
    +            
    3611class Decode(Func):
    +3612    arg_types = {"this": True, "charset": True, "replace": False}
     
    @@ -35593,8 +36182,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3570class DiToDate(Func):
    -3571    pass
    +            
    3615class DiToDate(Func):
    +3616    pass
     
    @@ -35670,8 +36259,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3574class Encode(Func):
    -3575    arg_types = {"this": True, "charset": True}
    +            
    3619class Encode(Func):
    +3620    arg_types = {"this": True, "charset": True}
     
    @@ -35747,8 +36336,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3578class Exp(Func):
    -3579    pass
    +            
    3623class Exp(Func):
    +3624    pass
     
    @@ -35824,8 +36413,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3582class Explode(Func):
    -3583    pass
    +            
    3627class Explode(Func):
    +3628    pass
     
    @@ -35901,8 +36490,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3586class ExponentialTimeDecayedAvg(AggFunc):
    -3587    arg_types = {"this": True, "time": False, "decay": False}
    +            
    3631class ExponentialTimeDecayedAvg(AggFunc):
    +3632    arg_types = {"this": True, "time": False, "decay": False}
     
    @@ -35978,8 +36567,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3590class Floor(Func):
    -3591    arg_types = {"this": True, "decimals": False}
    +            
    3635class Floor(Func):
    +3636    arg_types = {"this": True, "decimals": False}
     
    @@ -36055,9 +36644,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3594class Greatest(Func):
    -3595    arg_types = {"this": True, "expressions": False}
    -3596    is_var_len_args = True
    +            
    3639class Greatest(Func):
    +3640    arg_types = {"this": True, "expressions": False}
    +3641    is_var_len_args = True
     
    @@ -36133,8 +36722,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3599class GroupConcat(Func):
    -3600    arg_types = {"this": True, "separator": False}
    +            
    3644class GroupConcat(Func):
    +3645    arg_types = {"this": True, "separator": False}
     
    @@ -36210,8 +36799,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3603class GroupUniqArray(AggFunc):
    -3604    arg_types = {"this": True, "size": False}
    +            
    3648class GroupUniqArray(AggFunc):
    +3649    arg_types = {"this": True, "size": False}
     
    @@ -36287,8 +36876,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3607class Hex(Func):
    -3608    pass
    +            
    3652class Hex(Func):
    +3653    pass
     
    @@ -36364,8 +36953,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3611class Histogram(AggFunc):
    -3612    arg_types = {"this": True, "bins": False}
    +            
    3656class Histogram(AggFunc):
    +3657    arg_types = {"this": True, "bins": False}
     
    @@ -36441,8 +37030,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3615class If(Func):
    -3616    arg_types = {"this": True, "true": True, "false": False}
    +            
    3660class If(Func):
    +3661    arg_types = {"this": True, "true": True, "false": False}
     
    @@ -36518,9 +37107,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3619class IfNull(Func):
    -3620    arg_types = {"this": True, "expression": False}
    -3621    _sql_names = ["IFNULL", "NVL"]
    +            
    3664class IfNull(Func):
    +3665    arg_types = {"this": True, "expression": False}
    +3666    _sql_names = ["IFNULL", "NVL"]
     
    @@ -36596,8 +37185,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3624class Initcap(Func):
    -3625    pass
    +            
    3669class Initcap(Func):
    +3670    pass
     
    @@ -36673,8 +37262,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3628class JSONKeyValue(Expression):
    -3629    arg_types = {"this": True, "expression": True}
    +            
    3673class JSONKeyValue(Expression):
    +3674    arg_types = {"this": True, "expression": True}
     
    @@ -36737,15 +37326,15 @@ name is set to the expression's class name transformed to snake case.
    -
    3632class JSONObject(Func):
    -3633    arg_types = {
    -3634        "expressions": False,
    -3635        "null_handling": False,
    -3636        "unique_keys": False,
    -3637        "return_type": False,
    -3638        "format_json": False,
    -3639        "encoding": False,
    -3640    }
    +            
    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    }
     
    @@ -36821,8 +37410,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3643class JSONBContains(Binary):
    -3644    _sql_names = ["JSONB_CONTAINS"]
    +            
    3688class JSONBContains(Binary):
    +3689    _sql_names = ["JSONB_CONTAINS"]
     
    @@ -36885,8 +37474,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3647class JSONExtract(Binary, Func):
    -3648    _sql_names = ["JSON_EXTRACT"]
    +            
    3692class JSONExtract(Binary, Func):
    +3693    _sql_names = ["JSON_EXTRACT"]
     
    @@ -36962,8 +37551,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3651class JSONExtractScalar(JSONExtract):
    -3652    _sql_names = ["JSON_EXTRACT_SCALAR"]
    +            
    3696class JSONExtractScalar(JSONExtract):
    +3697    _sql_names = ["JSON_EXTRACT_SCALAR"]
     
    @@ -37039,8 +37628,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3655class JSONBExtract(JSONExtract):
    -3656    _sql_names = ["JSONB_EXTRACT"]
    +            
    3700class JSONBExtract(JSONExtract):
    +3701    _sql_names = ["JSONB_EXTRACT"]
     
    @@ -37116,8 +37705,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3659class JSONBExtractScalar(JSONExtract):
    -3660    _sql_names = ["JSONB_EXTRACT_SCALAR"]
    +            
    3704class JSONBExtractScalar(JSONExtract):
    +3705    _sql_names = ["JSONB_EXTRACT_SCALAR"]
     
    @@ -37193,9 +37782,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3663class JSONFormat(Func):
    -3664    arg_types = {"this": False, "options": False}
    -3665    _sql_names = ["JSON_FORMAT"]
    +            
    3708class JSONFormat(Func):
    +3709    arg_types = {"this": False, "options": False}
    +3710    _sql_names = ["JSON_FORMAT"]
     
    @@ -37271,9 +37860,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3668class Least(Func):
    -3669    arg_types = {"expressions": False}
    -3670    is_var_len_args = True
    +            
    3713class Least(Func):
    +3714    arg_types = {"expressions": False}
    +3715    is_var_len_args = True
     
    @@ -37349,8 +37938,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3673class Length(Func):
    -3674    pass
    +            
    3718class Length(Func):
    +3719    pass
     
    @@ -37426,14 +38015,14 @@ name is set to the expression's class name transformed to snake case.
    -
    3677class Levenshtein(Func):
    -3678    arg_types = {
    -3679        "this": True,
    -3680        "expression": False,
    -3681        "ins_cost": False,
    -3682        "del_cost": False,
    -3683        "sub_cost": False,
    -3684    }
    +            
    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    }
     
    @@ -37509,8 +38098,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3687class Ln(Func):
    -3688    pass
    +            
    3732class Ln(Func):
    +3733    pass
     
    @@ -37586,8 +38175,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3691class Log(Func):
    -3692    arg_types = {"this": True, "expression": False}
    +            
    3736class Log(Func):
    +3737    arg_types = {"this": True, "expression": False}
     
    @@ -37663,8 +38252,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3695class Log2(Func):
    -3696    pass
    +            
    3740class Log2(Func):
    +3741    pass
     
    @@ -37740,8 +38329,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3699class Log10(Func):
    -3700    pass
    +            
    3744class Log10(Func):
    +3745    pass
     
    @@ -37817,8 +38406,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3703class LogicalOr(AggFunc):
    -3704    _sql_names = ["LOGICAL_OR", "BOOL_OR", "BOOLOR_AGG"]
    +            
    3748class LogicalOr(AggFunc):
    +3749    _sql_names = ["LOGICAL_OR", "BOOL_OR", "BOOLOR_AGG"]
     
    @@ -37894,8 +38483,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3707class LogicalAnd(AggFunc):
    -3708    _sql_names = ["LOGICAL_AND", "BOOL_AND", "BOOLAND_AGG"]
    +            
    3752class LogicalAnd(AggFunc):
    +3753    _sql_names = ["LOGICAL_AND", "BOOL_AND", "BOOLAND_AGG"]
     
    @@ -37971,8 +38560,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3711class Lower(Func):
    -3712    _sql_names = ["LOWER", "LCASE"]
    +            
    3756class Lower(Func):
    +3757    _sql_names = ["LOWER", "LCASE"]
     
    @@ -38048,8 +38637,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3715class Map(Func):
    -3716    arg_types = {"keys": False, "values": False}
    +            
    3760class Map(Func):
    +3761    arg_types = {"keys": False, "values": False}
     
    @@ -38110,6 +38699,83 @@ name is set to the expression's class name transformed to snake case.
    or_
    not_
    +
    + + +
    +
    + +
    + + class + StarMap(Func): + + + +
    + +
    3764class StarMap(Func):
    +3765    pass
    +
    + + + + + @@ -38125,9 +38791,9 @@ name is set to the expression's class name transformed to snake case. -
    3719class VarMap(Func):
    -3720    arg_types = {"keys": True, "values": True}
    -3721    is_var_len_args = True
    +            
    3768class VarMap(Func):
    +3769    arg_types = {"keys": True, "values": True}
    +3770    is_var_len_args = True
     
    @@ -38203,8 +38869,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3725class MatchAgainst(Func):
    -3726    arg_types = {"this": True, "expressions": True, "modifier": False}
    +            
    3774class MatchAgainst(Func):
    +3775    arg_types = {"this": True, "expressions": True, "modifier": False}
     
    @@ -38280,9 +38946,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3729class Max(AggFunc):
    -3730    arg_types = {"this": True, "expressions": False}
    -3731    is_var_len_args = True
    +            
    3778class Max(AggFunc):
    +3779    arg_types = {"this": True, "expressions": False}
    +3780    is_var_len_args = True
     
    @@ -38343,6 +39009,83 @@ name is set to the expression's class name transformed to snake case.
    or_
    not_
    +
    + + +
    +
    + +
    + + class + MD5(Func): + + + +
    + +
    3783class MD5(Func):
    +3784    _sql_names = ["MD5"]
    +
    + + + + + @@ -38358,9 +39101,9 @@ name is set to the expression's class name transformed to snake case. -
    3734class Min(AggFunc):
    -3735    arg_types = {"this": True, "expressions": False}
    -3736    is_var_len_args = True
    +            
    3787class Min(AggFunc):
    +3788    arg_types = {"this": True, "expressions": False}
    +3789    is_var_len_args = True
     
    @@ -38436,8 +39179,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3739class Month(Func):
    -3740    pass
    +            
    3792class Month(Func):
    +3793    pass
     
    @@ -38513,8 +39256,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3743class Nvl2(Func):
    -3744    arg_types = {"this": True, "true": True, "false": False}
    +            
    3796class Nvl2(Func):
    +3797    arg_types = {"this": True, "true": True, "false": False}
     
    @@ -38590,8 +39333,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3747class Posexplode(Func):
    -3748    pass
    +            
    3800class Posexplode(Func):
    +3801    pass
     
    @@ -38667,8 +39410,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3751class Pow(Binary, Func):
    -3752    _sql_names = ["POWER", "POW"]
    +            
    3804class Pow(Binary, Func):
    +3805    _sql_names = ["POWER", "POW"]
     
    @@ -38744,8 +39487,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3755class PercentileCont(AggFunc):
    -3756    pass
    +            
    3808class PercentileCont(AggFunc):
    +3809    pass
     
    @@ -38821,8 +39564,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3759class PercentileDisc(AggFunc):
    -3760    pass
    +            
    3812class PercentileDisc(AggFunc):
    +3813    pass
     
    @@ -38898,8 +39641,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3763class Quantile(AggFunc):
    -3764    arg_types = {"this": True, "quantile": True}
    +            
    3816class Quantile(AggFunc):
    +3817    arg_types = {"this": True, "quantile": True}
     
    @@ -38975,9 +39718,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3769class Quantiles(AggFunc):
    -3770    arg_types = {"parameters": True, "expressions": True}
    -3771    is_var_len_args = True
    +            
    3822class Quantiles(AggFunc):
    +3823    arg_types = {"parameters": True, "expressions": True}
    +3824    is_var_len_args = True
     
    @@ -39053,8 +39796,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3774class QuantileIf(AggFunc):
    -3775    arg_types = {"parameters": True, "expressions": True}
    +            
    3827class QuantileIf(AggFunc):
    +3828    arg_types = {"parameters": True, "expressions": True}
     
    @@ -39130,8 +39873,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3778class ApproxQuantile(Quantile):
    -3779    arg_types = {"this": True, "quantile": True, "accuracy": False, "weight": False}
    +            
    3831class ApproxQuantile(Quantile):
    +3832    arg_types = {"this": True, "quantile": True, "accuracy": False, "weight": False}
     
    @@ -39207,8 +39950,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3782class RangeN(Func):
    -3783    arg_types = {"this": True, "expressions": True, "each": False}
    +            
    3835class RangeN(Func):
    +3836    arg_types = {"this": True, "expressions": True, "each": False}
     
    @@ -39284,10 +40027,10 @@ name is set to the expression's class name transformed to snake case.
    -
    3786class ReadCSV(Func):
    -3787    _sql_names = ["READ_CSV"]
    -3788    is_var_len_args = True
    -3789    arg_types = {"this": True, "expressions": False}
    +            
    3839class ReadCSV(Func):
    +3840    _sql_names = ["READ_CSV"]
    +3841    is_var_len_args = True
    +3842    arg_types = {"this": True, "expressions": False}
     
    @@ -39363,8 +40106,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3792class Reduce(Func):
    -3793    arg_types = {"this": True, "initial": True, "merge": True, "finish": False}
    +            
    3845class Reduce(Func):
    +3846    arg_types = {"this": True, "initial": True, "merge": True, "finish": False}
     
    @@ -39440,14 +40183,14 @@ name is set to the expression's class name transformed to snake case.
    -
    3796class RegexpExtract(Func):
    -3797    arg_types = {
    -3798        "this": True,
    -3799        "expression": True,
    -3800        "position": False,
    -3801        "occurrence": False,
    -3802        "group": False,
    -3803    }
    +            
    3849class RegexpExtract(Func):
    +3850    arg_types = {
    +3851        "this": True,
    +3852        "expression": True,
    +3853        "position": False,
    +3854        "occurrence": False,
    +3855        "group": False,
    +3856    }
     
    @@ -39523,8 +40266,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3806class RegexpLike(Func):
    -3807    arg_types = {"this": True, "expression": True, "flag": False}
    +            
    3859class RegexpLike(Func):
    +3860    arg_types = {"this": True, "expression": True, "flag": False}
     
    @@ -39600,8 +40343,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3810class RegexpILike(Func):
    -3811    arg_types = {"this": True, "expression": True, "flag": False}
    +            
    3863class RegexpILike(Func):
    +3864    arg_types = {"this": True, "expression": True, "flag": False}
     
    @@ -39677,8 +40420,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3816class RegexpSplit(Func):
    -3817    arg_types = {"this": True, "expression": True, "limit": False}
    +            
    3869class RegexpSplit(Func):
    +3870    arg_types = {"this": True, "expression": True, "limit": False}
     
    @@ -39754,8 +40497,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3820class Repeat(Func):
    -3821    arg_types = {"this": True, "times": True}
    +            
    3873class Repeat(Func):
    +3874    arg_types = {"this": True, "times": True}
     
    @@ -39831,8 +40574,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3824class Round(Func):
    -3825    arg_types = {"this": True, "decimals": False}
    +            
    3877class Round(Func):
    +3878    arg_types = {"this": True, "decimals": False}
     
    @@ -39908,8 +40651,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3828class RowNumber(Func):
    -3829    arg_types: t.Dict[str, t.Any] = {}
    +            
    3881class RowNumber(Func):
    +3882    arg_types: t.Dict[str, t.Any] = {}
     
    @@ -39985,8 +40728,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3832class SafeDivide(Func):
    -3833    arg_types = {"this": True, "expression": True}
    +            
    3885class SafeDivide(Func):
    +3886    arg_types = {"this": True, "expression": True}
     
    @@ -40062,8 +40805,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3836class SetAgg(AggFunc):
    -3837    pass
    +            
    3889class SetAgg(AggFunc):
    +3890    pass
     
    @@ -40124,6 +40867,161 @@ name is set to the expression's class name transformed to snake case.
    or_
    not_
    +
    + + +
    +
    + +
    + + class + SHA(Func): + + + +
    + +
    3893class SHA(Func):
    +3894    _sql_names = ["SHA", "SHA1"]
    +
    + + + + + +
    +
    + +
    + + class + SHA2(Func): + + + +
    + +
    3897class SHA2(Func):
    +3898    _sql_names = ["SHA2"]
    +3899    arg_types = {"this": True, "length": False}
    +
    + + + + + @@ -40139,8 +41037,8 @@ name is set to the expression's class name transformed to snake case. -
    3840class SortArray(Func):
    -3841    arg_types = {"this": True, "asc": False}
    +            
    3902class SortArray(Func):
    +3903    arg_types = {"this": True, "asc": False}
     
    @@ -40216,8 +41114,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3844class Split(Func):
    -3845    arg_types = {"this": True, "expression": True, "limit": False}
    +            
    3906class Split(Func):
    +3907    arg_types = {"this": True, "expression": True, "limit": False}
     
    @@ -40293,8 +41191,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3850class Substring(Func):
    -3851    arg_types = {"this": True, "start": False, "length": False}
    +            
    3912class Substring(Func):
    +3913    arg_types = {"this": True, "start": False, "length": False}
     
    @@ -40370,13 +41268,13 @@ name is set to the expression's class name transformed to snake case.
    -
    3854class StrPosition(Func):
    -3855    arg_types = {
    -3856        "this": True,
    -3857        "substr": True,
    -3858        "position": False,
    -3859        "instance": False,
    -3860    }
    +            
    3916class StrPosition(Func):
    +3917    arg_types = {
    +3918        "this": True,
    +3919        "substr": True,
    +3920        "position": False,
    +3921        "instance": False,
    +3922    }
     
    @@ -40452,8 +41350,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3863class StrToDate(Func):
    -3864    arg_types = {"this": True, "format": True}
    +            
    3925class StrToDate(Func):
    +3926    arg_types = {"this": True, "format": True}
     
    @@ -40529,8 +41427,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3867class StrToTime(Func):
    -3868    arg_types = {"this": True, "format": True}
    +            
    3929class StrToTime(Func):
    +3930    arg_types = {"this": True, "format": True}
     
    @@ -40606,8 +41504,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3873class StrToUnix(Func):
    -3874    arg_types = {"this": False, "format": False}
    +            
    3935class StrToUnix(Func):
    +3936    arg_types = {"this": False, "format": False}
     
    @@ -40683,8 +41581,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3877class NumberToStr(Func):
    -3878    arg_types = {"this": True, "format": True}
    +            
    3939class NumberToStr(Func):
    +3940    arg_types = {"this": True, "format": True}
     
    @@ -40760,9 +41658,9 @@ name is set to the expression's class name transformed to snake case.
    -
    3881class Struct(Func):
    -3882    arg_types = {"expressions": True}
    -3883    is_var_len_args = True
    +            
    3943class Struct(Func):
    +3944    arg_types = {"expressions": True}
    +3945    is_var_len_args = True
     
    @@ -40838,8 +41736,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3886class StructExtract(Func):
    -3887    arg_types = {"this": True, "expression": True}
    +            
    3948class StructExtract(Func):
    +3949    arg_types = {"this": True, "expression": True}
     
    @@ -40915,8 +41813,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3890class Sum(AggFunc):
    -3891    pass
    +            
    3952class Sum(AggFunc):
    +3953    pass
     
    @@ -40992,8 +41890,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3894class Sqrt(Func):
    -3895    pass
    +            
    3956class Sqrt(Func):
    +3957    pass
     
    @@ -41069,8 +41967,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3898class Stddev(AggFunc):
    -3899    pass
    +            
    3960class Stddev(AggFunc):
    +3961    pass
     
    @@ -41146,8 +42044,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3902class StddevPop(AggFunc):
    -3903    pass
    +            
    3964class StddevPop(AggFunc):
    +3965    pass
     
    @@ -41223,8 +42121,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3906class StddevSamp(AggFunc):
    -3907    pass
    +            
    3968class StddevSamp(AggFunc):
    +3969    pass
     
    @@ -41300,8 +42198,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3910class TimeToStr(Func):
    -3911    arg_types = {"this": True, "format": True}
    +            
    3972class TimeToStr(Func):
    +3973    arg_types = {"this": True, "format": True}
     
    @@ -41377,8 +42275,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3914class TimeToTimeStr(Func):
    -3915    pass
    +            
    3976class TimeToTimeStr(Func):
    +3977    pass
     
    @@ -41454,8 +42352,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3918class TimeToUnix(Func):
    -3919    pass
    +            
    3980class TimeToUnix(Func):
    +3981    pass
     
    @@ -41531,8 +42429,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3922class TimeStrToDate(Func):
    -3923    pass
    +            
    3984class TimeStrToDate(Func):
    +3985    pass
     
    @@ -41608,8 +42506,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3926class TimeStrToTime(Func):
    -3927    pass
    +            
    3988class TimeStrToTime(Func):
    +3989    pass
     
    @@ -41685,8 +42583,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3930class TimeStrToUnix(Func):
    -3931    pass
    +            
    3992class TimeStrToUnix(Func):
    +3993    pass
     
    @@ -41762,13 +42660,13 @@ name is set to the expression's class name transformed to snake case.
    -
    3934class Trim(Func):
    -3935    arg_types = {
    -3936        "this": True,
    -3937        "expression": False,
    -3938        "position": False,
    -3939        "collation": False,
    -3940    }
    +            
    3996class Trim(Func):
    +3997    arg_types = {
    +3998        "this": True,
    +3999        "expression": False,
    +4000        "position": False,
    +4001        "collation": False,
    +4002    }
     
    @@ -41844,8 +42742,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3943class TsOrDsAdd(Func, TimeUnit):
    -3944    arg_types = {"this": True, "expression": True, "unit": False}
    +            
    4005class TsOrDsAdd(Func, TimeUnit):
    +4006    arg_types = {"this": True, "expression": True, "unit": False}
     
    @@ -41924,8 +42822,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3947class TsOrDsToDateStr(Func):
    -3948    pass
    +            
    4009class TsOrDsToDateStr(Func):
    +4010    pass
     
    @@ -42001,8 +42899,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3951class TsOrDsToDate(Func):
    -3952    arg_types = {"this": True, "format": False}
    +            
    4013class TsOrDsToDate(Func):
    +4014    arg_types = {"this": True, "format": False}
     
    @@ -42078,8 +42976,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3955class TsOrDiToDi(Func):
    -3956    pass
    +            
    4017class TsOrDiToDi(Func):
    +4018    pass
     
    @@ -42155,8 +43053,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3959class Unhex(Func):
    -3960    pass
    +            
    4021class Unhex(Func):
    +4022    pass
     
    @@ -42232,8 +43130,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3963class UnixToStr(Func):
    -3964    arg_types = {"this": True, "format": False}
    +            
    4025class UnixToStr(Func):
    +4026    arg_types = {"this": True, "format": False}
     
    @@ -42309,12 +43207,12 @@ name is set to the expression's class name transformed to snake case.
    -
    3969class UnixToTime(Func):
    -3970    arg_types = {"this": True, "scale": False, "zone": False, "hours": False, "minutes": False}
    -3971
    -3972    SECONDS = Literal.string("seconds")
    -3973    MILLIS = Literal.string("millis")
    -3974    MICROS = Literal.string("micros")
    +            
    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")
     
    @@ -42390,8 +43288,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3977class UnixToTimeStr(Func):
    -3978    pass
    +            
    4039class UnixToTimeStr(Func):
    +4040    pass
     
    @@ -42467,8 +43365,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3981class Upper(Func):
    -3982    _sql_names = ["UPPER", "UCASE"]
    +            
    4043class Upper(Func):
    +4044    _sql_names = ["UPPER", "UCASE"]
     
    @@ -42544,8 +43442,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3985class Variance(AggFunc):
    -3986    _sql_names = ["VARIANCE", "VARIANCE_SAMP", "VAR_SAMP"]
    +            
    4047class Variance(AggFunc):
    +4048    _sql_names = ["VARIANCE", "VARIANCE_SAMP", "VAR_SAMP"]
     
    @@ -42621,8 +43519,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3989class VariancePop(AggFunc):
    -3990    _sql_names = ["VARIANCE_POP", "VAR_POP"]
    +            
    4051class VariancePop(AggFunc):
    +4052    _sql_names = ["VARIANCE_POP", "VAR_POP"]
     
    @@ -42698,8 +43596,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3993class Week(Func):
    -3994    arg_types = {"this": True, "mode": False}
    +            
    4055class Week(Func):
    +4056    arg_types = {"this": True, "mode": False}
     
    @@ -42775,8 +43673,8 @@ name is set to the expression's class name transformed to snake case.
    -
    3997class XMLTable(Func):
    -3998    arg_types = {"this": True, "passing": False, "columns": False, "by_ref": False}
    +            
    4059class XMLTable(Func):
    +4060    arg_types = {"this": True, "passing": False, "columns": False, "by_ref": False}
     
    @@ -42852,8 +43750,8 @@ name is set to the expression's class name transformed to snake case.
    -
    4001class Year(Func):
    -4002    pass
    +            
    4063class Year(Func):
    +4064    pass
     
    @@ -42929,8 +43827,8 @@ name is set to the expression's class name transformed to snake case.
    -
    4005class Use(Expression):
    -4006    arg_types = {"this": True, "kind": False}
    +            
    4067class Use(Expression):
    +4068    arg_types = {"this": True, "kind": False}
     
    @@ -42993,8 +43891,8 @@ name is set to the expression's class name transformed to snake case.
    -
    4009class Merge(Expression):
    -4010    arg_types = {"this": True, "using": True, "on": True, "expressions": True}
    +            
    4071class Merge(Expression):
    +4072    arg_types = {"this": True, "using": True, "on": True, "expressions": True}
     
    @@ -43057,8 +43955,8 @@ name is set to the expression's class name transformed to snake case.
    -
    4013class When(Func):
    -4014    arg_types = {"matched": True, "source": False, "condition": False, "then": True}
    +            
    4075class When(Func):
    +4076    arg_types = {"matched": True, "source": False, "condition": False, "then": True}
     
    @@ -43134,48 +44032,48 @@ name is set to the expression's class name transformed to snake case.
    -
    4025def maybe_parse(
    -4026    sql_or_expression: ExpOrStr,
    -4027    *,
    -4028    into: t.Optional[IntoType] = None,
    -4029    dialect: DialectType = None,
    -4030    prefix: t.Optional[str] = None,
    -4031    copy: bool = False,
    -4032    **opts,
    -4033) -> Expression:
    -4034    """Gracefully handle a possible string or expression.
    -4035
    -4036    Example:
    -4037        >>> maybe_parse("1")
    -4038        (LITERAL this: 1, is_string: False)
    -4039        >>> maybe_parse(to_identifier("x"))
    -4040        (IDENTIFIER this: x, quoted: False)
    -4041
    -4042    Args:
    -4043        sql_or_expression: the SQL code string or an expression
    -4044        into: the SQLGlot Expression to parse into
    -4045        dialect: the dialect used to parse the input expressions (in the case that an
    -4046            input expression is a SQL string).
    -4047        prefix: a string to prefix the sql with before it gets parsed
    -4048            (automatically includes a space)
    -4049        copy: whether or not to copy the expression.
    -4050        **opts: other options to use to parse the input expressions (again, in the case
    -4051            that an input expression is a SQL string).
    -4052
    -4053    Returns:
    -4054        Expression: the parsed or given expression.
    -4055    """
    -4056    if isinstance(sql_or_expression, Expression):
    -4057        if copy:
    -4058            return sql_or_expression.copy()
    -4059        return sql_or_expression
    -4060
    -4061    import sqlglot
    -4062
    -4063    sql = str(sql_or_expression)
    -4064    if prefix:
    -4065        sql = f"{prefix} {sql}"
    -4066    return sqlglot.parse_one(sql, read=dialect, into=into, **opts)
    +            
    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)
     
    @@ -43227,29 +44125,29 @@ that an input expression is a SQL string).
    -
    4212def union(left, right, distinct=True, dialect=None, **opts):
    -4213    """
    -4214    Initializes a syntax tree from one UNION expression.
    -4215
    -4216    Example:
    -4217        >>> union("SELECT * FROM foo", "SELECT * FROM bla").sql()
    -4218        'SELECT * FROM foo UNION SELECT * FROM bla'
    -4219
    -4220    Args:
    -4221        left (str | Expression): the SQL code string corresponding to the left-hand side.
    -4222            If an `Expression` instance is passed, it will be used as-is.
    -4223        right (str | Expression): the SQL code string corresponding to the right-hand side.
    -4224            If an `Expression` instance is passed, it will be used as-is.
    -4225        distinct (bool): set the DISTINCT flag if and only if this is true.
    -4226        dialect (str): the dialect used to parse the input expression.
    -4227        opts (kwargs): other options to use to parse the input expressions.
    -4228    Returns:
    -4229        Union: the syntax tree for the UNION expression.
    -4230    """
    -4231    left = maybe_parse(sql_or_expression=left, dialect=dialect, **opts)
    -4232    right = maybe_parse(sql_or_expression=right, dialect=dialect, **opts)
    -4233
    -4234    return Union(this=left, expression=right, distinct=distinct)
    +            
    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)
     
    @@ -43297,29 +44195,29 @@ If an Expression instance is passed, it w
    -
    4237def intersect(left, right, distinct=True, dialect=None, **opts):
    -4238    """
    -4239    Initializes a syntax tree from one INTERSECT expression.
    -4240
    -4241    Example:
    -4242        >>> intersect("SELECT * FROM foo", "SELECT * FROM bla").sql()
    -4243        'SELECT * FROM foo INTERSECT SELECT * FROM bla'
    -4244
    -4245    Args:
    -4246        left (str | Expression): the SQL code string corresponding to the left-hand side.
    -4247            If an `Expression` instance is passed, it will be used as-is.
    -4248        right (str | Expression): the SQL code string corresponding to the right-hand side.
    -4249            If an `Expression` instance is passed, it will be used as-is.
    -4250        distinct (bool): set the DISTINCT flag if and only if this is true.
    -4251        dialect (str): the dialect used to parse the input expression.
    -4252        opts (kwargs): other options to use to parse the input expressions.
    -4253    Returns:
    -4254        Intersect: the syntax tree for the INTERSECT expression.
    -4255    """
    -4256    left = maybe_parse(sql_or_expression=left, dialect=dialect, **opts)
    -4257    right = maybe_parse(sql_or_expression=right, dialect=dialect, **opts)
    -4258
    -4259    return Intersect(this=left, expression=right, distinct=distinct)
    +            
    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)
     
    @@ -43367,29 +44265,29 @@ If an Expression instance is passed, it w
    -
    4262def except_(left, right, distinct=True, dialect=None, **opts):
    -4263    """
    -4264    Initializes a syntax tree from one EXCEPT expression.
    -4265
    -4266    Example:
    -4267        >>> except_("SELECT * FROM foo", "SELECT * FROM bla").sql()
    -4268        'SELECT * FROM foo EXCEPT SELECT * FROM bla'
    -4269
    -4270    Args:
    -4271        left (str | Expression): the SQL code string corresponding to the left-hand side.
    -4272            If an `Expression` instance is passed, it will be used as-is.
    -4273        right (str | Expression): the SQL code string corresponding to the right-hand side.
    -4274            If an `Expression` instance is passed, it will be used as-is.
    -4275        distinct (bool): set the DISTINCT flag if and only if this is true.
    -4276        dialect (str): the dialect used to parse the input expression.
    -4277        opts (kwargs): other options to use to parse the input expressions.
    -4278    Returns:
    -4279        Except: the syntax tree for the EXCEPT statement.
    -4280    """
    -4281    left = maybe_parse(sql_or_expression=left, dialect=dialect, **opts)
    -4282    right = maybe_parse(sql_or_expression=right, dialect=dialect, **opts)
    -4283
    -4284    return Except(this=left, expression=right, distinct=distinct)
    +            
    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)
     
    @@ -43437,26 +44335,26 @@ If an Expression instance is passed, it w
    -
    4287def select(*expressions: ExpOrStr, dialect: DialectType = None, **opts) -> Select:
    -4288    """
    -4289    Initializes a syntax tree from one or multiple SELECT expressions.
    -4290
    -4291    Example:
    -4292        >>> select("col1", "col2").from_("tbl").sql()
    -4293        'SELECT col1, col2 FROM tbl'
    -4294
    -4295    Args:
    -4296        *expressions: the SQL code string to parse as the expressions of a
    -4297            SELECT statement. If an Expression instance is passed, this is used as-is.
    -4298        dialect: the dialect used to parse the input expressions (in the case that an
    -4299            input expression is a SQL string).
    -4300        **opts: other options to use to parse the input expressions (again, in the case
    -4301            that an input expression is a SQL string).
    -4302
    -4303    Returns:
    -4304        Select: the syntax tree for the SELECT statement.
    -4305    """
    -4306    return Select().select(*expressions, dialect=dialect, **opts)
    +            
    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)
     
    @@ -43503,26 +44401,26 @@ that an input expression is a SQL string).
    -
    4309def from_(*expressions, dialect=None, **opts) -> Select:
    -4310    """
    -4311    Initializes a syntax tree from a FROM expression.
    -4312
    -4313    Example:
    -4314        >>> from_("tbl").select("col1", "col2").sql()
    -4315        'SELECT col1, col2 FROM tbl'
    -4316
    -4317    Args:
    -4318        *expressions (str | Expression): the SQL code string to parse as the FROM expressions of a
    -4319            SELECT statement. If an Expression instance is passed, this is used as-is.
    -4320        dialect (str): the dialect used to parse the input expression (in the case that the
    -4321            input expression is a SQL string).
    -4322        **opts: other options to use to parse the input expressions (again, in the case
    -4323            that the input expression is a SQL string).
    -4324
    -4325    Returns:
    -4326        Select: the syntax tree for the SELECT statement.
    -4327    """
    -4328    return Select().from_(*expressions, dialect=dialect, **opts)
    +            
    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)
     
    @@ -43569,53 +44467,53 @@ that the input expression is a SQL string).
    -
    4331def update(
    -4332    table: str | Table,
    -4333    properties: dict,
    -4334    where: t.Optional[ExpOrStr] = None,
    -4335    from_: t.Optional[ExpOrStr] = None,
    -4336    dialect: DialectType = None,
    -4337    **opts,
    -4338) -> Update:
    -4339    """
    -4340    Creates an update statement.
    -4341
    -4342    Example:
    -4343        >>> update("my_table", {"x": 1, "y": "2", "z": None}, from_="baz", where="id > 1").sql()
    -4344        "UPDATE my_table SET x = 1, y = '2', z = NULL FROM baz WHERE id > 1"
    -4345
    -4346    Args:
    -4347        *properties: dictionary of properties to set which are
    -4348            auto converted to sql objects eg None -> NULL
    -4349        where: sql conditional parsed into a WHERE statement
    -4350        from_: sql statement parsed into a FROM statement
    -4351        dialect: the dialect used to parse the input expressions.
    -4352        **opts: other options to use to parse the input expressions.
    -4353
    -4354    Returns:
    -4355        Update: the syntax tree for the UPDATE statement.
    -4356    """
    -4357    update_expr = Update(this=maybe_parse(table, into=Table, dialect=dialect))
    -4358    update_expr.set(
    -4359        "expressions",
    -4360        [
    -4361            EQ(this=maybe_parse(k, dialect=dialect, **opts), expression=convert(v))
    -4362            for k, v in properties.items()
    -4363        ],
    -4364    )
    -4365    if from_:
    -4366        update_expr.set(
    -4367            "from",
    -4368            maybe_parse(from_, into=From, dialect=dialect, prefix="FROM", **opts),
    -4369        )
    -4370    if isinstance(where, Condition):
    -4371        where = Where(this=where)
    -4372    if where:
    -4373        update_expr.set(
    -4374            "where",
    -4375            maybe_parse(where, into=Where, dialect=dialect, prefix="WHERE", **opts),
    -4376        )
    -4377    return update_expr
    +            
    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
     
    @@ -43662,35 +44560,35 @@ auto converted to sql objects eg None -> NULL
    -
    4380def delete(
    -4381    table: ExpOrStr,
    -4382    where: t.Optional[ExpOrStr] = None,
    -4383    returning: t.Optional[ExpOrStr] = None,
    -4384    dialect: DialectType = None,
    -4385    **opts,
    -4386) -> Delete:
    -4387    """
    -4388    Builds a delete statement.
    -4389
    -4390    Example:
    -4391        >>> delete("my_table", where="id > 1").sql()
    -4392        'DELETE FROM my_table WHERE id > 1'
    -4393
    -4394    Args:
    -4395        where: sql conditional parsed into a WHERE statement
    -4396        returning: sql conditional parsed into a RETURNING statement
    -4397        dialect: the dialect used to parse the input expressions.
    -4398        **opts: other options to use to parse the input expressions.
    -4399
    -4400    Returns:
    -4401        Delete: the syntax tree for the DELETE statement.
    -4402    """
    -4403    delete_expr = Delete().delete(table, dialect=dialect, copy=False, **opts)
    -4404    if where:
    -4405        delete_expr = delete_expr.where(where, dialect=dialect, copy=False, **opts)
    -4406    if returning:
    -4407        delete_expr = delete_expr.returning(returning, dialect=dialect, copy=False, **opts)
    -4408    return delete_expr
    +            
    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
     
    @@ -43735,37 +44633,37 @@ auto converted to sql objects eg None -> NULL
    -
    4411def condition(expression, dialect=None, **opts) -> Condition:
    -4412    """
    -4413    Initialize a logical condition expression.
    -4414
    -4415    Example:
    -4416        >>> condition("x=1").sql()
    -4417        'x = 1'
    -4418
    -4419        This is helpful for composing larger logical syntax trees:
    -4420        >>> where = condition("x=1")
    -4421        >>> where = where.and_("y=1")
    -4422        >>> Select().from_("tbl").select("*").where(where).sql()
    -4423        'SELECT * FROM tbl WHERE x = 1 AND y = 1'
    -4424
    -4425    Args:
    -4426        *expression (str | Expression): the SQL code string to parse.
    -4427            If an Expression instance is passed, this is used as-is.
    -4428        dialect (str): the dialect used to parse the input expression (in the case that the
    -4429            input expression is a SQL string).
    -4430        **opts: other options to use to parse the input expressions (again, in the case
    -4431            that the input expression is a SQL string).
    -4432
    -4433    Returns:
    -4434        Condition: the expression
    -4435    """
    -4436    return maybe_parse(  # type: ignore
    -4437        expression,
    -4438        into=Condition,
    -4439        dialect=dialect,
    -4440        **opts,
    -4441    )
    +            
    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    )
     
    @@ -43822,24 +44720,24 @@ that the input expression is a SQL string).
    -
    4444def and_(*expressions, dialect=None, **opts) -> And:
    -4445    """
    -4446    Combine multiple conditions with an AND logical operator.
    -4447
    -4448    Example:
    -4449        >>> and_("x=1", and_("y=1", "z=1")).sql()
    -4450        'x = 1 AND (y = 1 AND z = 1)'
    -4451
    -4452    Args:
    -4453        *expressions (str | Expression): the SQL code strings to parse.
    -4454            If an Expression instance is passed, this is used as-is.
    -4455        dialect (str): the dialect used to parse the input expression.
    -4456        **opts: other options to use to parse the input expressions.
    -4457
    -4458    Returns:
    -4459        And: the new condition
    -4460    """
    -4461    return _combine(expressions, And, dialect, **opts)
    +            
    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)
     
    @@ -43884,24 +44782,24 @@ If an Expression instance is passed, this is used as-is.
    -
    4464def or_(*expressions, dialect=None, **opts) -> Or:
    -4465    """
    -4466    Combine multiple conditions with an OR logical operator.
    -4467
    -4468    Example:
    -4469        >>> or_("x=1", or_("y=1", "z=1")).sql()
    -4470        'x = 1 OR (y = 1 OR z = 1)'
    -4471
    -4472    Args:
    -4473        *expressions (str | Expression): the SQL code strings to parse.
    -4474            If an Expression instance is passed, this is used as-is.
    -4475        dialect (str): the dialect used to parse the input expression.
    -4476        **opts: other options to use to parse the input expressions.
    -4477
    -4478    Returns:
    -4479        Or: the new condition
    -4480    """
    -4481    return _combine(expressions, Or, dialect, **opts)
    +            
    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)
     
    @@ -43946,29 +44844,29 @@ If an Expression instance is passed, this is used as-is.
    -
    4484def not_(expression, dialect=None, **opts) -> Not:
    -4485    """
    -4486    Wrap a condition with a NOT operator.
    -4487
    -4488    Example:
    -4489        >>> not_("this_suit='black'").sql()
    -4490        "NOT this_suit = 'black'"
    -4491
    -4492    Args:
    -4493        expression (str | Expression): the SQL code strings to parse.
    -4494            If an Expression instance is passed, this is used as-is.
    -4495        dialect (str): the dialect used to parse the input expression.
    -4496        **opts: other options to use to parse the input expressions.
    -4497
    -4498    Returns:
    -4499        Not: the new condition
    -4500    """
    -4501    this = condition(
    -4502        expression,
    -4503        dialect=dialect,
    -4504        **opts,
    -4505    )
    -4506    return Not(this=_wrap_operator(this))
    +            
    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))
     
    @@ -44013,8 +44911,8 @@ If an Expression instance is passed, this is used as-is.
    -
    4509def paren(expression) -> Paren:
    -4510    return Paren(this=expression)
    +            
    4597def paren(expression) -> Paren:
    +4598    return Paren(this=expression)
     
    @@ -44032,30 +44930,30 @@ If an Expression instance is passed, this is used as-is.
    -
    4526def to_identifier(name, quoted=None):
    -4527    """Builds an identifier.
    -4528
    -4529    Args:
    -4530        name: The name to turn into an identifier.
    -4531        quoted: Whether or not force quote the identifier.
    -4532
    -4533    Returns:
    -4534        The identifier ast node.
    -4535    """
    -4536
    -4537    if name is None:
    -4538        return None
    -4539
    -4540    if isinstance(name, Identifier):
    -4541        identifier = name
    -4542    elif isinstance(name, str):
    -4543        identifier = Identifier(
    -4544            this=name,
    -4545            quoted=not SAFE_IDENTIFIER_RE.match(name) if quoted is None else quoted,
    -4546        )
    -4547    else:
    -4548        raise ValueError(f"Name needs to be a string or an Identifier, got: {name.__class__}")
    -4549    return identifier
    +            
    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
     
    @@ -44088,23 +44986,23 @@ If an Expression instance is passed, this is used as-is.
    -
    4555def to_interval(interval: str | Literal) -> Interval:
    -4556    """Builds an interval expression from a string like '1 day' or '5 months'."""
    -4557    if isinstance(interval, Literal):
    -4558        if not interval.is_string:
    -4559            raise ValueError("Invalid interval string.")
    -4560
    -4561        interval = interval.this
    -4562
    -4563    interval_parts = INTERVAL_STRING_RE.match(interval)  # type: ignore
    -4564
    -4565    if not interval_parts:
    -4566        raise ValueError("Invalid interval string.")
    -4567
    -4568    return Interval(
    -4569        this=Literal.string(interval_parts.group(1)),
    -4570        unit=Var(this=interval_parts.group(2)),
    -4571    )
    +            
    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    )
     
    @@ -44124,24 +45022,24 @@ If an Expression instance is passed, this is used as-is.
    -
    4584def to_table(sql_path: t.Optional[str | Table], **kwargs) -> t.Optional[Table]:
    -4585    """
    -4586    Create a table expression from a `[catalog].[schema].[table]` sql path. Catalog and schema are optional.
    -4587    If a table is passed in then that table is returned.
    -4588
    -4589    Args:
    -4590        sql_path: a `[catalog].[schema].[table]` string.
    -4591
    -4592    Returns:
    -4593        A table expression.
    -4594    """
    -4595    if sql_path is None or isinstance(sql_path, Table):
    -4596        return sql_path
    -4597    if not isinstance(sql_path, str):
    -4598        raise ValueError(f"Invalid type provided for a table: {type(sql_path)}")
    -4599
    -4600    catalog, db, table_name = (to_identifier(x) for x in split_num_words(sql_path, ".", 3))
    -4601    return Table(this=table_name, db=db, catalog=catalog, **kwargs)
    +            
    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)
     
    @@ -44174,22 +45072,22 @@ If a table is passed in then that table is returned.

    -
    4604def to_column(sql_path: str | Column, **kwargs) -> Column:
    -4605    """
    -4606    Create a column from a `[table].[column]` sql path. Schema is optional.
    -4607
    -4608    If a column is passed in then that column is returned.
    -4609
    -4610    Args:
    -4611        sql_path: `[table].[column]` string
    -4612    Returns:
    -4613        Table: A column expression
    -4614    """
    -4615    if sql_path is None or isinstance(sql_path, Column):
    -4616        return sql_path
    -4617    if not isinstance(sql_path, str):
    -4618        raise ValueError(f"Invalid type provided for column: {type(sql_path)}")
    -4619    return column(*reversed(sql_path.split(".")), **kwargs)  # type: ignore
    +            
    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
     
    @@ -44223,60 +45121,62 @@ If a table is passed in then that table is returned.

    -
    4622def alias_(
    -4623    expression: ExpOrStr,
    -4624    alias: str | Identifier,
    -4625    table: bool | t.Sequence[str | Identifier] = False,
    -4626    quoted: t.Optional[bool] = None,
    -4627    dialect: DialectType = None,
    -4628    **opts,
    -4629):
    -4630    """Create an Alias expression.
    -4631
    -4632    Example:
    -4633        >>> alias_('foo', 'bar').sql()
    -4634        'foo AS bar'
    -4635
    -4636        >>> alias_('(select 1, 2)', 'bar', table=['a', 'b']).sql()
    -4637        '(SELECT 1, 2) AS bar(a, b)'
    -4638
    -4639    Args:
    -4640        expression: the SQL code strings to parse.
    -4641            If an Expression instance is passed, this is used as-is.
    -4642        alias: the alias name to use. If the name has
    -4643            special characters it is quoted.
    -4644        table: Whether or not to create a table alias, can also be a list of columns.
    -4645        quoted: whether or not to quote the alias
    -4646        dialect: the dialect used to parse the input expression.
    -4647        **opts: other options to use to parse the input expressions.
    -4648
    -4649    Returns:
    -4650        Alias: the aliased expression
    -4651    """
    -4652    exp = maybe_parse(expression, dialect=dialect, **opts)
    -4653    alias = to_identifier(alias, quoted=quoted)
    -4654
    -4655    if table:
    -4656        table_alias = TableAlias(this=alias)
    -4657        exp.set("alias", table_alias)
    -4658
    -4659        if not isinstance(table, bool):
    -4660            for column in table:
    -4661                table_alias.append("columns", to_identifier(column, quoted=quoted))
    -4662
    -4663        return exp
    -4664
    -4665    # We don't set the "alias" arg for Window expressions, because that would add an IDENTIFIER node in
    -4666    # the AST, representing a "named_window" [1] construct (eg. bigquery). What we want is an ALIAS node
    -4667    # for the complete Window expression.
    -4668    #
    -4669    # [1]: https://cloud.google.com/bigquery/docs/reference/standard-sql/window-function-calls
    -4670
    -4671    if "alias" in exp.arg_types and not isinstance(exp, Window):
    -4672        exp = exp.copy()
    -4673        exp.set("alias", alias)
    -4674        return exp
    -4675    return Alias(this=exp, alias=alias)
    +            
    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)
     
    @@ -44331,27 +45231,27 @@ special characters it is quoted.
    -
    4678def subquery(expression, alias=None, dialect=None, **opts):
    -4679    """
    -4680    Build a subquery expression.
    -4681
    -4682    Example:
    -4683        >>> subquery('select x from tbl', 'bar').select('x').sql()
    -4684        'SELECT x FROM (SELECT x FROM tbl) AS bar'
    -4685
    -4686    Args:
    -4687        expression (str | Expression): the SQL code strings to parse.
    -4688            If an Expression instance is passed, this is used as-is.
    -4689        alias (str | Expression): the alias name to use.
    -4690        dialect (str): the dialect used to parse the input expression.
    -4691        **opts: other options to use to parse the input expressions.
    -4692
    -4693    Returns:
    -4694        Select: a new select with the subquery expression included
    -4695    """
    -4696
    -4697    expression = maybe_parse(expression, dialect=dialect, **opts).subquery(alias)
    -4698    return Select().from_(expression, dialect=dialect, **opts)
    +            
    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)
     
    @@ -44397,31 +45297,31 @@ If an Expression instance is passed, this is used as-is.
    -
    4701def column(
    -4702    col: str | Identifier,
    -4703    table: t.Optional[str | Identifier] = None,
    -4704    db: t.Optional[str | Identifier] = None,
    -4705    catalog: t.Optional[str | Identifier] = None,
    -4706    quoted: t.Optional[bool] = None,
    -4707) -> Column:
    -4708    """
    -4709    Build a Column.
    -4710
    -4711    Args:
    -4712        col: column name
    -4713        table: table name
    -4714        db: db name
    -4715        catalog: catalog name
    -4716        quoted: whether or not to force quote each part
    -4717    Returns:
    -4718        Column: column instance
    -4719    """
    -4720    return Column(
    -4721        this=to_identifier(col, quoted=quoted),
    -4722        table=to_identifier(table, quoted=quoted),
    -4723        db=to_identifier(db, quoted=quoted),
    -4724        catalog=to_identifier(catalog, quoted=quoted),
    -4725    )
    +            
    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    )
     
    @@ -44457,22 +45357,22 @@ If an Expression instance is passed, this is used as-is.
    -
    4728def cast(expression: ExpOrStr, to: str | DataType | DataType.Type, **opts) -> Cast:
    -4729    """Cast an expression to a data type.
    -4730
    -4731    Example:
    -4732        >>> cast('x + 1', 'int').sql()
    -4733        'CAST(x + 1 AS INT)'
    -4734
    -4735    Args:
    -4736        expression: The expression to cast.
    -4737        to: The datatype to cast to.
    -4738
    -4739    Returns:
    -4740        A cast node.
    -4741    """
    -4742    expression = maybe_parse(expression, **opts)
    -4743    return Cast(this=expression, to=DataType.build(to, **opts))
    +            
    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))
     
    @@ -44515,23 +45415,23 @@ If an Expression instance is passed, this is used as-is.
    -
    4746def table_(table, db=None, catalog=None, quoted=None, alias=None) -> Table:
    -4747    """Build a Table.
    -4748
    -4749    Args:
    -4750        table (str | Expression): column name
    -4751        db (str | Expression): db name
    -4752        catalog (str | Expression): catalog name
    -4753
    -4754    Returns:
    -4755        Table: table instance
    -4756    """
    -4757    return Table(
    -4758        this=to_identifier(table, quoted=quoted),
    -4759        db=to_identifier(db, quoted=quoted),
    -4760        catalog=to_identifier(catalog, quoted=quoted),
    -4761        alias=TableAlias(this=to_identifier(alias)) if alias else None,
    -4762    )
    +            
    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    )
     
    @@ -44565,46 +45465,46 @@ If an Expression instance is passed, this is used as-is.
    -
    4765def values(
    -4766    values: t.Iterable[t.Tuple[t.Any, ...]],
    -4767    alias: t.Optional[str] = None,
    -4768    columns: t.Optional[t.Iterable[str] | t.Dict[str, DataType]] = None,
    -4769) -> Values:
    -4770    """Build VALUES statement.
    -4771
    -4772    Example:
    -4773        >>> values([(1, '2')]).sql()
    -4774        "VALUES (1, '2')"
    -4775
    -4776    Args:
    -4777        values: values statements that will be converted to SQL
    -4778        alias: optional alias
    -4779        columns: Optional list of ordered column names or ordered dictionary of column names to types.
    -4780         If either are provided then an alias is also required.
    -4781         If a dictionary is provided then the first column of the values will be casted to the expected type
    -4782         in order to help with type inference.
    -4783
    -4784    Returns:
    -4785        Values: the Values expression object
    -4786    """
    -4787    if columns and not alias:
    -4788        raise ValueError("Alias is required when providing columns")
    -4789    table_alias = (
    -4790        TableAlias(this=to_identifier(alias), columns=[to_identifier(x) for x in columns])
    -4791        if columns
    -4792        else TableAlias(this=to_identifier(alias) if alias else None)
    -4793    )
    -4794    expressions = [convert(tup) for tup in values]
    -4795    if columns and isinstance(columns, dict):
    -4796        types = list(columns.values())
    -4797        expressions[0].set(
    -4798            "expressions",
    -4799            [cast(x, types[i]) for i, x in enumerate(expressions[0].expressions)],
    -4800        )
    -4801    return Values(
    -4802        expressions=expressions,
    -4803        alias=table_alias,
    -4804    )
    +            
    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    )
     
    @@ -44651,28 +45551,28 @@ in order to help with type inference.
    -
    4807def var(name: t.Optional[ExpOrStr]) -> Var:
    -4808    """Build a SQL variable.
    -4809
    -4810    Example:
    -4811        >>> repr(var('x'))
    -4812        '(VAR this: x)'
    -4813
    -4814        >>> repr(var(column('x', table='y')))
    -4815        '(VAR this: x)'
    -4816
    -4817    Args:
    -4818        name: The name of the var or an expression who's name will become the var.
    -4819
    -4820    Returns:
    -4821        The new variable node.
    -4822    """
    -4823    if not name:
    -4824        raise ValueError("Cannot convert empty name into var.")
    -4825
    -4826    if isinstance(name, Expression):
    -4827        name = name.name
    -4828    return Var(this=name)
    +            
    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)
     
    @@ -44720,24 +45620,24 @@ in order to help with type inference.
    -
    4831def rename_table(old_name: str | Table, new_name: str | Table) -> AlterTable:
    -4832    """Build ALTER TABLE... RENAME... expression
    -4833
    -4834    Args:
    -4835        old_name: The old name of the table
    -4836        new_name: The new name of the table
    -4837
    -4838    Returns:
    -4839        Alter table expression
    -4840    """
    -4841    old_table = to_table(old_name)
    -4842    new_table = to_table(new_name)
    -4843    return AlterTable(
    -4844        this=old_table,
    -4845        actions=[
    -4846            RenameTable(this=new_table),
    -4847        ],
    -4848    )
    +            
    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    )
     
    @@ -44770,47 +45670,47 @@ in order to help with type inference.
    -
    4851def convert(value) -> Expression:
    -4852    """Convert a python value into an expression object.
    -4853
    -4854    Raises an error if a conversion is not possible.
    -4855
    -4856    Args:
    -4857        value (Any): a python object
    -4858
    -4859    Returns:
    -4860        Expression: the equivalent expression object
    -4861    """
    -4862    if isinstance(value, Expression):
    -4863        return value
    -4864    if value is None:
    -4865        return NULL
    -4866    if isinstance(value, bool):
    -4867        return Boolean(this=value)
    -4868    if isinstance(value, str):
    -4869        return Literal.string(value)
    -4870    if isinstance(value, float) and math.isnan(value):
    -4871        return NULL
    -4872    if isinstance(value, numbers.Number):
    -4873        return Literal.number(value)
    -4874    if isinstance(value, tuple):
    -4875        return Tuple(expressions=[convert(v) for v in value])
    -4876    if isinstance(value, list):
    -4877        return Array(expressions=[convert(v) for v in value])
    -4878    if isinstance(value, dict):
    -4879        return Map(
    -4880            keys=[convert(k) for k in value],
    -4881            values=[convert(v) for v in value.values()],
    -4882        )
    -4883    if isinstance(value, datetime.datetime):
    -4884        datetime_literal = Literal.string(
    -4885            (value if value.tzinfo else value.replace(tzinfo=datetime.timezone.utc)).isoformat()
    -4886        )
    -4887        return TimeStrToTime(this=datetime_literal)
    -4888    if isinstance(value, datetime.date):
    -4889        date_literal = Literal.string(value.strftime("%Y-%m-%d"))
    -4890        return DateStrToDate(this=date_literal)
    -4891    raise ValueError(f"Cannot convert {value}")
    +            
    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}")
     
    @@ -44844,26 +45744,26 @@ in order to help with type inference.
    -
    4894def replace_children(expression, fun, *args, **kwargs):
    -4895    """
    -4896    Replace children of an expression with the result of a lambda fun(child) -> exp.
    -4897    """
    -4898    for k, v in expression.args.items():
    -4899        is_list_arg = type(v) is list
    -4900
    -4901        child_nodes = v if is_list_arg else [v]
    -4902        new_child_nodes = []
    -4903
    -4904        for cn in child_nodes:
    -4905            if isinstance(cn, Expression):
    -4906                for child_node in ensure_collection(fun(cn, *args, **kwargs)):
    -4907                    new_child_nodes.append(child_node)
    -4908                    child_node.parent = expression
    -4909                    child_node.arg_key = k
    -4910            else:
    -4911                new_child_nodes.append(cn)
    -4912
    -4913        expression.args[k] = new_child_nodes if is_list_arg else seq_get(new_child_nodes, 0)
    +            
    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)
     
    @@ -44883,22 +45783,22 @@ in order to help with type inference.
    -
    4916def column_table_names(expression):
    -4917    """
    -4918    Return all table names referenced through columns in an expression.
    -4919
    -4920    Example:
    -4921        >>> import sqlglot
    -4922        >>> column_table_names(sqlglot.parse_one("a.b AND c.d AND c.e"))
    -4923        ['c', 'a']
    -4924
    -4925    Args:
    -4926        expression (sqlglot.Expression): expression to find table names
    -4927
    -4928    Returns:
    -4929        list: A list of unique names
    -4930    """
    -4931    return list(dict.fromkeys(column.table for column in expression.find_all(Column)))
    +            
    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)))
     
    @@ -44941,35 +45841,35 @@ in order to help with type inference.
    -
    4934def table_name(table) -> str:
    -4935    """Get the full name of a table as a string.
    -4936
    -4937    Args:
    -4938        table (exp.Table | str): table expression node or string.
    -4939
    -4940    Examples:
    -4941        >>> from sqlglot import exp, parse_one
    -4942        >>> table_name(parse_one("select * from a.b.c").find(exp.Table))
    -4943        'a.b.c'
    -4944
    -4945    Returns:
    -4946        The table name.
    -4947    """
    -4948
    -4949    table = maybe_parse(table, into=Table)
    -4950
    -4951    if not table:
    -4952        raise ValueError(f"Cannot parse {table}")
    -4953
    -4954    return ".".join(
    -4955        part
    -4956        for part in (
    -4957            table.text("catalog"),
    -4958            table.text("db"),
    -4959            table.name,
    -4960        )
    -4961        if part
    -4962    )
    +            
    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    )
     
    @@ -45012,33 +45912,33 @@ in order to help with type inference.
    -
    4965def replace_tables(expression, mapping):
    -4966    """Replace all tables in expression according to the mapping.
    -4967
    -4968    Args:
    -4969        expression (sqlglot.Expression): expression node to be transformed and replaced.
    -4970        mapping (Dict[str, str]): mapping of table names.
    -4971
    -4972    Examples:
    -4973        >>> from sqlglot import exp, parse_one
    -4974        >>> replace_tables(parse_one("select * from a.b"), {"a.b": "c"}).sql()
    -4975        'SELECT * FROM c'
    -4976
    -4977    Returns:
    -4978        The mapped expression.
    -4979    """
    -4980
    -4981    def _replace_tables(node):
    -4982        if isinstance(node, Table):
    -4983            new_name = mapping.get(table_name(node))
    -4984            if new_name:
    -4985                return to_table(
    -4986                    new_name,
    -4987                    **{k: v for k, v in node.args.items() if k not in ("this", "db", "catalog")},
    -4988                )
    -4989        return node
    -4990
    -4991    return expression.transform(_replace_tables)
    +            
    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)
     
    @@ -45082,40 +45982,40 @@ in order to help with type inference.
    -
    4994def replace_placeholders(expression, *args, **kwargs):
    -4995    """Replace placeholders in an expression.
    -4996
    -4997    Args:
    -4998        expression (sqlglot.Expression): expression node to be transformed and replaced.
    -4999        args: positional names that will substitute unnamed placeholders in the given order.
    -5000        kwargs: keyword arguments that will substitute named placeholders.
    -5001
    -5002    Examples:
    -5003        >>> from sqlglot import exp, parse_one
    -5004        >>> replace_placeholders(
    -5005        ...     parse_one("select * from :tbl where ? = ?"),
    -5006        ...     exp.to_identifier("str_col"), "b", tbl=exp.to_identifier("foo")
    -5007        ... ).sql()
    -5008        "SELECT * FROM foo WHERE str_col = 'b'"
    -5009
    -5010    Returns:
    -5011        The mapped expression.
    -5012    """
    -5013
    -5014    def _replace_placeholders(node, args, **kwargs):
    -5015        if isinstance(node, Placeholder):
    -5016            if node.name:
    -5017                new_name = kwargs.get(node.name)
    -5018                if new_name:
    -5019                    return convert(new_name)
    -5020            else:
    -5021                try:
    -5022                    return convert(next(args))
    -5023                except StopIteration:
    -5024                    pass
    -5025        return node
    -5026
    -5027    return expression.transform(_replace_placeholders, iter(args), **kwargs)
    +            
    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)
     
    @@ -45157,40 +46057,45 @@ in order to help with type inference.
    def - expand( expression: sqlglot.expressions.Expression, sources: Dict[str, sqlglot.expressions.Subqueryable], copy=True) -> sqlglot.expressions.Expression: + expand( expression: sqlglot.expressions.Expression, sources: Dict[str, sqlglot.expressions.Subqueryable], copy: bool = True) -> sqlglot.expressions.Expression:
    -
    5030def expand(expression: Expression, sources: t.Dict[str, Subqueryable], copy=True) -> Expression:
    -5031    """Transforms an expression by expanding all referenced sources into subqueries.
    -5032
    -5033    Examples:
    -5034        >>> from sqlglot import parse_one
    -5035        >>> expand(parse_one("select * from x AS z"), {"x": parse_one("select * from y")}).sql()
    -5036        'SELECT * FROM (SELECT * FROM y) AS z /* source: x */'
    -5037
    -5038    Args:
    -5039        expression: The expression to expand.
    -5040        sources: A dictionary of name to Subqueryables.
    -5041        copy: Whether or not to copy the expression during transformation. Defaults to True.
    -5042
    -5043    Returns:
    -5044        The transformed expression.
    -5045    """
    -5046
    -5047    def _expand(node: Expression):
    -5048        if isinstance(node, Table):
    -5049            name = table_name(node)
    -5050            source = sources.get(name)
    -5051            if source:
    -5052                subquery = source.subquery(node.alias or name)
    -5053                subquery.comments = [f"source: {name}"]
    -5054                return subquery
    -5055        return node
    -5056
    -5057    return expression.transform(_expand, copy=copy)
    +            
    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)
     
    @@ -45203,6 +46108,12 @@ in order to help with type inference.
    >>> from sqlglot import parse_one
     >>> expand(parse_one("select * from x AS z"), {"x": parse_one("select * from y")}).sql()
     'SELECT * FROM (SELECT * FROM y) AS z /* source: x */'
    +
    +
    + +
    +
    >>> expand(parse_one("select * from x AS z"), {"x": parse_one("select * from y"), "y": parse_one("select * from z")}).sql()
    +'SELECT * FROM (SELECT * FROM (SELECT * FROM z) AS y /* source: y */) AS z /* source: x */'
     
    @@ -45235,51 +46146,51 @@ in order to help with type inference.
    -
    5060def func(name: str, *args, dialect: DialectType = None, **kwargs) -> Func:
    -5061    """
    -5062    Returns a Func expression.
    -5063
    -5064    Examples:
    -5065        >>> func("abs", 5).sql()
    -5066        'ABS(5)'
    -5067
    -5068        >>> func("cast", this=5, to=DataType.build("DOUBLE")).sql()
    -5069        'CAST(5 AS DOUBLE)'
    -5070
    -5071    Args:
    -5072        name: the name of the function to build.
    -5073        args: the args used to instantiate the function of interest.
    -5074        dialect: the source dialect.
    -5075        kwargs: the kwargs used to instantiate the function of interest.
    -5076
    -5077    Note:
    -5078        The arguments `args` and `kwargs` are mutually exclusive.
    -5079
    -5080    Returns:
    -5081        An instance of the function of interest, or an anonymous function, if `name` doesn't
    -5082        correspond to an existing `sqlglot.expressions.Func` class.
    -5083    """
    -5084    if args and kwargs:
    -5085        raise ValueError("Can't use both args and kwargs to instantiate a function.")
    -5086
    -5087    from sqlglot.dialects.dialect import Dialect
    -5088
    -5089    converted = [convert(arg) for arg in args]
    -5090    kwargs = {key: convert(value) for key, value in kwargs.items()}
    -5091
    -5092    parser = Dialect.get_or_raise(dialect)().parser()
    -5093    from_args_list = parser.FUNCTIONS.get(name.upper())
    -5094
    -5095    if from_args_list:
    -5096        function = from_args_list(converted) if converted else from_args_list.__self__(**kwargs)  # type: ignore
    -5097    else:
    -5098        kwargs = kwargs or {"expressions": converted}
    -5099        function = Anonymous(this=name, **kwargs)
    -5100
    -5101    for error_message in function.error_messages(converted):
    -5102        raise ValueError(error_message)
    -5103
    -5104    return function
    +            
    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
     
    @@ -45337,11 +46248,11 @@ in order to help with type inference.
    -
    5107def true():
    -5108    """
    -5109    Returns a true Boolean expression.
    -5110    """
    -5111    return Boolean(this=True)
    +            
    5202def true():
    +5203    """
    +5204    Returns a true Boolean expression.
    +5205    """
    +5206    return Boolean(this=True)
     
    @@ -45361,11 +46272,11 @@ in order to help with type inference.
    -
    5114def false():
    -5115    """
    -5116    Returns a false Boolean expression.
    -5117    """
    -5118    return Boolean(this=False)
    +            
    5209def false():
    +5210    """
    +5211    Returns a false Boolean expression.
    +5212    """
    +5213    return Boolean(this=False)
     
    @@ -45385,11 +46296,11 @@ in order to help with type inference.
    -
    5121def null():
    -5122    """
    -5123    Returns a Null expression.
    -5124    """
    -5125    return Null()
    +            
    5216def null():
    +5217    """
    +5218    Returns a Null expression.
    +5219    """
    +5220    return Null()
     
    -- cgit v1.2.3