tinybird-cli 5.1.1.dev3__py3-none-any.whl → 5.2.1.dev0__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__ = '5.1.1.dev3'
8
- __revision__ = '7908f0f'
7
+ __version__ = '5.2.1.dev0'
8
+ __revision__ = '83349b1'
tinybird/datatypes.py CHANGED
@@ -1,5 +1,7 @@
1
1
  import ast
2
+ import decimal
2
3
  import re
4
+ from decimal import Decimal
3
5
 
4
6
  datetime64_patterns = [
5
7
  r"\d\d\d\d.\d\d.\d\d(T|\s)\d\d:\d\d:\d\d.\d\d\d",
@@ -317,3 +319,89 @@ def type_test(i, t):
317
319
  return True
318
320
  except Exception:
319
321
  return False
322
+
323
+
324
+ def parse_decimal_type(typ):
325
+ """
326
+ >>> parse_decimal_type("decimal")
327
+
328
+ >>> parse_decimal_type('Decimal')
329
+ (64, 10, 0)
330
+ >>> parse_decimal_type('Decimal()')
331
+
332
+ >>> parse_decimal_type('Decimal(2)')
333
+ (32, 2, 0)
334
+ >>> parse_decimal_type('Decimal(5,2)')
335
+ (32, 5, 2)
336
+ >>> parse_decimal_type('Decimal( 9 , 2 )')
337
+ (32, 9, 2)
338
+ >>> parse_decimal_type('Decimal(10,2)')
339
+ (64, 10, 2)
340
+ >>> parse_decimal_type('Decimal(19,2)')
341
+ (128, 19, 2)
342
+ >>> parse_decimal_type('Decimal(39,2)')
343
+ (256, 39, 2)
344
+ >>> parse_decimal_type('Decimal32(9)')
345
+ (32, 9, 9)
346
+ >>> parse_decimal_type('Decimal32(10)')
347
+
348
+ >>> parse_decimal_type('Decimal(10,10)')
349
+ (64, 10, 10)
350
+ >>> parse_decimal_type('Decimal(10,11)')
351
+
352
+ >>> parse_decimal_type('Decimal32(5, 2)')
353
+
354
+ >>> parse_decimal_type('Decimal64(2)')
355
+ (64, 18, 2)
356
+ >>> parse_decimal_type('Decimal128(2)')
357
+ (128, 38, 2)
358
+ >>> parse_decimal_type('Decimal256(2)')
359
+ (256, 76, 2)
360
+ """
361
+ # Obtained from https://clickhouse.com/docs/en/sql-reference/data-types/decimal
362
+ max_digits_by_bit_width = {32: 9, 64: 18, 128: 38, 256: 76}
363
+
364
+ # Check if type is Decimal, Decimal(P), or Decimal(P, S) with whitespace support
365
+ # Regex contains two capturing groups. First capturing P. Second capturing S.
366
+ if m := re.match(r"^Decimal\s*(?:\(\s*(\d+)(?:\s*,\s*(\d+))?\s*\))?$", typ):
367
+ p, s = int(m.group(1) or 10), int(m.group(2) or 0)
368
+ b = min(bit_width for bit_width, max_digits in max_digits_by_bit_width.items() if max_digits >= p)
369
+ if p < s or b is None:
370
+ return None
371
+ # Check if type is Decimal32(S), Decimal64(S), Decimal128(S), or Decimal256(S) with whitespace support.
372
+ # Regex contains 2 capturing groups. First capturing 32, 64, 128 or 256. Second capturing S.
373
+ elif m := re.match(r"^Decimal(32|64|128|256)\s*\(\s*(\d+)\s*\)$", typ):
374
+ b, s = int(m.group(1)), int(m.group(2))
375
+ p = max_digits_by_bit_width[int(b)]
376
+ if p < s:
377
+ return None
378
+ else:
379
+ return None
380
+ return b, p, s
381
+
382
+
383
+ def is_type_decimal(type_to_check):
384
+ """
385
+ >>> is_type_decimal('Decimal')
386
+ True
387
+ >>> is_type_decimal("Decimal(10, 2)")
388
+ True
389
+ >>> is_type_decimal("decimal")
390
+ False
391
+ """
392
+ return parse_decimal_type(type_to_check) is not None
393
+
394
+
395
+ def get_decimal_limits(p, s):
396
+ """
397
+ >>> get_decimal_limits(1, 0)
398
+ (Decimal('-9'), Decimal('9'))
399
+ >>> get_decimal_limits(5, 5)
400
+ (Decimal('-0.99999'), Decimal('0.99999'))
401
+ >>> get_decimal_limits(76, 38)
402
+ (Decimal('-99999999999999999999999999999999999999.99999999999999999999999999999999999999'), Decimal('99999999999999999999999999999999999999.99999999999999999999999999999999999999'))
403
+ """
404
+ with decimal.localcontext(prec=p + 2):
405
+ max_value = Decimal(((10**p) - 1)) / (10**s)
406
+ min_value = -max_value
407
+ return min_value, max_value
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tinybird-cli
3
- Version: 5.1.1.dev3
3
+ Version: 5.2.1.dev0
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/cli/introduction.html
6
6
  Author: Tinybird
@@ -51,20 +51,12 @@ The Tinybird command-line tool allows you to use all the Tinybird functionality
51
51
  Changelog
52
52
  ----------
53
53
 
54
- 5.1.1.dev3
55
- ***********
56
-
57
- - `Improved` No need for `--node` param in `tb pipe populate`
58
-
59
- 5.1.1.dev2
60
- ************
54
+ 5.2.0
55
+ ******
61
56
 
57
+ - `Added` internal changes
62
58
  - `Added` `tb pipe unlink` command
63
-
64
- 5.1.1.dev1
65
- ***********
66
-
67
- - `Added` internal release
59
+ - `Changed` No need for `--node` param in `tb pipe populate`
68
60
 
69
61
  5.1.0
70
62
  ******
@@ -1,11 +1,11 @@
1
- tinybird/__cli__.py,sha256=wBhbllYssfKoVKD9Kd6-Jo_ZjEcPjqbVdTvoDi2axo4,254
1
+ tinybird/__cli__.py,sha256=IbnUUJ08cF2YML6kb9feeJ0xdS3OpWZbGSlQoIpIxDo,254
2
2
  tinybird/check_pypi.py,sha256=_4NkharLyR_ELrAdit-ftqIWvOf7jZNPt3i76frlo9g,975
3
3
  tinybird/client.py,sha256=j-2KQUlxf4gJUjTVf4o6y8-aV0OSXlBWndPEb9Ny8aA,47851
4
4
  tinybird/config.py,sha256=E0jDwbFD1zhdijNhtF8fg6mqIyKbZ8xpNPP_3n2PFpE,2003
5
5
  tinybird/connectors.py,sha256=lkpVSUmSuViEZBa4QjTK7YmPHUop0a5UFoTrSmlVq6k,15244
6
6
  tinybird/context.py,sha256=3KwB9TL-nON6qX9Mm5uev4CkrgLwYyNDvdFfQmNc0Cc,1171
7
7
  tinybird/datafile.py,sha256=J4GPqEwfnsvUuVlPcaYMFc3zuG26vAB-zrJtLRZJNoc,213625
8
- tinybird/datatypes.py,sha256=adYOQBTyfeBGVINIlaRex_81gTQQuqF2M9VTQpzq1H0,7060
8
+ tinybird/datatypes.py,sha256=Q4u7noeosY6tl3yGWPdaOCJsFEUY1h0M_d_CgFdOIpA,9988
9
9
  tinybird/feedback_manager.py,sha256=F5W3iMKwfnHZU0REzIsdoc_pguoPT1nAFrB_OeUn00A,62568
10
10
  tinybird/git_settings.py,sha256=vu8sWb3TAXeM8Tqy27aR0el8MnPm7kqQzTRV76xB0ro,4707
11
11
  tinybird/sql.py,sha256=hUnpfmkRkdyZV2ylIYflzxnwyv5Es7fLEv6cBc39OJA,41589
@@ -36,8 +36,8 @@ tinybird/tb_cli_modules/workspace.py,sha256=TfKqSQuIk5JhG7Za4Z6e2uTwy4NhWPXLgZN2
36
36
  tinybird/tb_cli_modules/workspace_members.py,sha256=0nkaQJJdR_6rLnTeoK0eBkiDFnm4v7Z2oFGovY-jYMY,8446
37
37
  tinybird/tb_cli_modules/tinyunit/tinyunit.py,sha256=0dYYmZMMJVubxSPls2e_a-fqtUYvgLfu2B0xwLfkbHw,11667
38
38
  tinybird/tb_cli_modules/tinyunit/tinyunit_lib.py,sha256=j92za8QbXrv4eIPjKBZPn9ghR-nYQ2wZZ88MeXyMWXE,1868
39
- tinybird_cli-5.1.1.dev3.dist-info/METADATA,sha256=tMXZWI1E0a4gLcnm9QYTWq8waBPayIX8LDiv-7M9vJA,73778
40
- tinybird_cli-5.1.1.dev3.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
41
- tinybird_cli-5.1.1.dev3.dist-info/entry_points.txt,sha256=PKPKuPmA4IfJYnCFHHUiw-aAWZuBomFvwCklv1OyCjE,43
42
- tinybird_cli-5.1.1.dev3.dist-info/top_level.txt,sha256=pgw6AzERHBcW3YTi2PW4arjxLkulk2msOz_SomfOEuc,45
43
- tinybird_cli-5.1.1.dev3.dist-info/RECORD,,
39
+ tinybird_cli-5.2.1.dev0.dist-info/METADATA,sha256=bDDoui3FGRhm8F583Ets1zWBAd0cVQMV-7RA82yuEzU,73716
40
+ tinybird_cli-5.2.1.dev0.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
41
+ tinybird_cli-5.2.1.dev0.dist-info/entry_points.txt,sha256=PKPKuPmA4IfJYnCFHHUiw-aAWZuBomFvwCklv1OyCjE,43
42
+ tinybird_cli-5.2.1.dev0.dist-info/top_level.txt,sha256=pgw6AzERHBcW3YTi2PW4arjxLkulk2msOz_SomfOEuc,45
43
+ tinybird_cli-5.2.1.dev0.dist-info/RECORD,,