ydb-sqlglot-plugin 0.2.6__tar.gz → 0.2.7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ydb-sqlglot-plugin
3
- Version: 0.2.6
3
+ Version: 0.2.7
4
4
  Summary: YDB dialect plugin for sqlglot
5
5
  Author: YDB Team
6
6
  License: Apache-2.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ydb-sqlglot-plugin"
7
- version = "0.2.6" # AUTOVERSION
7
+ version = "0.2.7" # AUTOVERSION
8
8
  description = "YDB dialect plugin for sqlglot"
9
9
  readme = "README.md"
10
10
  license = {text = "Apache-2.0"}
@@ -0,0 +1 @@
1
+ VERSION = "0.2.7"
@@ -1532,31 +1532,6 @@ class YDB(Dialect):
1532
1532
  return None
1533
1533
  return super()._parse_table_alias(alias_tokens=alias_tokens)
1534
1534
 
1535
- def _normalize_ydb_table_path(self, table: exp.Expression) -> exp.Expression:
1536
- if not isinstance(table, exp.Table):
1537
- return table
1538
-
1539
- identifier = table.this
1540
- if not isinstance(identifier, exp.Identifier) or table.catalog:
1541
- return table
1542
-
1543
- path = identifier.this
1544
- if "/" not in path:
1545
- if table.db:
1546
- table.set("catalog", table.args.get("db"))
1547
- table.set("db", None)
1548
- return table
1549
-
1550
- schema, name = path.rsplit("/", 1)
1551
- if not schema or not name:
1552
- return table
1553
-
1554
- if table.db:
1555
- table.set("catalog", table.args.get("db"))
1556
- table.set("db", exp.to_identifier(schema, quoted=True))
1557
- table.set("this", exp.to_identifier(name, quoted=True))
1558
- return table
1559
-
1560
1535
  def _parse_table_hints(self) -> t.Optional[t.List[exp.Expression]]:
1561
1536
  if not (self._curr and self._curr.token_type == TokenType.WITH):
1562
1537
  return super()._parse_table_hints()
@@ -1870,9 +1845,9 @@ class YDB(Dialect):
1870
1845
  parts.append(self._curr.text)
1871
1846
  self._advance()
1872
1847
  self._match(TokenType.R_BRACKET)
1873
- table = self.expression(exp.Table(this=exp.to_identifier("".join(parts), quoted=True)))
1848
+ table = self.expression(exp.Table(this=exp.to_identifier("".join(parts))))
1874
1849
  table.set("alias", self._parse_table_alias())
1875
- return self._normalize_ydb_table_path(table)
1850
+ return table
1876
1851
 
1877
1852
  table = super()._parse_table(*args, **kwargs)
1878
1853
  if (
@@ -1886,8 +1861,6 @@ class YDB(Dialect):
1886
1861
  param = self._parse_parameter()
1887
1862
  table = self.expression(exp.Table(this=param))
1888
1863
  table.set("alias", self._parse_table_alias())
1889
- if table:
1890
- table = self._normalize_ydb_table_path(table)
1891
1864
  if table and self._match(TokenType.VIEW):
1892
1865
  table.set("ydb_index_view", self._parse_id_var(any_token=True))
1893
1866
  explicit_alias = bool(self._curr and self._curr.token_type == TokenType.ALIAS)
@@ -2439,12 +2412,8 @@ class YDB(Dialect):
2439
2412
  if expression.alias:
2440
2413
  sql += f" AS {expression.alias}"
2441
2414
  return _with_table_joins(sql)
2442
- path = f"{expression.db}/{expression.name}" if expression.db else expression.name
2443
- if expression.catalog:
2444
- table_identifier = f"`{path}`" if expression.db else self.sql(expression, "this")
2445
- sql = f"{expression.catalog}.{table_identifier}"
2446
- else:
2447
- sql = f"`{path}`"
2415
+ prefix = f"{expression.db}/" if expression.db else ""
2416
+ sql = f"`{prefix}{expression.name}`"
2448
2417
 
2449
2418
  ydb_index_view = self.sql(expression, "ydb_index_view")
2450
2419
  if ydb_index_view:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ydb-sqlglot-plugin
3
- Version: 0.2.6
3
+ Version: 0.2.7
4
4
  Summary: YDB dialect plugin for sqlglot
5
5
  Author: YDB Team
6
6
  License: Apache-2.0
@@ -1 +0,0 @@
1
- VERSION = "0.2.6"