tinybird-cli 3.6.1.dev5__py3-none-any.whl → 3.6.1.dev7__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://www.tinybird.co/docs/cli/introduction.html'
5
5
  __author__ = 'Tinybird'
6
6
  __author_email__ = 'support@tinybird.co'
7
- __version__ = '3.6.1.dev5'
8
- __revision__ = '321fe96'
7
+ __version__ = '3.6.1.dev7'
8
+ __revision__ = 'c015232'
@@ -32,7 +32,20 @@ class TableDetails:
32
32
  >>> ed.to_datafile()
33
33
  ''
34
34
 
35
+ >>> ed = TableDetails({ "engine_full": "MergeTree() PARTITION BY toYear(timestamp) ORDER BY (timestamp, cityHash64(location)) SAMPLE BY cityHash64(location) SETTINGS index_granularity = 32, index_granularity_bytes = 2048", "engine": "MergeTree", "partition_key": "toYear(timestamp)", "sorting_key": "timestamp, cityHash64(location)", "primary_key": "timestamp, cityHash64(location)", "sampling_key": "cityHash64(location)", "settings": "index_granularity = 32, index_granularity_bytes = 2048", "ttl": None })
36
+ >>> ed.diff_ttl("toDate(timestamp) + toIntervalDay(1)")
37
+ True
35
38
  >>> ed = TableDetails({ "engine_full": "MergeTree() PARTITION BY toYear(timestamp) ORDER BY (timestamp, cityHash64(location)) SAMPLE BY cityHash64(location) SETTINGS index_granularity = 32, index_granularity_bytes = 2048 TTL toDate(timestamp) + INTERVAL 1 DAY", "engine": "MergeTree", "partition_key": "toYear(timestamp)", "sorting_key": "timestamp, cityHash64(location)", "primary_key": "timestamp, cityHash64(location)", "sampling_key": "cityHash64(location)", "settings": "index_granularity = 32, index_granularity_bytes = 2048", "ttl": "toDate(timestamp) + INTERVAL 1 DAY" })
39
+ >>> ed.diff_ttl("toDate(timestamp) + toIntervalDay(1)")
40
+ False
41
+ >>> ed.diff_ttl("toDate(timestamp) + toIntervalDay(2)")
42
+ True
43
+ >>> ed.diff_ttl("toDate(timestamp) + INTERVAL DAY 2")
44
+ True
45
+ >>> ed.diff_ttl("toDate(timestamp) + INTERVAL 1 DAY")
46
+ False
47
+ >>> ed.diff_ttl("")
48
+ True
36
49
  >>> ed.engine_full
37
50
  'MergeTree() PARTITION BY toYear(timestamp) ORDER BY (timestamp, cityHash64(location)) SAMPLE BY cityHash64(location) SETTINGS index_granularity = 32, index_granularity_bytes = 2048 TTL toDate(timestamp) + INTERVAL 1 DAY'
38
51
  >>> ed.engine
@@ -132,6 +145,16 @@ class TableDetails:
132
145
  return is_aggregating or is_replacing or is_collapsing
133
146
  return False
134
147
 
148
+ def diff_ttl(self, new_ttl: str) -> bool:
149
+ try:
150
+ from tinybird.sql_toolset import format_sql
151
+
152
+ current_ttl = format_sql(f"select {self.ttl}")[7:]
153
+ new_ttl = format_sql(f"select {new_ttl}")[7:]
154
+ return current_ttl != new_ttl
155
+ except Exception:
156
+ return self.ttl != new_ttl
157
+
135
158
  @property
136
159
  def partition_key(self) -> Optional[str]:
137
160
  return self.details.get("partition_key", None)
tinybird/datafile.py CHANGED
@@ -237,6 +237,10 @@ class ParseException(Exception):
237
237
  super().__init__(err)
238
238
 
239
239
 
240
+ class IncludeFileNotFoundException(Exception):
241
+ pass
242
+
243
+
240
244
  class ValidationException(Exception):
241
245
  def __init__(self, err: str, lineno: int = -1) -> None:
242
246
  self.lineno: int = lineno
@@ -411,16 +415,21 @@ class CLIGitRelease:
411
415
  parsed_resources: Dict[str, Datafile] = {}
412
416
 
413
417
  def _is_include(include_path, resource_path):
414
- if filename.endswith(".pipe"):
415
- parsed_func = parse_pipe
416
- else:
417
- parsed_func = parse_datasource
418
- parsed_resource = parsed_resources.get(resource_path, parsed_func(resource_path))
419
- parsed_resources[filename] = parsed_resource
420
- for include in parsed_resource.includes.keys():
421
- if Path(include_path).resolve().name in include.strip('"').strip("'"):
422
- return True
423
- return False
418
+ try:
419
+ if filename.endswith(".pipe"):
420
+ parsed_func = parse_pipe
421
+ else:
422
+ parsed_func = parse_datasource
423
+ parsed_resource = parsed_resources.get(resource_path, parsed_func(resource_path))
424
+ parsed_resources[filename] = parsed_resource
425
+ for include in parsed_resource.includes.keys():
426
+ if Path(include_path).resolve().name in include.strip('"').strip("'"):
427
+ return True
428
+ return False
429
+ except IncludeFileNotFoundException as e:
430
+ raise click.ClickException(
431
+ FeedbackManager.error_deleted_include(include_file=str(e), filename=filename)
432
+ )
424
433
 
