ydb-sqlglot-plugin 0.2.1__tar.gz → 0.2.2__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.1 → ydb_sqlglot_plugin-0.2.2}/PKG-INFO +1 -1
- {ydb_sqlglot_plugin-0.2.1 → ydb_sqlglot_plugin-0.2.2}/pyproject.toml +1 -1
- ydb_sqlglot_plugin-0.2.2/ydb_sqlglot/version.py +1 -0
- {ydb_sqlglot_plugin-0.2.1 → ydb_sqlglot_plugin-0.2.2}/ydb_sqlglot/ydb.py +43 -1
- {ydb_sqlglot_plugin-0.2.1 → ydb_sqlglot_plugin-0.2.2}/ydb_sqlglot_plugin.egg-info/PKG-INFO +1 -1
- ydb_sqlglot_plugin-0.2.1/ydb_sqlglot/version.py +0 -1
- {ydb_sqlglot_plugin-0.2.1 → ydb_sqlglot_plugin-0.2.2}/LICENSE +0 -0
- {ydb_sqlglot_plugin-0.2.1 → ydb_sqlglot_plugin-0.2.2}/README.md +0 -0
- {ydb_sqlglot_plugin-0.2.1 → ydb_sqlglot_plugin-0.2.2}/setup.cfg +0 -0
- {ydb_sqlglot_plugin-0.2.1 → ydb_sqlglot_plugin-0.2.2}/ydb_sqlglot/__init__.py +0 -0
- {ydb_sqlglot_plugin-0.2.1 → ydb_sqlglot_plugin-0.2.2}/ydb_sqlglot_plugin.egg-info/SOURCES.txt +0 -0
- {ydb_sqlglot_plugin-0.2.1 → ydb_sqlglot_plugin-0.2.2}/ydb_sqlglot_plugin.egg-info/dependency_links.txt +0 -0
- {ydb_sqlglot_plugin-0.2.1 → ydb_sqlglot_plugin-0.2.2}/ydb_sqlglot_plugin.egg-info/entry_points.txt +0 -0
- {ydb_sqlglot_plugin-0.2.1 → ydb_sqlglot_plugin-0.2.2}/ydb_sqlglot_plugin.egg-info/requires.txt +0 -0
- {ydb_sqlglot_plugin-0.2.1 → ydb_sqlglot_plugin-0.2.2}/ydb_sqlglot_plugin.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = "0.2.2"
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import inspect as _inspect
|
|
1
2
|
import re
|
|
2
3
|
import typing as t
|
|
3
4
|
|
|
@@ -426,6 +427,13 @@ _YDB_GENERIC_TYPES = {
|
|
|
426
427
|
}
|
|
427
428
|
|
|
428
429
|
|
|
430
|
+
# sqlglot >= 30.0.0 changed Parser.expression() to take a pre-built instance instead of
|
|
431
|
+
# (cls, **kwargs). Detect once so the YDB parser override below can support both APIs.
|
|
432
|
+
_EXPRESSION_TAKES_INSTANCE = (
|
|
433
|
+
"instance" in _inspect.signature(parser.Parser.expression).parameters
|
|
434
|
+
)
|
|
435
|
+
|
|
436
|
+
|
|
429
437
|
def _reassemble_ctes(
|
|
430
438
|
statements: t.List[t.Optional[exp.Expression]],
|
|
431
439
|
) -> t.List[t.Optional[exp.Expression]]:
|
|
@@ -582,6 +590,38 @@ class YDB(Dialect):
|
|
|
582
590
|
statements = super().parse(raw_tokens, sql)
|
|
583
591
|
return _reassemble_ctes(statements)
|
|
584
592
|
|
|
593
|
+
def expression(self, exp_class_or_instance, token=None, comments=None, **kwargs):
|
|
594
|
+
"""Bridge sqlglot's two `Parser.expression()` calling conventions.
|
|
595
|
+
|
|
596
|
+
sqlglot < 30 expects ``expression(cls, **kwargs)`` and instantiates internally.
|
|
597
|
+
sqlglot >= 30 expects a pre-built ``expression(instance)`` and rejects kwargs.
|
|
598
|
+
Several call sites in this dialect (and a few in upstream code paths we exercise)
|
|
599
|
+
mix both styles, so normalise here before delegating.
|
|
600
|
+
"""
|
|
601
|
+
if _EXPRESSION_TAKES_INSTANCE:
|
|
602
|
+
if not isinstance(exp_class_or_instance, exp.Expression):
|
|
603
|
+
exp_class_or_instance = exp_class_or_instance(**kwargs)
|
|
604
|
+
return super().expression(
|
|
605
|
+
exp_class_or_instance, token=token, comments=comments
|
|
606
|
+
)
|
|
607
|
+
|
|
608
|
+
if isinstance(exp_class_or_instance, exp.Expression):
|
|
609
|
+
# Old super() would attempt instance(**kwargs) -> "object is not callable".
|
|
610
|
+
instance = exp_class_or_instance
|
|
611
|
+
if token is not None:
|
|
612
|
+
update_positions = getattr(instance, "update_positions", None)
|
|
613
|
+
if update_positions is not None:
|
|
614
|
+
update_positions(token)
|
|
615
|
+
if comments:
|
|
616
|
+
instance.add_comments(comments)
|
|
617
|
+
else:
|
|
618
|
+
self._add_comments(instance)
|
|
619
|
+
return self.validate_expression(instance)
|
|
620
|
+
|
|
621
|
+
return super().expression(
|
|
622
|
+
exp_class_or_instance, token=token, comments=comments, **kwargs
|
|
623
|
+
)
|
|
624
|
+
|
|
585
625
|
def _parse_dcolon(self) -> t.Optional[exp.Expression]:
|
|
586
626
|
return self._parse_function(anonymous=True) or self._parse_var(any_token=True)
|
|
587
627
|
|
|
@@ -759,7 +799,9 @@ class YDB(Dialect):
|
|
|
759
799
|
|
|
760
800
|
def _parse_lambda_body(self, params):
|
|
761
801
|
if (
|
|
762
|
-
self._curr
|
|
802
|
+
self._curr is None
|
|
803
|
+
or self._curr.token_type != TokenType.R_PAREN
|
|
804
|
+
or self._next is None
|
|
763
805
|
or self._next.token_type != TokenType.ARROW
|
|
764
806
|
):
|
|
765
807
|
return None
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
VERSION = "0.2.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ydb_sqlglot_plugin-0.2.1 → ydb_sqlglot_plugin-0.2.2}/ydb_sqlglot_plugin.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{ydb_sqlglot_plugin-0.2.1 → ydb_sqlglot_plugin-0.2.2}/ydb_sqlglot_plugin.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{ydb_sqlglot_plugin-0.2.1 → ydb_sqlglot_plugin-0.2.2}/ydb_sqlglot_plugin.egg-info/requires.txt
RENAMED
|
File without changes
|
{ydb_sqlglot_plugin-0.2.1 → ydb_sqlglot_plugin-0.2.2}/ydb_sqlglot_plugin.egg-info/top_level.txt
RENAMED
|
File without changes
|