tinybird-cli 3.3.1.dev13__py3-none-any.whl → 3.3.1.dev14__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.
tinybird/__cli__.py CHANGED
@@ -4,5 +4,5 @@ __description__ = 'Tinybird Command Line Tool'
4
4
  __url__ = 'https://docs.tinybird.co/cli.html'
5
5
  __author__ = 'Tinybird'
6
6
  __author_email__ = 'support@tinybird.co'
7
- __version__ = '3.3.1.dev13'
8
- __revision__ = 'ab05577'
7
+ __version__ = '3.3.1.dev14'
8
+ __revision__ = '5fde94c'
@@ -1,9 +1,10 @@
1
1
  import logging
2
2
  import re
3
3
  from collections import defaultdict
4
+ from dataclasses import asdict
4
5
  from typing import Any, Callable, Dict, Iterable, List, Optional
5
6
 
6
- from ..sql import col_name, engine_replicated_to_local, parse_table_structure
7
+ from ..sql import TableIndex, col_name, engine_replicated_to_local, parse_indices_structure, parse_table_structure
7
8
 
8
9
  DEFAULT_EMPTY_PARAMETERS = ["ttl", "partition_key", "sorting_key"]
9
10
  DEFAULT_JOIN_EMPTY_PARAMETERS = ["join_strictness", "join_type", "key_columns"]
@@ -204,6 +205,10 @@ class TableDetails:
204
205
  "row_count": self.details.get("total_rows", None),
205
206
  }
206
207
 
208
+ @property
209
+ def indices(self) -> List[TableIndex]:
210
+ return _parse_indices(str(self.details.get("create_table_query", "")))
211
+
207
212
  def to_json(self, exclude: Optional[List[str]] = None, include_empty_details: bool = False):
208
213
  # name, database are not exported since they are not part of the engine
