sqlglot 26.25.2__py3-none-any.whl → 26.26.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sqlglot/_version.py +2 -2
- sqlglot/dialects/bigquery.py +10 -0
- sqlglot/dialects/clickhouse.py +1 -0
- sqlglot/dialects/postgres.py +11 -1
- sqlglot/dialects/risingwave.py +4 -0
- sqlglot/dialects/snowflake.py +3 -0
- sqlglot/dialects/spark.py +1 -0
- sqlglot/dialects/sqlite.py +9 -0
- sqlglot/dialects/starrocks.py +16 -1
- sqlglot/expressions.py +36 -9
- sqlglot/generator.py +1 -3
- sqlglot/parser.py +86 -4
- {sqlglot-26.25.2.dist-info → sqlglot-26.26.0.dist-info}/METADATA +2 -1
- {sqlglot-26.25.2.dist-info → sqlglot-26.26.0.dist-info}/RECORD +17 -17
- {sqlglot-26.25.2.dist-info → sqlglot-26.26.0.dist-info}/WHEEL +0 -0
- {sqlglot-26.25.2.dist-info → sqlglot-26.26.0.dist-info}/licenses/LICENSE +0 -0
- {sqlglot-26.25.2.dist-info → sqlglot-26.26.0.dist-info}/top_level.txt +0 -0
sqlglot/_version.py
CHANGED
sqlglot/dialects/bigquery.py
CHANGED
@@ -525,6 +525,16 @@ class BigQuery(Dialect):
|
|
525
525
|
LOG_DEFAULTS_TO_LN = True
|
526
526
|
SUPPORTS_IMPLICIT_UNNEST = True
|
527
527
|
|
528
|
+
# BigQuery does not allow ASC/DESC to be used as an identifier
|
529
|
+
ID_VAR_TOKENS = parser.Parser.ID_VAR_TOKENS - {TokenType.ASC, TokenType.DESC}
|
530
|
+
ALIAS_TOKENS = parser.Parser.ALIAS_TOKENS - {TokenType.ASC, TokenType.DESC}
|
531
|
+
TABLE_ALIAS_TOKENS = parser.Parser.TABLE_ALIAS_TOKENS - {TokenType.ASC, TokenType.DESC}
|
532
|
+
COMMENT_TABLE_ALIAS_TOKENS = parser.Parser.COMMENT_TABLE_ALIAS_TOKENS - {
|
533
|
+
TokenType.ASC,
|
534
|
+
TokenType.DESC,
|
535
|
+
}
|
536
|
+
UPDATE_ALIAS_TOKENS = parser.Parser.UPDATE_ALIAS_TOKENS - {TokenType.ASC, TokenType.DESC}
|
537
|
+
|
528
538
|
FUNCTIONS = {
|
529
539
|
**parser.Parser.FUNCTIONS,
|
530
540
|
"CONTAINS_SUBSTR": _build_contains_substring,
|
sqlglot/dialects/clickhouse.py
CHANGED
@@ -1096,6 +1096,7 @@ class ClickHouse(Dialect):
|
|
1096
1096
|
exp.RegexpLike: lambda self, e: self.func("match", e.this, e.expression),
|
1097
1097
|
exp.Rand: rename_func("randCanonical"),
|
1098
1098
|
exp.StartsWith: rename_func("startsWith"),
|
1099
|
+
exp.EndsWith: rename_func("endsWith"),
|
1099
1100
|
exp.StrPosition: lambda self, e: strposition_sql(
|
1100
1101
|
self,
|
1101
1102
|
e,
|
sqlglot/dialects/postgres.py
CHANGED
@@ -36,6 +36,7 @@ from sqlglot.dialects.dialect import (
|
|
36
36
|
strposition_sql,
|
37
37
|
count_if_to_sum,
|
38
38
|
groupconcat_sql,
|
39
|
+
Version,
|
39
40
|
)
|
40
41
|
from sqlglot.generator import unsupported_args
|
41
42
|
from sqlglot.helper import is_int, seq_get
|
@@ -255,6 +256,15 @@ def _levenshtein_sql(self: Postgres.Generator, expression: exp.Levenshtein) -> s
|
|
255
256
|
return rename_func(name)(self, expression)
|
256
257
|
|
257
258
|
|
259
|
+
def _versioned_anyvalue_sql(self: Postgres.Generator, expression: exp.AnyValue) -> str:
|
260
|
+
# https://www.postgresql.org/docs/16/functions-aggregate.html
|
261
|
+
# https://www.postgresql.org/about/featurematrix/
|
262
|
+
if self.dialect.version < Version("16.0"):
|
263
|
+
return any_value_to_max_sql(self, expression)
|
264
|
+
|
265
|
+
return rename_func("ANY_VALUE")(self, expression)
|
266
|
+
|
267
|
+
|
258
268
|
class Postgres(Dialect):
|
259
269
|
INDEX_OFFSET = 1
|
260
270
|
TYPED_DIVISION = True
|
@@ -546,7 +556,7 @@ class Postgres(Dialect):
|
|
546
556
|
|
547
557
|
TRANSFORMS = {
|
548
558
|
**generator.Generator.TRANSFORMS,
|
549
|
-
exp.AnyValue:
|
559
|
+
exp.AnyValue: _versioned_anyvalue_sql,
|
550
560
|
exp.ArrayConcat: lambda self, e: self.arrayconcat_sql(e, name="ARRAY_CAT"),
|
551
561
|
exp.ArrayFilter: filter_array_using_unnest,
|
552
562
|
exp.BitwiseXor: lambda self, e: self.binary(e, "#"),
|
sqlglot/dialects/risingwave.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
from sqlglot.dialects.postgres import Postgres
|
3
|
+
from sqlglot.generator import Generator
|
3
4
|
from sqlglot.tokens import TokenType
|
4
5
|
import typing as t
|
5
6
|
|
@@ -72,3 +73,6 @@ class RisingWave(Postgres):
|
|
72
73
|
}
|
73
74
|
|
74
75
|
EXPRESSION_PRECEDES_PROPERTIES_CREATABLES = {"SINK"}
|
76
|
+
|
77
|
+
def computedcolumnconstraint_sql(self, expression: exp.ComputedColumnConstraint) -> str:
|
78
|
+
return Generator.computedcolumnconstraint_sql(self, expression)
|
sqlglot/dialects/snowflake.py
CHANGED
@@ -1019,6 +1019,7 @@ class Snowflake(Dialect):
|
|
1019
1019
|
exp.ArgMin: rename_func("MIN_BY"),
|
1020
1020
|
exp.ArrayConcat: lambda self, e: self.arrayconcat_sql(e, name="ARRAY_CAT"),
|
1021
1021
|
exp.ArrayContains: lambda self, e: self.func("ARRAY_CONTAINS", e.expression, e.this),
|
1022
|
+
exp.ArrayIntersect: rename_func("ARRAY_INTERSECTION"),
|
1022
1023
|
exp.AtTimeZone: lambda self, e: self.func(
|
1023
1024
|
"CONVERT_TIMEZONE", e.args.get("zone"), e.this
|
1024
1025
|
),
|
@@ -1094,11 +1095,13 @@ class Snowflake(Dialect):
|
|
1094
1095
|
exp.SHA: rename_func("SHA1"),
|
1095
1096
|
exp.StarMap: rename_func("OBJECT_CONSTRUCT"),
|
1096
1097
|
exp.StartsWith: rename_func("STARTSWITH"),
|
1098
|
+
exp.EndsWith: rename_func("ENDSWITH"),
|
1097
1099
|
exp.StrPosition: lambda self, e: strposition_sql(
|
1098
1100
|
self, e, func_name="CHARINDEX", supports_position=True
|
1099
1101
|
),
|
1100
1102
|
exp.StrToDate: lambda self, e: self.func("DATE", e.this, self.format_time(e)),
|
1101
1103
|
exp.Stuff: rename_func("INSERT"),
|
1104
|
+
exp.StPoint: rename_func("ST_MAKEPOINT"),
|
1102
1105
|
exp.TimeAdd: date_delta_sql("TIMEADD"),
|
1103
1106
|
exp.Timestamp: no_timestamp_sql,
|
1104
1107
|
exp.TimestampAdd: date_delta_sql("TIMESTAMPADD"),
|
sqlglot/dialects/spark.py
CHANGED
@@ -163,6 +163,7 @@ class Spark(Spark2):
|
|
163
163
|
move_partitioned_by_to_schema_columns,
|
164
164
|
]
|
165
165
|
),
|
166
|
+
exp.EndsWith: rename_func("ENDSWITH"),
|
166
167
|
exp.PartitionedByProperty: lambda self,
|
167
168
|
e: f"PARTITIONED BY {self.wrap(self.expressions(sqls=[_normalize_partition(e) for e in e.this.expressions], skip_first=True))}",
|
168
169
|
exp.StartsWith: rename_func("STARTSWITH"),
|
sqlglot/dialects/sqlite.py
CHANGED
@@ -99,6 +99,8 @@ class SQLite(Dialect):
|
|
99
99
|
KEYWORDS = tokens.Tokenizer.KEYWORDS.copy()
|
100
100
|
KEYWORDS.pop("/*+")
|
101
101
|
|
102
|
+
COMMANDS = {*tokens.Tokenizer.COMMANDS, TokenType.REPLACE}
|
103
|
+
|
102
104
|
class Parser(parser.Parser):
|
103
105
|
FUNCTIONS = {
|
104
106
|
**parser.Parser.FUNCTIONS,
|
@@ -307,3 +309,10 @@ class SQLite(Dialect):
|
|
307
309
|
@unsupported_args("this")
|
308
310
|
def currentschema_sql(self, expression: exp.CurrentSchema) -> str:
|
309
311
|
return "'main'"
|
312
|
+
|
313
|
+
def ignorenulls_sql(self, expression: exp.IgnoreNulls) -> str:
|
314
|
+
self.unsupported("SQLite does not support IGNORE NULLS.")
|
315
|
+
return self.sql(expression.this)
|
316
|
+
|
317
|
+
def respectnulls_sql(self, expression: exp.RespectNulls) -> str:
|
318
|
+
return self.sql(expression.this)
|
sqlglot/dialects/starrocks.py
CHANGED
@@ -17,6 +17,19 @@ from sqlglot.helper import seq_get
|
|
17
17
|
from sqlglot.tokens import TokenType
|
18
18
|
|
19
19
|
|
20
|
+
# https://docs.starrocks.io/docs/sql-reference/sql-functions/spatial-functions/st_distance_sphere/
|
21
|
+
def st_distance_sphere(self, expression: exp.StDistance) -> str:
|
22
|
+
point1 = expression.this
|
23
|
+
point2 = expression.expression
|
24
|
+
|
25
|
+
point1_x = self.func("ST_X", point1)
|
26
|
+
point1_y = self.func("ST_Y", point1)
|
27
|
+
point2_x = self.func("ST_X", point2)
|
28
|
+
point2_y = self.func("ST_Y", point2)
|
29
|
+
|
30
|
+
return self.func("ST_Distance_Sphere", point1_x, point1_y, point2_x, point2_y)
|
31
|
+
|
32
|
+
|
20
33
|
class StarRocks(MySQL):
|
21
34
|
STRICT_JSON_PATH_SYNTAX = False
|
22
35
|
|
@@ -132,6 +145,8 @@ class StarRocks(MySQL):
|
|
132
145
|
TRANSFORMS = {
|
133
146
|
**MySQL.Generator.TRANSFORMS,
|
134
147
|
exp.Array: inline_array_sql,
|
148
|
+
exp.ArrayAgg: rename_func("ARRAY_AGG"),
|
149
|
+
exp.ArrayFilter: rename_func("ARRAY_FILTER"),
|
135
150
|
exp.ArrayToString: rename_func("ARRAY_JOIN"),
|
136
151
|
exp.ApproxDistinct: approx_count_distinct_sql,
|
137
152
|
exp.DateDiff: lambda self, e: self.func(
|
@@ -141,12 +156,12 @@ class StarRocks(MySQL):
|
|
141
156
|
exp.JSONExtract: arrow_json_extract_sql,
|
142
157
|
exp.Property: property_sql,
|
143
158
|
exp.RegexpLike: rename_func("REGEXP"),
|
159
|
+
exp.StDistance: st_distance_sphere,
|
144
160
|
exp.StrToUnix: lambda self, e: self.func("UNIX_TIMESTAMP", e.this, self.format_time(e)),
|
145
161
|
exp.TimestampTrunc: lambda self, e: self.func("DATE_TRUNC", unit_to_str(e), e.this),
|
146
162
|
exp.TimeStrToDate: rename_func("TO_DATE"),
|
147
163
|
exp.UnixToStr: lambda self, e: self.func("FROM_UNIXTIME", e.this, self.format_time(e)),
|
148
164
|
exp.UnixToTime: rename_func("FROM_UNIXTIME"),
|
149
|
-
exp.ArrayFilter: rename_func("ARRAY_FILTER"),
|
150
165
|
}
|
151
166
|
|
152
167
|
TRANSFORMS.pop(exp.DateTrunc)
|
sqlglot/expressions.py
CHANGED
@@ -31,6 +31,7 @@ from sqlglot.helper import (
|
|
31
31
|
ensure_collection,
|
32
32
|
ensure_list,
|
33
33
|
seq_get,
|
34
|
+
split_num_words,
|
34
35
|
subclasses,
|
35
36
|
to_bool,
|
36
37
|
)
|
@@ -1993,11 +1994,6 @@ class OnUpdateColumnConstraint(ColumnConstraintKind):
|
|
1993
1994
|
pass
|
1994
1995
|
|
1995
1996
|
|
1996
|
-
# https://docs.snowflake.com/en/sql-reference/sql/create-external-table#optional-parameters
|
1997
|
-
class TransformColumnConstraint(ColumnConstraintKind):
|
1998
|
-
pass
|
1999
|
-
|
2000
|
-
|
2001
1997
|
class PrimaryKeyColumnConstraint(ColumnConstraintKind):
|
2002
1998
|
arg_types = {"desc": False, "options": False}
|
2003
1999
|
|
@@ -5570,6 +5566,21 @@ class ArrayToString(Func):
|
|
5570
5566
|
_sql_names = ["ARRAY_TO_STRING", "ARRAY_JOIN"]
|
5571
5567
|
|
5572
5568
|
|
5569
|
+
class ArrayIntersect(Func):
|
5570
|
+
arg_types = {"expressions": True}
|
5571
|
+
is_var_len_args = True
|
5572
|
+
_sql_names = ["ARRAY_INTERSECT", "ARRAY_INTERSECTION"]
|
5573
|
+
|
5574
|
+
|
5575
|
+
class StPoint(Func):
|
5576
|
+
arg_types = {"this": True, "expression": True, "null": False}
|
5577
|
+
_sql_names = ["ST_POINT", "ST_MAKEPOINT"]
|
5578
|
+
|
5579
|
+
|
5580
|
+
class StDistance(Func):
|
5581
|
+
arg_types = {"this": True, "expression": True, "use_spheroid": False}
|
5582
|
+
|
5583
|
+
|
5573
5584
|
# https://cloud.google.com/bigquery/docs/reference/standard-sql/timestamp_functions#string
|
5574
5585
|
class String(Func):
|
5575
5586
|
arg_types = {"this": True, "zone": False}
|
@@ -6706,6 +6717,11 @@ class StartsWith(Func):
|
|
6706
6717
|
arg_types = {"this": True, "expression": True}
|
6707
6718
|
|
6708
6719
|
|
6720
|
+
class EndsWith(Func):
|
6721
|
+
_sql_names = ["ENDS_WITH", "ENDSWITH"]
|
6722
|
+
arg_types = {"this": True, "expression": True}
|
6723
|
+
|
6724
|
+
|
6709
6725
|
class StrPosition(Func):
|
6710
6726
|
arg_types = {
|
6711
6727
|
"this": True,
|
@@ -7366,7 +7382,7 @@ def _apply_set_operation(
|
|
7366
7382
|
**opts,
|
7367
7383
|
) -> S:
|
7368
7384
|
return reduce(
|
7369
|
-
lambda x, y: set_operation(this=x, expression=y, distinct=distinct),
|
7385
|
+
lambda x, y: set_operation(this=x, expression=y, distinct=distinct, **opts),
|
7370
7386
|
(maybe_parse(e, dialect=dialect, copy=copy, **opts) for e in expressions),
|
7371
7387
|
)
|
7372
7388
|
|
@@ -7962,7 +7978,15 @@ def to_table(
|
|
7962
7978
|
if isinstance(sql_path, Table):
|
7963
7979
|
return maybe_copy(sql_path, copy=copy)
|
7964
7980
|
|
7965
|
-
|
7981
|
+
try:
|
7982
|
+
table = maybe_parse(sql_path, into=Table, dialect=dialect)
|
7983
|
+
except ParseError:
|
7984
|
+
catalog, db, this = split_num_words(sql_path, ".", 3)
|
7985
|
+
|
7986
|
+
if not this:
|
7987
|
+
raise
|
7988
|
+
|
7989
|
+
table = table_(this, db=db, catalog=catalog)
|
7966
7990
|
|
7967
7991
|
for k, v in kwargs.items():
|
7968
7992
|
table.set(k, v)
|
@@ -8110,7 +8134,7 @@ def column(
|
|
8110
8134
|
|
8111
8135
|
@t.overload
|
8112
8136
|
def column(
|
8113
|
-
col: str | Identifier,
|
8137
|
+
col: str | Identifier | Star,
|
8114
8138
|
table: t.Optional[str | Identifier] = None,
|
8115
8139
|
db: t.Optional[str | Identifier] = None,
|
8116
8140
|
catalog: t.Optional[str | Identifier] = None,
|
@@ -8147,8 +8171,11 @@ def column(
|
|
8147
8171
|
Returns:
|
8148
8172
|
The new Column instance.
|
8149
8173
|
"""
|
8174
|
+
if not isinstance(col, Star):
|
8175
|
+
col = to_identifier(col, quoted=quoted, copy=copy)
|
8176
|
+
|
8150
8177
|
this = Column(
|
8151
|
-
this=
|
8178
|
+
this=col,
|
8152
8179
|
table=to_identifier(table, quoted=quoted, copy=copy),
|
8153
8180
|
db=to_identifier(db, quoted=quoted, copy=copy),
|
8154
8181
|
catalog=to_identifier(catalog, quoted=quoted, copy=copy),
|
sqlglot/generator.py
CHANGED
@@ -1018,6 +1018,7 @@ class Generator(metaclass=_Generator):
|
|
1018
1018
|
persisted = " PERSISTED"
|
1019
1019
|
else:
|
1020
1020
|
persisted = ""
|
1021
|
+
|
1021
1022
|
return f"AS {this}{persisted}"
|
1022
1023
|
|
1023
1024
|
def autoincrementcolumnconstraint_sql(self, _) -> str:
|
@@ -1079,9 +1080,6 @@ class Generator(metaclass=_Generator):
|
|
1079
1080
|
def notnullcolumnconstraint_sql(self, expression: exp.NotNullColumnConstraint) -> str:
|
1080
1081
|
return f"{'' if expression.args.get('allow_null') else 'NOT '}NULL"
|
1081
1082
|
|
1082
|
-
def transformcolumnconstraint_sql(self, expression: exp.TransformColumnConstraint) -> str:
|
1083
|
-
return f"AS {self.sql(expression, 'this')}"
|
1084
|
-
|
1085
1083
|
def primarykeycolumnconstraint_sql(self, expression: exp.PrimaryKeyColumnConstraint) -> str:
|
1086
1084
|
desc = expression.args.get("desc")
|
1087
1085
|
if desc is not None:
|
sqlglot/parser.py
CHANGED
@@ -936,6 +936,7 @@ class Parser(metaclass=_Parser):
|
|
936
936
|
"ORDER BY": lambda self, query: query.order_by(self._parse_order(), copy=False),
|
937
937
|
"LIMIT": lambda self, query: self._parse_pipe_syntax_limit(query),
|
938
938
|
"OFFSET": lambda self, query: query.offset(self._parse_offset(), copy=False),
|
939
|
+
"AGGREGATE": lambda self, query: self._parse_pipe_syntax_aggregate(query),
|
939
940
|
}
|
940
941
|
|
941
942
|
PROPERTY_PARSERS: t.Dict[str, t.Callable] = {
|
@@ -1143,6 +1144,78 @@ class Parser(metaclass=_Parser):
|
|
1143
1144
|
query.offset(offset, copy=False)
|
1144
1145
|
return query
|
1145
1146
|
|
1147
|
+
def _parse_pipe_syntax_aggregate_fields(self) -> t.Optional[exp.Expression]:
|
1148
|
+
this = self._parse_assignment()
|
1149
|
+
if self._match_text_seq("GROUP", "AND", advance=False):
|
1150
|
+
return this
|
1151
|
+
|
1152
|
+
this = self._parse_alias(this)
|
1153
|
+
|
1154
|
+
if self._match_set((TokenType.ASC, TokenType.DESC), advance=False):
|
1155
|
+
return self._parse_ordered(lambda: this)
|
1156
|
+
|
1157
|
+
return this
|
1158
|
+
|
1159
|
+
def _parse_pipe_syntax_aggregate_group_order_by(
|
1160
|
+
self, query: exp.Query, group_by_exists: bool = True
|
1161
|
+
) -> exp.Query:
|
1162
|
+
expr = self._parse_csv(self._parse_pipe_syntax_aggregate_fields)
|
1163
|
+
aggregates_or_groups, orders = [], []
|
1164
|
+
for element in expr:
|
1165
|
+
if isinstance(element, exp.Ordered):
|
1166
|
+
this = element.this
|
1167
|
+
if isinstance(this, exp.Alias):
|
1168
|
+
element.set("this", this.args["alias"])
|
1169
|
+
orders.append(element)
|
1170
|
+
else:
|
1171
|
+
this = element
|
1172
|
+
aggregates_or_groups.append(this)
|
1173
|
+
|
1174
|
+
if group_by_exists and isinstance(query, exp.Select):
|
1175
|
+
query = query.select(*aggregates_or_groups, copy=False).group_by(
|
1176
|
+
*[element.args.get("alias", element) for element in aggregates_or_groups],
|
1177
|
+
copy=False,
|
1178
|
+
)
|
1179
|
+
else:
|
1180
|
+
query = exp.select(*aggregates_or_groups, copy=False).from_(
|
1181
|
+
query.subquery(copy=False), copy=False
|
1182
|
+
)
|
1183
|
+
|
1184
|
+
if orders:
|
1185
|
+
return query.order_by(*orders, copy=False)
|
1186
|
+
|
1187
|
+
return query
|
1188
|
+
|
1189
|
+
def _parse_pipe_syntax_aggregate(self, query: exp.Query) -> exp.Query:
|
1190
|
+
self._match_text_seq("AGGREGATE")
|
1191
|
+
query = self._parse_pipe_syntax_aggregate_group_order_by(query, group_by_exists=False)
|
1192
|
+
|
1193
|
+
if self._match(TokenType.GROUP_BY) or (
|
1194
|
+
self._match_text_seq("GROUP", "AND") and self._match(TokenType.ORDER_BY)
|
1195
|
+
):
|
1196
|
+
return self._parse_pipe_syntax_aggregate_group_order_by(query)
|
1197
|
+
|
1198
|
+
return query
|
1199
|
+
|
1200
|
+
def _parse_pipe_syntax_set_operator(
|
1201
|
+
self, query: t.Optional[exp.Query]
|
1202
|
+
) -> t.Optional[exp.Query]:
|
1203
|
+
first_setop = self.parse_set_operation(this=query)
|
1204
|
+
|
1205
|
+
if not first_setop or not query:
|
1206
|
+
return None
|
1207
|
+
|
1208
|
+
first_setop.this.pop()
|
1209
|
+
distinct = first_setop.args.pop("distinct")
|
1210
|
+
|
1211
|
+
setops = [first_setop.expression.pop(), *self._parse_expressions()]
|
1212
|
+
|
1213
|
+
if isinstance(first_setop, exp.Union):
|
1214
|
+
return query.union(*setops, distinct=distinct, **first_setop.args)
|
1215
|
+
if isinstance(first_setop, exp.Except):
|
1216
|
+
return query.except_(*setops, distinct=distinct, **first_setop.args)
|
1217
|
+
return query.intersect(*setops, distinct=distinct, **first_setop.args)
|
1218
|
+
|
1146
1219
|
def _parse_partitioned_by_bucket_or_truncate(self) -> exp.Expression:
|
1147
1220
|
klass = (
|
1148
1221
|
exp.PartitionedByBucket
|
@@ -5900,7 +5973,7 @@ class Parser(metaclass=_Parser):
|
|
5900
5973
|
constraints.append(
|
5901
5974
|
self.expression(
|
5902
5975
|
exp.ColumnConstraint,
|
5903
|
-
kind=exp.
|
5976
|
+
kind=exp.ComputedColumnConstraint(this=self._parse_disjunction()),
|
5904
5977
|
)
|
5905
5978
|
)
|
5906
5979
|
|
@@ -7163,11 +7236,18 @@ class Parser(metaclass=_Parser):
|
|
7163
7236
|
|
7164
7237
|
return this
|
7165
7238
|
|
7166
|
-
def _parse_pipe_syntax_query(self, query: exp.
|
7239
|
+
def _parse_pipe_syntax_query(self, query: exp.Query) -> t.Optional[exp.Query]:
|
7167
7240
|
while self._match(TokenType.PIPE_GT):
|
7241
|
+
start = self._curr
|
7168
7242
|
parser = self.PIPE_SYNTAX_TRANSFORM_PARSERS.get(self._curr.text.upper())
|
7169
7243
|
if not parser:
|
7170
|
-
|
7244
|
+
set_op_query = self._parse_pipe_syntax_set_operator(query)
|
7245
|
+
if not set_op_query:
|
7246
|
+
self._retreat(start)
|
7247
|
+
self.raise_error(f"Unsupported pipe syntax operator: '{start.text.upper()}'.")
|
7248
|
+
break
|
7249
|
+
|
7250
|
+
query = set_op_query
|
7171
7251
|
else:
|
7172
7252
|
query = parser(self, query)
|
7173
7253
|
|
@@ -8213,6 +8293,8 @@ class Parser(metaclass=_Parser):
|
|
8213
8293
|
)
|
8214
8294
|
|
8215
8295
|
def _parse_star_ops(self) -> t.Optional[exp.Expression]:
|
8296
|
+
star_token = self._prev
|
8297
|
+
|
8216
8298
|
if self._match_text_seq("COLUMNS", "(", advance=False):
|
8217
8299
|
this = self._parse_function()
|
8218
8300
|
if isinstance(this, exp.Columns):
|
@@ -8226,7 +8308,7 @@ class Parser(metaclass=_Parser):
|
|
8226
8308
|
"replace": self._parse_star_op("REPLACE"),
|
8227
8309
|
"rename": self._parse_star_op("RENAME"),
|
8228
8310
|
},
|
8229
|
-
)
|
8311
|
+
).update_positions(star_token)
|
8230
8312
|
|
8231
8313
|
def _parse_grant_privilege(self) -> t.Optional[exp.GrantPrivilege]:
|
8232
8314
|
privilege_parts = []
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: sqlglot
|
3
|
-
Version: 26.
|
3
|
+
Version: 26.26.0
|
4
4
|
Summary: An easily customizable SQL parser and transpiler
|
5
5
|
Author-email: Toby Mao <toby.mao@gmail.com>
|
6
6
|
License: MIT License
|
@@ -558,6 +558,7 @@ See also: [Writing a Python SQL engine from scratch](https://github.com/tobymao/
|
|
558
558
|
* [Dagster](https://github.com/dagster-io/dagster)
|
559
559
|
* [Fugue](https://github.com/fugue-project/fugue)
|
560
560
|
* [Ibis](https://github.com/ibis-project/ibis)
|
561
|
+
* [dlt](https://github.com/dlt-hub/dlt)
|
561
562
|
* [mysql-mimic](https://github.com/kelsin/mysql-mimic)
|
562
563
|
* [Querybook](https://github.com/pinterest/querybook)
|
563
564
|
* [Quokka](https://github.com/marsupialtail/quokka)
|
@@ -1,15 +1,15 @@
|
|
1
1
|
sqlglot/__init__.py,sha256=za08rtdPh2v7dOpGdNomttlIVGgTrKja7rPd6sQwaTg,5391
|
2
2
|
sqlglot/__main__.py,sha256=022c173KqxsiABWTEpUIq_tJUxuNiW7a7ABsxBXqvu8,2069
|
3
3
|
sqlglot/_typing.py,sha256=-1HPyr3w5COlSJWqlgt8jhFk2dyMvBuvVBqIX1wyVCM,642
|
4
|
-
sqlglot/_version.py,sha256=
|
4
|
+
sqlglot/_version.py,sha256=YIRxjNMWWorDaNkCL1dWusQPFAthcmiMLy53HgsVsoQ,515
|
5
5
|
sqlglot/diff.py,sha256=PtOllQMQa1Sw1-V2Y8eypmDqGujXYPaTOp_WLsWkAWk,17314
|
6
6
|
sqlglot/errors.py,sha256=QNKMr-pzLUDR-tuMmn_GK6iMHUIVdb_YSJ_BhGEvuso,2126
|
7
|
-
sqlglot/expressions.py,sha256=
|
8
|
-
sqlglot/generator.py,sha256=
|
7
|
+
sqlglot/expressions.py,sha256=vVF2fwwgwo2TWmgpBU4_kYz28xVZ7hhSoaIfpbeyMck,242714
|
8
|
+
sqlglot/generator.py,sha256=4JFrruvOtWB1vM470PzTNQC2yGG_7XOiogAjEukuhek,212229
|
9
9
|
sqlglot/helper.py,sha256=9nZjFVRBtMKFC3EdzpDQ6jkazFO19po6BF8xHiNGZIo,15111
|
10
10
|
sqlglot/jsonpath.py,sha256=dKdI3PNINNGimmSse2IIv-GbPN_3lXncXh_70QH7Lss,7664
|
11
11
|
sqlglot/lineage.py,sha256=kXBDSErmZZluZx_kkrMj4MPEOAbkvcbX1tbOW7Bpl-U,15303
|
12
|
-
sqlglot/parser.py,sha256=
|
12
|
+
sqlglot/parser.py,sha256=Qz6C1DARQxi60XGcAicOtUdb9K6RNEH2Fe689s0jrzA,317671
|
13
13
|
sqlglot/planner.py,sha256=ql7Li-bWJRcyXzNaZy_n6bQ6B2ZfunEIB8Ztv2xaxq4,14634
|
14
14
|
sqlglot/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
15
|
sqlglot/schema.py,sha256=13H2qKQs27EKdTpDLOvcNnSTDAUbYNKjWtJs4aQCSOA,20509
|
@@ -20,8 +20,8 @@ sqlglot/transforms.py,sha256=iTwRPMHTyRx_RG25ItSOnigw_v2tnG9cgwMq0Nwcy2U,39778
|
|
20
20
|
sqlglot/trie.py,sha256=v27uXMrHfqrXlJ6GmeTSMovsB_3o0ctnlKhdNt7W6fI,2245
|
21
21
|
sqlglot/dialects/__init__.py,sha256=aZTLpe2SwgWqiVrRabmfV8TVLPVHFydGwb_zhcVhRss,3499
|
22
22
|
sqlglot/dialects/athena.py,sha256=xjy75ej0T3douCUfFKhE1I3kqvPEuQY29x24WG1--Vw,6307
|
23
|
-
sqlglot/dialects/bigquery.py,sha256=
|
24
|
-
sqlglot/dialects/clickhouse.py,sha256=
|
23
|
+
sqlglot/dialects/bigquery.py,sha256=PIRhlNIj6I5iXPxR2_9q1OWXvy4ovVB_ae5qe8SWV80,52713
|
24
|
+
sqlglot/dialects/clickhouse.py,sha256=0ahX0zjIwN9-RzfNyITBHs9PsgQXjL0uMRlRgYz9crI,56520
|
25
25
|
sqlglot/dialects/databricks.py,sha256=8PoaiP8PfiBjpheRiua-rO_HzX2TRUXqc3DnlQ8zYrg,4481
|
26
26
|
sqlglot/dialects/dialect.py,sha256=uuek7l3vUf8OB987UUxzNqdsZdrSj1TtmImVyxbI7Go,68463
|
27
27
|
sqlglot/dialects/doris.py,sha256=eC7Ct-iz7p4Usz659NkelUFhm-GmVolIZy5uaBvgjaA,14397
|
@@ -33,16 +33,16 @@ sqlglot/dialects/hive.py,sha256=IKAM2elf_n3LgRcPK_4-JuE1j6shd6FhE1QJvBaP55U,3166
|
|
33
33
|
sqlglot/dialects/materialize.py,sha256=_DPLPt8YrdQIIXNrGJw1IMcGOoAEJ9NO9X9pDfy4hxs,3494
|
34
34
|
sqlglot/dialects/mysql.py,sha256=PnhqX2B15J71WUROefPTc7ZOP0vybbkZGWIDrxYN5Dc,48159
|
35
35
|
sqlglot/dialects/oracle.py,sha256=llxu2LzndrsGyceTod-Leh03vuPWEUKzVHB5gQY-tY8,15313
|
36
|
-
sqlglot/dialects/postgres.py,sha256=
|
36
|
+
sqlglot/dialects/postgres.py,sha256=p3sKOp1ImqsQkSz_BWP8pTTMasPFXDJscnMXccXN_5U,30594
|
37
37
|
sqlglot/dialects/presto.py,sha256=ltKbQ44efeq1HM0T8Qq0rsBSx6B6bF9RoKtUBVeoz70,33155
|
38
38
|
sqlglot/dialects/prql.py,sha256=OF2LfDb4uzKIF7kpCfpL5G7VP1pnzLbjfW5QFUnuPvo,7803
|
39
39
|
sqlglot/dialects/redshift.py,sha256=H8H8lGizHIAd4qLoPeFchyiGZKO1I8U_B058woukuGw,15366
|
40
|
-
sqlglot/dialects/risingwave.py,sha256=
|
41
|
-
sqlglot/dialects/snowflake.py,sha256=
|
42
|
-
sqlglot/dialects/spark.py,sha256=
|
40
|
+
sqlglot/dialects/risingwave.py,sha256=hwEOPjMw0ZM_3fjQcBUE00oy6I8V6mzYOOYmcwwS8mw,2898
|
41
|
+
sqlglot/dialects/snowflake.py,sha256=qbrtxaBrpJNIaBth1kkVe6ep5TZktMN3lcWEp1-m0hs,61467
|
42
|
+
sqlglot/dialects/spark.py,sha256=fbmiTKAQiKqG9yE_HAxYGgQiOjdxB9tJyjOtgdqF100,7645
|
43
43
|
sqlglot/dialects/spark2.py,sha256=8er7nHDm5Wc57m9AOxKN0sd_DVzbhAL44H_udlFh9O8,14258
|
44
|
-
sqlglot/dialects/sqlite.py,sha256=
|
45
|
-
sqlglot/dialects/starrocks.py,sha256=
|
44
|
+
sqlglot/dialects/sqlite.py,sha256=ZhVkBzse5yh5pxyYN_daU6CMr4Yint4pIoH3n4gbnns,12394
|
45
|
+
sqlglot/dialects/starrocks.py,sha256=fHNgvq5Nz7dI4QUWCTOO5VDOYjasBxRRlcg9TbY0UZE,11235
|
46
46
|
sqlglot/dialects/tableau.py,sha256=oIawDzUITxGCWaEMB8OaNMPWhbC3U-2y09pYPm4eazc,2190
|
47
47
|
sqlglot/dialects/teradata.py,sha256=xWa-9kSTsT-eM1NePi_oIM1dPHmXW89GLU5Uda3_6Ao,14036
|
48
48
|
sqlglot/dialects/trino.py,sha256=wgLsiX1NQvjGny_rgrU1e2r6kK1LD0KgaSdIDrYmjD0,4285
|
@@ -72,8 +72,8 @@ sqlglot/optimizer/qualify_tables.py,sha256=5f5enBAh-bpNB9ewF97W9fx9h1TGXj1Ih5fnc
|
|
72
72
|
sqlglot/optimizer/scope.py,sha256=Fqz9GpBqO1GWzRAnqdflXXNz44ot_1JqVBC-DnYAU_E,30063
|
73
73
|
sqlglot/optimizer/simplify.py,sha256=S0Blqg5Mq2KRRWhWz-Eivch9sBjBhg9fRJA6EdBzj2g,50704
|
74
74
|
sqlglot/optimizer/unnest_subqueries.py,sha256=kzWUVDlxs8z9nmRx-8U-pHXPtVZhEIwkKqmKhr2QLvc,10908
|
75
|
-
sqlglot-26.
|
76
|
-
sqlglot-26.
|
77
|
-
sqlglot-26.
|
78
|
-
sqlglot-26.
|
79
|
-
sqlglot-26.
|
75
|
+
sqlglot-26.26.0.dist-info/licenses/LICENSE,sha256=AI3__mHZfOtzY3EluR_pIYBm3_pE7TbVx7qaHxoZ114,1065
|
76
|
+
sqlglot-26.26.0.dist-info/METADATA,sha256=7uj_XRkGPWpSUuokcBiin3WhwIBUs8rRcwSyx1zszbY,20732
|
77
|
+
sqlglot-26.26.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
78
|
+
sqlglot-26.26.0.dist-info/top_level.txt,sha256=5kRskCGA_gVADF9rSfSzPdLHXqvfMusDYeHePfNY2nQ,8
|
79
|
+
sqlglot-26.26.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|