ydb-sqlglot-plugin 0.2.0__tar.gz → 0.2.1__tar.gz
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.
- {ydb_sqlglot_plugin-0.2.0 → ydb_sqlglot_plugin-0.2.1}/PKG-INFO +1 -1
- {ydb_sqlglot_plugin-0.2.0 → ydb_sqlglot_plugin-0.2.1}/pyproject.toml +1 -1
- ydb_sqlglot_plugin-0.2.1/ydb_sqlglot/version.py +1 -0
- {ydb_sqlglot_plugin-0.2.0 → ydb_sqlglot_plugin-0.2.1}/ydb_sqlglot/ydb.py +14 -47
- {ydb_sqlglot_plugin-0.2.0 → ydb_sqlglot_plugin-0.2.1}/ydb_sqlglot_plugin.egg-info/PKG-INFO +1 -1
- ydb_sqlglot_plugin-0.2.0/ydb_sqlglot/version.py +0 -1
- {ydb_sqlglot_plugin-0.2.0 → ydb_sqlglot_plugin-0.2.1}/LICENSE +0 -0
- {ydb_sqlglot_plugin-0.2.0 → ydb_sqlglot_plugin-0.2.1}/README.md +0 -0
- {ydb_sqlglot_plugin-0.2.0 → ydb_sqlglot_plugin-0.2.1}/setup.cfg +0 -0
- {ydb_sqlglot_plugin-0.2.0 → ydb_sqlglot_plugin-0.2.1}/ydb_sqlglot/__init__.py +0 -0
- {ydb_sqlglot_plugin-0.2.0 → ydb_sqlglot_plugin-0.2.1}/ydb_sqlglot_plugin.egg-info/SOURCES.txt +0 -0
- {ydb_sqlglot_plugin-0.2.0 → ydb_sqlglot_plugin-0.2.1}/ydb_sqlglot_plugin.egg-info/dependency_links.txt +0 -0
- {ydb_sqlglot_plugin-0.2.0 → ydb_sqlglot_plugin-0.2.1}/ydb_sqlglot_plugin.egg-info/entry_points.txt +0 -0
- {ydb_sqlglot_plugin-0.2.0 → ydb_sqlglot_plugin-0.2.1}/ydb_sqlglot_plugin.egg-info/requires.txt +0 -0
- {ydb_sqlglot_plugin-0.2.0 → ydb_sqlglot_plugin-0.2.1}/ydb_sqlglot_plugin.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = "0.2.1"
|
|
@@ -403,26 +403,6 @@ def _apply_subquery_alias_columns(expression: exp.Expression) -> None:
|
|
|
403
403
|
alias.set("columns", [])
|
|
404
404
|
|
|
405
405
|
|
|
406
|
-
def _has_implicit_cross_join(expression: exp.Expression) -> bool:
|
|
407
|
-
"""Return True if the expression tree contains an implicit cross join.
|
|
408
|
-
|
|
409
|
-
An implicit cross join arises from comma-separated FROM tables, e.g.
|
|
410
|
-
``FROM t1, t2``. In the sqlglot AST this appears as a ``Join`` node
|
|
411
|
-
with no ``kind``, no ``on`` clause, and no ``using`` clause.
|
|
412
|
-
YDB disables implicit cross joins by default; callers can prepend
|
|
413
|
-
``PRAGMA AnsiImplicitCrossJoin;`` when this returns True.
|
|
414
|
-
"""
|
|
415
|
-
for node in expression.walk():
|
|
416
|
-
if isinstance(node, exp.Join):
|
|
417
|
-
if (
|
|
418
|
-
not node.args.get("kind")
|
|
419
|
-
and not node.args.get("on")
|
|
420
|
-
and not node.args.get("using")
|
|
421
|
-
):
|
|
422
|
-
return True
|
|
423
|
-
return False
|
|
424
|
-
|
|
425
|
-
|
|
426
406
|
class FlattenBy(exp.Expression):
|
|
427
407
|
"""YDB-specific FLATTEN [LIST|DICT] BY clause on a table reference."""
|
|
428
408
|
arg_types = {"this": True, "expressions": True, "kind": False}
|
|
@@ -1384,12 +1364,6 @@ class YDB(Dialect):
|
|
|
1384
1364
|
else:
|
|
1385
1365
|
sql = self._generate_create_table(expression)
|
|
1386
1366
|
|
|
1387
|
-
# Prepend PRAGMA AnsiImplicitCrossJoin only when the query contains
|
|
1388
|
-
# implicit cross joins (FROM t1, t2 syntax). YDB disables them by
|
|
1389
|
-
# default; the pragma restores standard SQL semantics.
|
|
1390
|
-
if _has_implicit_cross_join(expression):
|
|
1391
|
-
sql = "PRAGMA AnsiImplicitCrossJoin;\n" + sql
|
|
1392
|
-
|
|
1393
1367
|
return sql
|
|
1394
1368
|
|
|
1395
1369
|
def unnest_subqueries(self, expression):
|
|
@@ -2180,15 +2154,15 @@ class YDB(Dialect):
|
|
|
2180
2154
|
# we move the WHERE expression from ON, using literals
|
|
2181
2155
|
def join_sql(self, expression: exp.Join) -> str:
|
|
2182
2156
|
on_condition = expression.args.get("on")
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
#
|
|
2186
|
-
# YDB requires
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
expression.set("kind",
|
|
2191
|
-
expression.set("
|
|
2157
|
+
using = expression.args.get("using")
|
|
2158
|
+
|
|
2159
|
+
# Any join with no ON/USING clause becomes an explicit CROSS JOIN.
|
|
2160
|
+
# YDB requires an ON clause for outer joins, and emitting CROSS JOIN
|
|
2161
|
+
# explicitly (instead of the comma-separated form) keeps the output
|
|
2162
|
+
# valid without any extra pragma.
|
|
2163
|
+
if not on_condition and not using:
|
|
2164
|
+
expression.set("kind", "CROSS")
|
|
2165
|
+
expression.set("side", None)
|
|
2192
2166
|
return super().join_sql(expression)
|
|
2193
2167
|
|
|
2194
2168
|
if on_condition:
|
|
@@ -2256,18 +2230,11 @@ class YDB(Dialect):
|
|
|
2256
2230
|
on_condition = exp.and_(on_condition, cond)
|
|
2257
2231
|
expression.set("on", on_condition)
|
|
2258
2232
|
else:
|
|
2259
|
-
# No valid equality conditions
|
|
2260
|
-
#
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
):
|
|
2265
|
-
# Convert to CROSS JOIN by removing kind and ON
|
|
2266
|
-
expression.set("kind", None)
|
|
2267
|
-
expression.set("on", None)
|
|
2268
|
-
expression.set("side", "CROSS")
|
|
2269
|
-
else:
|
|
2270
|
-
expression.set("on", None)
|
|
2233
|
+
# No valid equality conditions remain on the JOIN — fall back
|
|
2234
|
+
# to an explicit CROSS JOIN regardless of the original kind.
|
|
2235
|
+
expression.set("kind", "CROSS")
|
|
2236
|
+
expression.set("on", None)
|
|
2237
|
+
expression.set("side", None)
|
|
2271
2238
|
|
|
2272
2239
|
if conditions_to_move:
|
|
2273
2240
|
select_stmt = expression.find_ancestor(exp.Select)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
VERSION = "0.2.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ydb_sqlglot_plugin-0.2.0 → ydb_sqlglot_plugin-0.2.1}/ydb_sqlglot_plugin.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{ydb_sqlglot_plugin-0.2.0 → ydb_sqlglot_plugin-0.2.1}/ydb_sqlglot_plugin.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{ydb_sqlglot_plugin-0.2.0 → ydb_sqlglot_plugin-0.2.1}/ydb_sqlglot_plugin.egg-info/requires.txt
RENAMED
|
File without changes
|
{ydb_sqlglot_plugin-0.2.0 → ydb_sqlglot_plugin-0.2.1}/ydb_sqlglot_plugin.egg-info/top_level.txt
RENAMED
|
File without changes
|