209
214
  d: Dict[str, Any] = {
@@ -234,6 +239,8 @@ class TableDetails:
234
239
  d["version"] = self.version
235
240
  if self.ttl:
236
241
  d["ttl"] = self.ttl.strip()
242
+ if self.indices:
243
+ d["indices"] = [asdict(index) for index in self.indices]
237
244
 
238
245
  if self.engine_full:
239
246
  engine_params = engine_params_from_engine_full(self.engine_full)
@@ -253,7 +260,9 @@ class TableDetails:
253
260
  return d
254
261
 
255
262
  def to_datafile(self, include_empty_details: bool = False) -> str:
256
- d: Dict[str, Any] = self.to_json(exclude=["engine", "engine_full"], include_empty_details=include_empty_details)
263
+ d: Dict[str, Any] = self.to_json(
264
+ exclude=["engine", "engine_full", "indices"], include_empty_details=include_empty_details
265
+ )
257
266
  engine: str = self.engine
258
267
 
259
268
  datafile: str = ""
@@ -774,3 +783,21 @@ def ttl_condition_from_engine_full(engine_full: Optional[str]) -> Optional[str]:
774
783
  except Exception as e:
775
784
  logging.error(str(e))
776
785
  return None
786
+
787
+
788
+ def _parse_indices(create_table_query_expr: str) -> List[TableIndex]:
789
+ if create_table_query_expr == "":
790
+ return []
791
+ try:
792
+ from tinybird.sql_toolset import format_sql
793
+
794
+ indices = [
795
+ line.strip()
796
+ for line in format_sql(create_table_query_expr).splitlines()
797
+ if line.strip().startswith("INDEX")
798
+ ]
799
+ except ModuleNotFoundError:
800
+ # this is not needed from CLI
801
+ return []
802
+
803
+ return parse_indices_structure(indices)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tinybird-cli
3
- Version: 3.3.1.dev13
3
+ Version: 3.3.1.dev14
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://docs.tinybird.co/cli.html
6
6
  Author: Tinybird
@@ -52,6 +52,11 @@ Changelog
52
52
 
53
53
  ---------
54
54
 
55
+ 3.3.1.dev14
56
+ ************
57
+
58
+ - `Added` Support `tb deploy` .datasource with `INDICES`
59
+
55
60
  3.3.1.dev13
56
61
  ************
57
62
 
@@ -1,4 +1,4 @@
1
- tinybird/__cli__.py,sha256=HPy6Lum99jotL_al6SnGh__dN6NWBzQwmgddWTIsG-A,238
1
+ tinybird/__cli__.py,sha256=MRI1KpxSe_rofDh_2zh_cT5MtvWxbS-pKdAMOAjMUSE,238
2
2
  tinybird/check_pypi.py,sha256=_4NkharLyR_ELrAdit-ftqIWvOf7jZNPt3i76frlo9g,975
3
3
  tinybird/client.py,sha256=iLQHu8tVUZ25U3DeWTxO2vAhsy-pko1XDX2r0xNoays,46468
4
4
  tinybird/config.py,sha256=E0jDwbFD1zhdijNhtF8fg6mqIyKbZ8xpNPP_3n2PFpE,2003
@@ -17,7 +17,7 @@ tinybird/syncasync.py,sha256=fAvq0qkRgqXqXMKwbY2iJNYqLT_r6mDsh1MRpGKrdRU,27763
17
17
  tinybird/tb_cli.py,sha256=XPyQ8QQ85ohpfVv7ZGzZjIbeijFZEzWQDwCz5zVpZ_U,674
18
18
  tinybird/tornado_template.py,sha256=0CMUKHZXMfe86mKgEWSuQdYG1ptRfJCg8TGnUjhOJlc,41970
19
19
  tinybird/ch_utils/constants.py,sha256=QtaTrpYsmxnlogsC57YEnkrbw22t9hx6ueCvl6qD9f4,3657
20
- tinybird/ch_utils/engine.py,sha256=LzQxPraFN7tTl6YP-xwd3Z2o3BjjD4VNqWDrreC4koI,37634
20
+ tinybird/ch_utils/engine.py,sha256=GDICiBGV1jup9Mmt_xRfg_HiWZnrrQplF8UmbDK8VVY,38465
21
21
  tinybird/data_connectors/credentials.py,sha256=c52x4f6PTORcnoDJAtYC186GYBbTzdbEY3bi79OrCaU,638
22
22
  tinybird/tb_cli_modules/auth.py,sha256=joR1uS821o2bPTpgDyMCYed9Kw7MutR0aa-YvmIb4zA,8561
23
23
  tinybird/tb_cli_modules/branch.py,sha256=5d0lDMxUOt68BK5rmcVCxPYshdUfs42oz_sxIn9NSsk,37863
@@ -38,8 +38,8 @@ tinybird/tb_cli_modules/workspace.py,sha256=NDHINzW3SBo8FcWH8Bx-DCeUXQ8YUJX6FW8c
38
38
  tinybird/tb_cli_modules/workspace_members.py,sha256=6oZM7oJQPxDMycL95TPtALriL5WRI2DhNlQWD8MP8JU,8205
39
39
  tinybird/tb_cli_modules/tinyunit/tinyunit.py,sha256=0dYYmZMMJVubxSPls2e_a-fqtUYvgLfu2B0xwLfkbHw,11667
40
40
  tinybird/tb_cli_modules/tinyunit/tinyunit_lib.py,sha256=j92za8QbXrv4eIPjKBZPn9ghR-nYQ2wZZ88MeXyMWXE,1868
41
- tinybird_cli-3.3.1.dev13.dist-info/METADATA,sha256=mpL7HYt4qvCafLNz9zP3W3Q28zZFneaIO5g0Yf5FRQ8,67751
42
- tinybird_cli-3.3.1.dev13.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
43
- tinybird_cli-3.3.1.dev13.dist-info/entry_points.txt,sha256=PKPKuPmA4IfJYnCFHHUiw-aAWZuBomFvwCklv1OyCjE,43
44
- tinybird_cli-3.3.1.dev13.dist-info/top_level.txt,sha256=8TRt5snq9vZpx4rBBc9EWpj76Er6IAdfnx_Eq6cNBk8,45
45
- tinybird_cli-3.3.1.dev13.dist-info/RECORD,,
41
+ tinybird_cli-3.3.1.dev14.dist-info/METADATA,sha256=e6QOrUL72DNu23afm8nJOwAuIuy3VklNzuN49C8hgYU,67835
42
+ tinybird_cli-3.3.1.dev14.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
43
+ tinybird_cli-3.3.1.dev14.dist-info/entry_points.txt,sha256=PKPKuPmA4IfJYnCFHHUiw-aAWZuBomFvwCklv1OyCjE,43
44
+ tinybird_cli-3.3.1.dev14.dist-info/top_level.txt,sha256=8TRt5snq9vZpx4rBBc9EWpj76Er6IAdfnx_Eq6cNBk8,45
45
+ tinybird_cli-3.3.1.dev14.dist-info/RECORD,,