425
434
  for diff in diffs:
426
435
  changes_in_includes = False
@@ -663,7 +672,9 @@ class Deployment:
663
672
  for dep in node["dependencies"]:
664
673
  if dep in [pipe["name"] for pipe in remote_pipes]:
665
674
  pipes_deps.setdefault(dep, []).append(pipe["name"])
666
- deleted_resources: Dict[str, str] = {Path(resource).resolve().stem: resource for resource in deleted}
675
+ deleted_resources: Dict[str, str] = {
676
+ Path(resource).resolve().stem: resource for resource in deleted if ".incl" not in resource
677
+ }
667
678
 
668
679
  for group in toposort(pipes_deps):
669
680
  # for each level keep materialized for the end
@@ -976,19 +987,22 @@ def parse(
976
987
  # be sure to replace the include line
977
988
  p = Path(basepath)
978
989
 
979
- with open(p / f) as file:
980
- try:
981
- ll = list(StringIO(file.read(), newline=None))
982
- node_line = [line for line in ll if "NODE" in line]
983
- if node_line and doc.includes[args_with_attrs]:
984
- doc.includes[node_line[0].split("NODE")[-1].split("\n")[0].strip()] = ""
985
- except Exception:
986
- pass
987
- finally:
988
- file.seek(0)
989
- lines[lineno : lineno + 1] = [""] + list(
990
- StringIO(Template(file.read()).safe_substitute(attrs), newline=None)
991
- )
990
+ try:
991
+ with open(p / f) as file:
992
+ try:
993
+ ll = list(StringIO(file.read(), newline=None))
994
+ node_line = [line for line in ll if "NODE" in line]
995
+ if node_line and doc.includes[args_with_attrs]:
996
+ doc.includes[node_line[0].split("NODE")[-1].split("\n")[0].strip()] = ""
997
+ except Exception:
998
+ pass
999
+ finally:
1000
+ file.seek(0)
1001
+ lines[lineno : lineno + 1] = [""] + list(
1002
+ StringIO(Template(file.read()).safe_substitute(attrs), newline=None)
1003
+ )
1004
+ except FileNotFoundError:
1005
+ raise IncludeFileNotFoundException(f)
992
1006
 
993
1007
  def version(*args: str, **kwargs: Any) -> None:
994
1008
  if len(args) < 1:
@@ -1152,6 +1166,8 @@ def parse(
1152
1166
  raise click.ClickException(FeedbackManager.error_missing_datasource_name())
1153
1167
  else:
1154
1168
  raise ValidationException(f"Validation error, found {line} in line {str(lineno)}: {str(e)}", lineno=lineno)
1169
+ except IncludeFileNotFoundException as e:
1170
+ raise e
1155
1171
  except Exception as e:
1156
1172
  traceback.print_tb(e.__traceback__)
1157
1173
  raise ParseException(f"Unexpected error: {e}", lineno=lineno)
@@ -3628,6 +3644,8 @@ async def build_graph(
3628
3644
  )
3629
3645
  except click.ClickException as e:
3630
3646
  raise e
3647
+ except IncludeFileNotFoundException as e:
3648
+ raise click.ClickException(FeedbackManager.error_deleted_include(include_file=str(e), filename=filename))
3631
3649
  except Exception as e:
3632
3650
  raise click.ClickException(str(e))
3633
3651
 
@@ -206,6 +206,9 @@ class FeedbackManager:
206
206
  error_connection_create = error_message("Connection {connection_name} could not be created: {error}")
207
207
  error_connection_integration_not_available = error_message("Connection could not be created: {error}")
208
208
  error_workspace = error_message("Workspace {workspace} not found. use 'tb workspace ls' to list your workspaces")
209
+ error_deleted_include = error_message(
210
+ "Related include file {include_file} was deleted and it's used in {filename}. Delete or remove dependency from {filename}."
211
+ )
209
212
  error_branch = error_message(
210
213
  "Branch {branch} not found. use 'tb branch ls' to list your Branches, make sure you are authenticated using the right workspace token"
211
214
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tinybird-cli
3
- Version: 3.6.1.dev5
3
+ Version: 3.6.1.dev7
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/cli/introduction.html
6
6
  Author: Tinybird
@@ -52,6 +52,16 @@ Changelog
52
52
 
53
53
  ---------
54
54
 
55
+ 3.6.1.dev7
56
+ ************
57
+
58
+ - `Fixed` `tb deploy` supports deployment when a `.incl` file is removed
59
+
60
+ 3.6.1.dev6
61
+ ************
62
+
63
+ - `Fixed` Some issues when using `--fmt: off` with `CASE` in the sql
64
+
55
65
  3.6.1.dev5
56
66
  ************
57
67
 
@@ -1,13 +1,13 @@
1
- tinybird/__cli__.py,sha256=9b226fjwx6IUFDoehvMthpbbpOiAS-OJceoZ5qknImY,254
1
+ tinybird/__cli__.py,sha256=CR5Z-Th3G0oO7rKALtC5QWrdWpqifscvz0inDmvyO4k,254
2
2
  tinybird/check_pypi.py,sha256=_4NkharLyR_ELrAdit-ftqIWvOf7jZNPt3i76frlo9g,975
3
3
  tinybird/client.py,sha256=HbTicwXGErvAMCFj7o9X7aGKxI0WuuTKOr6tf-0jYOA,46575
4
4
  tinybird/config.py,sha256=E0jDwbFD1zhdijNhtF8fg6mqIyKbZ8xpNPP_3n2PFpE,2003
5
5
  tinybird/connector_settings.py,sha256=js2LvL8bAv5PegDICWB6EQ-LhqhAQU9VPApU1dW0vyA,6258
6
6
  tinybird/connectors.py,sha256=lkpVSUmSuViEZBa4QjTK7YmPHUop0a5UFoTrSmlVq6k,15244
7
7
  tinybird/context.py,sha256=BlMsbeg5jTjTtJmcyJBCpjQE74sYk_CLBeHorSUer1M,913
8
- tinybird/datafile.py,sha256=AT8umvbMwPSzfifMfsCj0jk8-Od-5PZbX6XHqr97mEw,211020
8
+ tinybird/datafile.py,sha256=I6ILGNHDOiBrg2QbE93deUYGMBxxLOSrrS30X8ntunE,211777
9
9
  tinybird/datatypes.py,sha256=adYOQBTyfeBGVINIlaRex_81gTQQuqF2M9VTQpzq1H0,7060
10
- tinybird/feedback_manager.py,sha256=p8unybrnH8L6uK-k5UZ0nvzrSfzwDMeIKSGIzRy0_nU,58756
10
+ tinybird/feedback_manager.py,sha256=uia44mEbC-2iDOTOXEET0W0_IPY2PltS-kEDtrENnj0,58937
11
11
  tinybird/git_settings.py,sha256=vu8sWb3TAXeM8Tqy27aR0el8MnPm7kqQzTRV76xB0ro,4707
12
12
  tinybird/sql.py,sha256=ln_rs8goRV-yP7BdiA3MewzFKgIHQdRalhtiUrwTBV4,41181
13
13
  tinybird/sql_template.py,sha256=-q64irnoIqKhYgtCmsgjPV62vluM6aFxKgkgtRcL1n8,76994
@@ -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=yA9r0wPS5_Na48HZEGtwES14xX3UcKtm581ZXw-nsOc,41982
19
19
  tinybird/ch_utils/constants.py,sha256=QtaTrpYsmxnlogsC57YEnkrbw22t9hx6ueCvl6qD9f4,3657
20
- tinybird/ch_utils/engine.py,sha256=RXuiseVt43BROW2nn3nWYEeQbkzz_8IKVPSFrPWpScw,38465
20
+ tinybird/ch_utils/engine.py,sha256=KVxZdmNkUCYXaw74aZgpUd7n1E5AhLynsGnLx8pi7UM,39699
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=3HzY43218fb35ZM81mtkwDQe7gAAf1zEFY6kIEhGvgE,8268
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.6.1.dev5.dist-info/METADATA,sha256=4tC2eTcips1VHScwJvriZ6HzHCQwvhT7JDIBw5iEXbQ,69168
42
- tinybird_cli-3.6.1.dev5.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
43
- tinybird_cli-3.6.1.dev5.dist-info/entry_points.txt,sha256=PKPKuPmA4IfJYnCFHHUiw-aAWZuBomFvwCklv1OyCjE,43
44
- tinybird_cli-3.6.1.dev5.dist-info/top_level.txt,sha256=pgw6AzERHBcW3YTi2PW4arjxLkulk2msOz_SomfOEuc,45
45
- tinybird_cli-3.6.1.dev5.dist-info/RECORD,,
41
+ tinybird_cli-3.6.1.dev7.dist-info/METADATA,sha256=wORHK2U5g1BqPmqlv2xV0NtN1YpsGEvKScOAClmIulY,69362
42
+ tinybird_cli-3.6.1.dev7.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
43
+ tinybird_cli-3.6.1.dev7.dist-info/entry_points.txt,sha256=PKPKuPmA4IfJYnCFHHUiw-aAWZuBomFvwCklv1OyCjE,43
44
+ tinybird_cli-3.6.1.dev7.dist-info/top_level.txt,sha256=pgw6AzERHBcW3YTi2PW4arjxLkulk2msOz_SomfOEuc,45
45
+ tinybird_cli-3.6.1.dev7.dist-info/RECORD,,