tinybird-cli 4.1.1.dev1__tar.gz → 4.1.2.dev0__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.
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/PKG-INFO +2 -2
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/__cli__.py +2 -2
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/context.py +1 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/datafile.py +3 -3
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/sql_template.py +92 -66
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tornado_template.py +9 -1
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird_cli.egg-info/PKG-INFO +2 -2
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/setup.cfg +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/ch_utils/constants.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/ch_utils/engine.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/check_pypi.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/client.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/config.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/connectors.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/datatypes.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/feedback_manager.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/git_settings.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/sql.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/sql_template_fmt.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/sql_toolset.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/syncasync.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/auth.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/branch.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/cicd.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/cli.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/common.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/config.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/connection.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/datasource.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/exceptions.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/job.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/pipe.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/regions.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/telemetry.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/test.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/tinyunit/tinyunit.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/tinyunit/tinyunit_lib.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/token.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/workspace.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/workspace_members.py +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird_cli.egg-info/SOURCES.txt +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird_cli.egg-info/dependency_links.txt +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird_cli.egg-info/entry_points.txt +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird_cli.egg-info/requires.txt +0 -0
- {tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird_cli.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: tinybird-cli
|
|
3
|
-
Version: 4.1.
|
|
3
|
+
Version: 4.1.2.dev0
|
|
4
4
|
Summary: Tinybird Command Line Tool
|
|
5
5
|
Home-page: https://www.tinybird.co/docs/cli/introduction.html
|
|
6
6
|
Author: Tinybird
|
|
@@ -18,7 +18,7 @@ The Tinybird command-line tool allows you to use all the Tinybird functionality
|
|
|
18
18
|
Changelog
|
|
19
19
|
----------
|
|
20
20
|
|
|
21
|
-
4.1.1
|
|
21
|
+
4.1.1
|
|
22
22
|
************
|
|
23
23
|
|
|
24
24
|
- `Fixed` workspace info gathering when switching branches. We were prioritizing the general workspace properties over the user ones.
|
|
@@ -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__ = '4.1.
|
|
8
|
-
__revision__ = '
|
|
7
|
+
__version__ = '4.1.2.dev0'
|
|
8
|
+
__revision__ = 'b6a6857'
|
|
@@ -7,6 +7,7 @@ hfi_frequency: ContextVar[float] = ContextVar("hfi_frequency")
|
|
|
7
7
|
hfi_frequency_gatherer: ContextVar[float] = ContextVar("hfi_frequency_gatherer")
|
|
8
8
|
use_gatherer: ContextVar[bool] = ContextVar("use_gatherer")
|
|
9
9
|
allow_gatherer_fallback: ContextVar[bool] = ContextVar("allow_gatherer_fallback")
|
|
10
|
+
gatherer_allow_s3_backup_on_user_errors: ContextVar[bool] = ContextVar("gatherer_allow_s3_backup_on_user_errors")
|
|
10
11
|
disable_template_security_validation: ContextVar[bool] = ContextVar("disable_template_security_validation")
|
|
11
12
|
origin: ContextVar[str] = ContextVar("origin")
|
|
12
13
|
request_id: ContextVar[str] = ContextVar("request_id")
|
|
@@ -773,7 +773,7 @@ def parse_pipe(
|
|
|
773
773
|
for node in doc.nodes:
|
|
774
774
|
sql = node.get("sql", "")
|
|
775
775
|
if sql.strip()[0] == "%":
|
|
776
|
-
sql, _ = render_sql_template(sql[1:], test_mode=True, name=node["name"])
|
|
776
|
+
sql, _, _ = render_sql_template(sql[1:], test_mode=True, name=node["name"])
|
|
777
777
|
# it'll fail with a ModuleNotFoundError when the toolset is not available but it returns the parsed doc
|
|
778
778
|
from tinybird.sql_toolset import format_sql as toolset_format_sql
|
|
779
779
|
|
|
@@ -785,7 +785,7 @@ def parse_pipe(
|
|
|
785
785
|
)
|
|
786
786
|
)
|
|
787
787
|
except ValueError as e:
|
|
788
|
-
t, template_variables = get_template_and_variables(sql, name=node["name"])
|
|
788
|
+
t, template_variables, _ = get_template_and_variables(sql, name=node["name"])
|
|
789
789
|
|
|
790
790
|
if sql.strip()[0] != "%" and len(template_variables) > 0:
|
|
791
791
|
raise click.ClickException(FeedbackManager.error_template_start(filename=filename))
|
|
@@ -1492,7 +1492,7 @@ async def process_file(
|
|
|
1492
1492
|
is_template = False
|
|
1493
1493
|
if sql[0] == "%":
|
|
1494
1494
|
try:
|
|
1495
|
-
sql_rendered, _ = render_sql_template(sql[1:], test_mode=True)
|
|
1495
|
+
sql_rendered, _, _ = render_sql_template(sql[1:], test_mode=True)
|
|
1496
1496
|
except Exception as e:
|
|
1497
1497
|
raise click.ClickException(
|
|
1498
1498
|
FeedbackManager.error_parsing_node(node=node["name"], pipe=name, error=str(e))
|
|
@@ -42,6 +42,24 @@ class SQLTemplateException(ValueError):
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
DEFAULT_PARAM_NAMES = ["format", "q"]
|
|
45
|
+
RESERVED_PARAM_NAMES = [
|
|
46
|
+
"__tb__semver",
|
|
47
|
+
"debug_source_tables",
|
|
48
|
+
"debug",
|
|
49
|
+
"explain",
|
|
50
|
+
"finalize_aggregations",
|
|
51
|
+
"output_format_json_quote_64bit_integers",
|
|
52
|
+
"output_format_json_quote_denormals",
|
|
53
|
+
"output_format_parquet_string_as_string",
|
|
54
|
+
"pipeline",
|
|
55
|
+
"playground",
|
|
56
|
+
"q",
|
|
57
|
+
"query_id",
|
|
58
|
+
"release_replacements",
|
|
59
|
+
"tag",
|
|
60
|
+
"template_parameters",
|
|
61
|
+
"token",
|
|
62
|
+
]
|
|
45
63
|
|
|
46
64
|
parameter_types = [
|
|
47
65
|
"String",
|
|
@@ -1771,6 +1789,8 @@ def get_template_and_variables(sql: str, name: Optional[str], escape_arrays: boo
|
|
|
1771
1789
|
it is important to NOT MODIFY THESE OBJECTS.
|
|
1772
1790
|
Neither render_sql_template() or generate() modify them, so neither should you
|
|
1773
1791
|
"""
|
|
1792
|
+
variable_warnings = []
|
|
1793
|
+
|
|
1774
1794
|
try:
|
|
1775
1795
|
t = Template(sql, name)
|
|
1776
1796
|
template_variables = get_var_names(t)
|
|
@@ -1780,10 +1800,12 @@ def get_template_and_variables(sql: str, name: Optional[str], escape_arrays: boo
|
|
|
1780
1800
|
name = variable["name"]
|
|
1781
1801
|
line = variable["line"]
|
|
1782
1802
|
raise ValueError(f'"{name}" can not be used as a variable name, line {line}')
|
|
1803
|
+
if variable["name"] in RESERVED_PARAM_NAMES:
|
|
1804
|
+
variable_warnings.append(variable["name"])
|
|
1783
1805
|
|
|
1784
1806
|
wrap_vars(t, escape_arrays=escape_arrays)
|
|
1785
1807
|
|
|
1786
|
-
return t, template_variables
|
|
1808
|
+
return t, template_variables, variable_warnings
|
|
1787
1809
|
except SecurityException as e:
|
|
1788
1810
|
raise SQLTemplateException(e)
|
|
1789
1811
|
|
|
@@ -1836,96 +1858,96 @@ def render_sql_template(
|
|
|
1836
1858
|
variables: Optional[dict] = None,
|
|
1837
1859
|
test_mode: bool = False,
|
|
1838
1860
|
name: Optional[str] = None,
|
|
1839
|
-
) -> Tuple[str, dict]:
|
|
1861
|
+
) -> Tuple[str, dict, list]:
|
|
1840
1862
|
"""
|
|
1841
1863
|
>>> render_sql_template("select * from table where f = {{Float32(foo)}}", { 'foo': -1 })
|
|
1842
|
-
("select * from table where f = toFloat32('-1.0')", {})
|
|
1864
|
+
("select * from table where f = toFloat32('-1.0')", {}, [])
|
|
1843
1865
|
>>> render_sql_template("{% if defined(open) %}ERROR{% else %}YEAH!{% end %}")
|
|
1844
|
-
('YEAH!', {})
|
|
1866
|
+
('YEAH!', {}, [])
|
|
1845
1867
|
>>> render_sql_template("{% if defined(close) %}ERROR{% else %}YEAH!{% end %}")
|
|
1846
|
-
('YEAH!', {})
|
|
1868
|
+
('YEAH!', {}, [])
|
|
1847
1869
|
>>> render_sql_template("{% if defined(input) %}ERROR{% else %}YEAH!{% end %}")
|
|
1848
|
-
('YEAH!', {})
|
|
1870
|
+
('YEAH!', {}, [])
|
|
1849
1871
|
>>> render_sql_template("{% if defined(print) %}ERROR{% else %}YEAH!{% end %}")
|
|
1850
|
-
('YEAH!', {})
|
|
1872
|
+
('YEAH!', {}, [])
|
|
1851
1873
|
>>> render_sql_template("select * from table where str = {{foo}}", { 'foo': 'test' })
|
|
1852
|
-
("select * from table where str = 'test'", {})
|
|
1874
|
+
("select * from table where str = 'test'", {}, [])
|
|
1853
1875
|
>>> render_sql_template("select * from table where f = {{foo}}", { 'foo': 1.0 })
|
|
1854
|
-
('select * from table where f = 1.0', {})
|
|
1876
|
+
('select * from table where f = 1.0', {}, [])
|
|
1855
1877
|
>>> render_sql_template("select {{Boolean(foo)}} from table", { 'foo': True })
|
|
1856
|
-
('select 1 from table', {})
|
|
1878
|
+
('select 1 from table', {}, [])
|
|
1857
1879
|
>>> render_sql_template("select {{Boolean(foo)}} from table", { 'foo': False })
|
|
1858
|
-
('select 0 from table', {})
|
|
1880
|
+
('select 0 from table', {}, [])
|
|
1859
1881
|
>>> render_sql_template("select * from table where f = {{Float32(foo)}}", { 'foo': 1 })
|
|
1860
|
-
("select * from table where f = toFloat32('1.0')", {})
|
|
1882
|
+
("select * from table where f = toFloat32('1.0')", {}, [])
|
|
1861
1883
|
>>> render_sql_template("select * from table where f = {{foo}}", { 'foo': "';drop table users;" })
|
|
1862
|
-
("select * from table where f = '\\\\';drop table users;'", {})
|
|
1884
|
+
("select * from table where f = '\\\\';drop table users;'", {}, [])
|
|
1863
1885
|
>>> render_sql_template("select * from {{symbol(foo)}}", { 'foo': 'table-name' })
|
|
1864
|
-
('select * from `table-name`', {})
|
|
1886
|
+
('select * from `table-name`', {}, [])
|
|
1865
1887
|
>>> render_sql_template("select * from {{symbol(foo)}}", { 'foo': '"table-name"' })
|
|
1866
|
-
('select * from `table-name`', {})
|
|
1888
|
+
('select * from `table-name`', {}, [])
|
|
1867
1889
|
>>> render_sql_template("select * from {{table(foo)}}", { 'foo': '"table-name"' })
|
|
1868
|
-
('select * from table-name', {})
|
|
1890
|
+
('select * from table-name', {}, [])
|
|
1869
1891
|
>>> render_sql_template("select * from {{Int32(foo)}}", { 'foo': 'non_int' })
|
|
1870
1892
|
Traceback (most recent call last):
|
|
1871
1893
|
...
|
|
1872
1894
|
tinybird.sql_template.SQLTemplateException: Template Syntax Error: Error validating 'non_int' to type Int32
|
|
1873
1895
|
>>> render_sql_template("select * from table where f = {{Float32(foo)}}", test_mode=True)
|
|
1874
|
-
("select * from table where f = toFloat32('0.0')", {})
|
|
1896
|
+
("select * from table where f = toFloat32('0.0')", {}, [])
|
|
1875
1897
|
>>> render_sql_template("SELECT * FROM query_log__dev where a = {{test}}", test_mode=True)
|
|
1876
|
-
("SELECT * FROM query_log__dev where a = '__placeholder__'", {})
|
|
1898
|
+
("SELECT * FROM query_log__dev where a = '__placeholder__'", {}, [])
|
|
1877
1899
|
>>> render_sql_template("SELECT {{test}}", {'token':'testing'})
|
|
1878
1900
|
Traceback (most recent call last):
|
|
1879
1901
|
...
|
|
1880
1902
|
tinybird.sql_template.SQLTemplateException: Template Syntax Error: expression "test" evaluated to null
|
|
1881
1903
|
>>> render_sql_template('{% if test %}SELECT 1{% else %} select 2 {% end %}')
|
|
1882
|
-
(' select 2 ', {})
|
|
1904
|
+
(' select 2 ', {}, [])
|
|
1883
1905
|
>>> render_sql_template('{% if Int32(test, 1) %}SELECT 1{% else %} select 2 {% end %}')
|
|
1884
|
-
('SELECT 1', {})
|
|
1906
|
+
('SELECT 1', {}, [])
|
|
1885
1907
|
>>> render_sql_template('{% for v in test %}SELECT {{v}} {% end %}',test_mode=True)
|
|
1886
|
-
("SELECT '__placeholder__' SELECT '__placeholder__' SELECT '__placeholder__' ", {})
|
|
1908
|
+
("SELECT '__placeholder__' SELECT '__placeholder__' SELECT '__placeholder__' ", {}, [])
|
|
1887
1909
|
>>> render_sql_template("select {{Int32(foo, 1)}}", test_mode=True)
|
|
1888
|
-
("select toInt32('1')", {})
|
|
1910
|
+
("select toInt32('1')", {}, [])
|
|
1889
1911
|
>>> render_sql_template("SELECT count() c FROM test_table where a > {{Float32(myvar)}} {% if defined(my_condition) %} and c = Int32({{my_condition}}){% end %}", {'myvar': 1.0})
|
|
1890
|
-
("SELECT count() c FROM test_table where a > toFloat32('1.0') ", {})
|
|
1912
|
+
("SELECT count() c FROM test_table where a > toFloat32('1.0') ", {}, [])
|
|
1891
1913
|
>>> render_sql_template("SELECT count() c FROM where {{sql_and(a=a, b=b)}}", {'a': '1', 'b': '2'})
|
|
1892
|
-
("SELECT count() c FROM where a = '1' and b = '2'", {})
|
|
1914
|
+
("SELECT count() c FROM where a = '1' and b = '2'", {}, [])
|
|
1893
1915
|
>>> render_sql_template("SELECT count() c FROM where {{sql_and(a=a, b=b)}}", {'b': '2'})
|
|
1894
|
-
("SELECT count() c FROM where b = '2'", {})
|
|
1916
|
+
("SELECT count() c FROM where b = '2'", {}, [])
|
|
1895
1917
|
>>> render_sql_template("SELECT count() c FROM where {{sql_and(a=Int(a, defined=False), b=Int(b, defined=False))}}", {'b': '2'})
|
|
1896
|
-
('SELECT count() c FROM where b = 2', {})
|
|
1918
|
+
('SELECT count() c FROM where b = 2', {}, [])
|
|
1897
1919
|
>>> render_sql_template("SELECT count() c FROM where {{sql_and(a__in=Array(a), b=b)}}", {'a': 'a,b,c','b': '2'})
|
|
1898
|
-
("SELECT count() c FROM where a in ['a','b','c'] and b = '2'", {})
|
|
1920
|
+
("SELECT count() c FROM where a in ['a','b','c'] and b = '2'", {}, [])
|
|
1899
1921
|
>>> render_sql_template("SELECT count() c FROM where {{sql_and(a__not_in=Array(a), b=b)}}", {'a': 'a,b,c','b': '2'})
|
|
1900
|
-
("SELECT count() c FROM where a not in ['a','b','c'] and b = '2'", {})
|
|
1922
|
+
("SELECT count() c FROM where a not in ['a','b','c'] and b = '2'", {}, [])
|
|
1901
1923
|
>>> render_sql_template("SELECT c FROM where a > {{Date(start)}}", test_mode=True)
|
|
1902
|
-
("SELECT c FROM where a > '2019-01-01'", {})
|
|
1924
|
+
("SELECT c FROM where a > '2019-01-01'", {}, [])
|
|
1903
1925
|
>>> render_sql_template("SELECT c FROM where a > {{DateTime(start)}}", test_mode=True)
|
|
1904
|
-
("SELECT c FROM where a > '2019-01-01 00:00:00'", {})
|
|
1926
|
+
("SELECT c FROM where a > '2019-01-01 00:00:00'", {}, [])
|
|
1905
1927
|
>>> render_sql_template("SELECT c FROM where a > {{DateTime(start)}}", {'start': '2018-09-07 23:55:00'})
|
|
1906
|
-
("SELECT c FROM where a > '2018-09-07 23:55:00'", {})
|
|
1928
|
+
("SELECT c FROM where a > '2018-09-07 23:55:00'", {}, [])
|
|
1907
1929
|
>>> render_sql_template('SELECT * FROM tracker {% if defined(start) %} {{DateTime(start)}} and {{DateTime(end)}} {% end %}', {'start': '2019-08-01 00:00:00', 'end': '2019-08-02 00:00:00'})
|
|
1908
|
-
("SELECT * FROM tracker '2019-08-01 00:00:00' and '2019-08-02 00:00:00' ", {})
|
|
1930
|
+
("SELECT * FROM tracker '2019-08-01 00:00:00' and '2019-08-02 00:00:00' ", {}, [])
|
|
1909
1931
|
>>> render_sql_template('SELECT * from test limit {{Int(limit)}}', test_mode=True)
|
|
1910
|
-
('SELECT * from test limit 0', {})
|
|
1932
|
+
('SELECT * from test limit 0', {}, [])
|
|
1911
1933
|
>>> render_sql_template('SELECT {{symbol(attr)}} from test', test_mode=True)
|
|
1912
|
-
('SELECT `placeholder` from test', {})
|
|
1934
|
+
('SELECT `placeholder` from test', {}, [])
|
|
1913
1935
|
>>> render_sql_template('SELECT {{Array(foo)}}', {'foo': 'a,b,c,d'})
|
|
1914
|
-
("SELECT ['a','b','c','d']", {})
|
|
1936
|
+
("SELECT ['a','b','c','d']", {}, [])
|
|
1915
1937
|
>>> render_sql_template("SELECT {{Array(foo, 'Int32')}}", {'foo': '1,2,3,4'})
|
|
1916
|
-
('SELECT [1,2,3,4]', {})
|
|
1938
|
+
('SELECT [1,2,3,4]', {}, [])
|
|
1917
1939
|
>>> render_sql_template("SELECT {{Array(foo, 'Int32')}}", test_mode=True)
|
|
1918
|
-
('SELECT [0,0]', {})
|
|
1940
|
+
('SELECT [0,0]', {}, [])
|
|
1919
1941
|
>>> render_sql_template("SELECT {{Array(foo)}}", test_mode=True)
|
|
1920
|
-
("SELECT ['__placeholder__0','__placeholder__1']", {})
|
|
1942
|
+
("SELECT ['__placeholder__0','__placeholder__1']", {}, [])
|
|
1921
1943
|
>>> render_sql_template("{{max_threads(2)}} SELECT 1")
|
|
1922
|
-
('-- max_threads 2\\n SELECT 1', {'max_threads': 2})
|
|
1944
|
+
('-- max_threads 2\\n SELECT 1', {'max_threads': 2}, [])
|
|
1923
1945
|
>>> render_sql_template("SELECT {{String(foo)}}", test_mode=True)
|
|
1924
|
-
("SELECT '__placeholder__'", {})
|
|
1946
|
+
("SELECT '__placeholder__'", {}, [])
|
|
1925
1947
|
>>> render_sql_template("SELECT {{String(foo, 'test')}}", test_mode=True)
|
|
1926
|
-
("SELECT 'test'", {})
|
|
1948
|
+
("SELECT 'test'", {}, [])
|
|
1927
1949
|
>>> render_sql_template("SELECT {{String(foo, 'test')}}", {'foo': 'tt'})
|
|
1928
|
-
("SELECT 'tt'", {})
|
|
1950
|
+
("SELECT 'tt'", {}, [])
|
|
1929
1951
|
>>> render_sql_template("SELECT {{String(format, 'test')}}", {'format': 'tt'})
|
|
1930
1952
|
Traceback (most recent call last):
|
|
1931
1953
|
...
|
|
@@ -1943,25 +1965,25 @@ def render_sql_template(
|
|
|
1943
1965
|
...
|
|
1944
1966
|
tinybird.sql_template.SQLTemplateException: Template Syntax Error: Missing column() default value, use `column(column_name, 'default_column_name')`
|
|
1945
1967
|
>>> render_sql_template("SELECT {{column(agg)}}", {'agg': 'foo'})
|
|
1946
|
-
('SELECT `foo`', {})
|
|
1968
|
+
('SELECT `foo`', {}, [])
|
|
1947
1969
|
>>> render_sql_template("SELECT {{column(agg)}}", {'agg': '"foo"'})
|
|
1948
|
-
('SELECT `foo`', {})
|
|
1970
|
+
('SELECT `foo`', {}, [])
|
|
1949
1971
|
>>> render_sql_template('{% if not defined(test) %}error("This is an error"){% end %}', {})
|
|
1950
|
-
('error("This is an error")', {})
|
|
1972
|
+
('error("This is an error")', {}, [])
|
|
1951
1973
|
>>> render_sql_template('{% if not defined(test) %}custom_error({error: "This is an error"}){% end %}', {})
|
|
1952
|
-
('custom_error({error: "This is an error"})', {})
|
|
1974
|
+
('custom_error({error: "This is an error"})', {}, [])
|
|
1953
1975
|
>>> render_sql_template("SELECT {{String(foo + 'abcd')}}", test_mode=True)
|
|
1954
|
-
("SELECT '__placeholder__'", {})
|
|
1976
|
+
("SELECT '__placeholder__'", {}, [])
|
|
1955
1977
|
>>> render_sql_template("SELECT {{columns(agg)}}", {})
|
|
1956
1978
|
Traceback (most recent call last):
|
|
1957
1979
|
...
|
|
1958
1980
|
tinybird.sql_template.SQLTemplateException: Template Syntax Error: Missing columns() default value, use `columns(column_names, 'default_column_name')`
|
|
1959
1981
|
>>> render_sql_template("SELECT {{columns(agg, 'a,b,c')}} FROM table", {})
|
|
1960
|
-
('SELECT `a`,`b`,`c` FROM table', {})
|
|
1982
|
+
('SELECT `a`,`b`,`c` FROM table', {}, [])
|
|
1961
1983
|
>>> render_sql_template("SELECT {{columns(agg, 'a,b,c')}} FROM table", {'agg': 'foo'})
|
|
1962
|
-
('SELECT `foo` FROM table', {})
|
|
1984
|
+
('SELECT `foo` FROM table', {}, [])
|
|
1963
1985
|
>>> render_sql_template("SELECT {{columns('a,b,c')}} FROM table", {})
|
|
1964
|
-
('SELECT `a`,`b`,`c` FROM table', {})
|
|
1986
|
+
('SELECT `a`,`b`,`c` FROM table', {}, [])
|
|
1965
1987
|
>>> render_sql_template("% {% if whatever(passenger_count) %}{% end %}", test_mode=True)
|
|
1966
1988
|
Traceback (most recent call last):
|
|
1967
1989
|
...
|
|
@@ -1971,13 +1993,13 @@ def render_sql_template(
|
|
|
1971
1993
|
...
|
|
1972
1994
|
SyntaxError: invalid syntax
|
|
1973
1995
|
>>> render_sql_template("SELECT * FROM dim_fecha_evento where foo like {{sql_unescape(String(pepe), '%')}}", {"pepe": 'raul_el_bueno_is_the_best_%'})
|
|
1974
|
-
("SELECT * FROM dim_fecha_evento where foo like 'raul_el_bueno_is_the_best_%'", {})
|
|
1996
|
+
("SELECT * FROM dim_fecha_evento where foo like 'raul_el_bueno_is_the_best_%'", {}, [])
|
|
1975
1997
|
>>> render_sql_template("SELECT * FROM table WHERE field={{String(field_filter)}}", {"field_filter": 'action."test run"'})
|
|
1976
|
-
('SELECT * FROM table WHERE field=\\'action.\\\\"test run\\\\"\\'', {})
|
|
1998
|
+
('SELECT * FROM table WHERE field=\\'action.\\\\"test run\\\\"\\'', {}, [])
|
|
1977
1999
|
>>> render_sql_template("SELECT {{Int128(foo)}} as x, {{Int128(bar)}} as y", {'foo': -170141183460469231731687303715884105728, 'bar': 170141183460469231731687303715884105727})
|
|
1978
|
-
("SELECT toInt128('-170141183460469231731687303715884105728') as x, toInt128('170141183460469231731687303715884105727') as y", {})
|
|
2000
|
+
("SELECT toInt128('-170141183460469231731687303715884105728') as x, toInt128('170141183460469231731687303715884105727') as y", {}, [])
|
|
1979
2001
|
>>> render_sql_template("SELECT {{Int256(foo)}} as x, {{Int256(bar)}} as y", {'foo': -57896044618658097711785492504343953926634992332820282019728792003956564819968, 'bar': 57896044618658097711785492504343953926634992332820282019728792003956564819967})
|
|
1980
|
-
("SELECT toInt256('-57896044618658097711785492504343953926634992332820282019728792003956564819968') as x, toInt256('57896044618658097711785492504343953926634992332820282019728792003956564819967') as y", {})
|
|
2002
|
+
("SELECT toInt256('-57896044618658097711785492504343953926634992332820282019728792003956564819968') as x, toInt256('57896044618658097711785492504343953926634992332820282019728792003956564819967') as y", {}, [])
|
|
1981
2003
|
>>> render_sql_template('% SELECT * FROM {% import os %}{{ os.popen("whoami").read() }}')
|
|
1982
2004
|
Traceback (most recent call last):
|
|
1983
2005
|
...
|
|
@@ -1999,21 +2021,21 @@ def render_sql_template(
|
|
|
1999
2021
|
...
|
|
2000
2022
|
tinybird.sql_template.SQLTemplateException: Template Syntax Error: Invalid BinOp: Pow()
|
|
2001
2023
|
>>> render_sql_template("% SELECT {{Array(click_selector, 'String', 'pre,pro')}}")
|
|
2002
|
-
("% SELECT ['pre','pro']", {})
|
|
2024
|
+
("% SELECT ['pre','pro']", {}, [])
|
|
2003
2025
|
>>> render_sql_template("% SELECT {{Array(click_selector, 'String', 'pre,pro')}}", {'click_selector': 'hi,hello'})
|
|
2004
|
-
("% SELECT ['hi','hello']", {})
|
|
2026
|
+
("% SELECT ['hi','hello']", {}, [])
|
|
2005
2027
|
>>> render_sql_template("% SELECT now() > {{DateTime64(variable, '2020-09-09 10:10:10.000')}}", {})
|
|
2006
|
-
("% SELECT now() > '2020-09-09 10:10:10.000'", {})
|
|
2028
|
+
("% SELECT now() > '2020-09-09 10:10:10.000'", {}, [])
|
|
2007
2029
|
>>> render_sql_template("% SELECT {% if defined(x) %} x, 1", {})
|
|
2008
2030
|
Traceback (most recent call last):
|
|
2009
2031
|
...
|
|
2010
2032
|
tinybird.tornado_template.UnClosedIfError: Missing {% end %} block for if at line 1
|
|
2011
2033
|
>>> render_sql_template("% SELECT * FROM employees WHERE 0 {% for kv in JSON(payload) %} OR department = {{kv['dp']}} {% end %}")
|
|
2012
|
-
('% SELECT * FROM employees WHERE 0 ', {})
|
|
2034
|
+
('% SELECT * FROM employees WHERE 0 ', {}, [])
|
|
2013
2035
|
>>> render_sql_template("% SELECT * FROM employees WHERE 0 {% for kv in JSON(payload, '[{\\"dp\\":\\"Sales\\"}]') %} OR department = {{kv['dp']}} {% end %}")
|
|
2014
|
-
("% SELECT * FROM employees WHERE 0 OR department = 'Sales' ", {})
|
|
2036
|
+
("% SELECT * FROM employees WHERE 0 OR department = 'Sales' ", {}, [])
|
|
2015
2037
|
>>> render_sql_template("% SELECT * FROM employees WHERE 0 {% for kv in JSON(payload) %} OR department = {{kv['dp']}} {% end %}", { 'payload': '[{"dp":"Design"},{"dp":"Marketing"}]'})
|
|
2016
|
-
("% SELECT * FROM employees WHERE 0 OR department = 'Design' OR department = 'Marketing' ", {})
|
|
2038
|
+
("% SELECT * FROM employees WHERE 0 OR department = 'Design' OR department = 'Marketing' ", {}, [])
|
|
2017
2039
|
>>> render_sql_template("% {% for kv in JSON(payload) %} department = {{kv['dp']}} {% end %}", test_mode=True)
|
|
2018
2040
|
Traceback (most recent call last):
|
|
2019
2041
|
...
|
|
@@ -2023,22 +2045,26 @@ def render_sql_template(
|
|
|
2023
2045
|
...
|
|
2024
2046
|
tinybird.sql_template.SQLTemplateException: Template Syntax Error: Error parsing JSON: '' - Expecting value: line 1 column 1 (char 0)
|
|
2025
2047
|
>>> render_sql_template("% {% if defined(test) %}{% set _groupByCSV = ','.join(test) %} SELECT test as aa, {{Array(test, 'String')}} as test, {{_groupByCSV}} as a {% end %}", {"test": "1,2"})
|
|
2026
|
-
("% SELECT test as aa, ['1','2'] as test, '1,2' as a ", {})
|
|
2048
|
+
("% SELECT test as aa, ['1','2'] as test, '1,2' as a ", {}, [])
|
|
2027
2049
|
>>> render_sql_template("% {% if defined(test) %}{% set _groupByCSV = ','.join(test) %} SELECT test as aa, {{Array(test, 'String')}} as test, {{_groupByCSV}} as a {% end %}", {"test": ["1","2"]})
|
|
2028
|
-
("% SELECT test as aa, ['1','2'] as test, '1,2' as a ", {})
|
|
2050
|
+
("% SELECT test as aa, ['1','2'] as test, '1,2' as a ", {}, [])
|
|
2029
2051
|
>>> render_sql_template("% {% if defined(test) %}{% set _total = sum(test) %} SELECT test as aa, {{Array(test, 'Int32')}} as test, {{_total}} as a {% end %}", {"test": "1,2"})
|
|
2030
|
-
('% SELECT test as aa, [1,2] as test, 3 as a ', {})
|
|
2052
|
+
('% SELECT test as aa, [1,2] as test, 3 as a ', {}, [])
|
|
2031
2053
|
>>> render_sql_template("% {% if defined(test) %}{% set _groupByCSV = ','.join(test) %} SELECT test as aa, {{Array(test, 'String')}} as test, {{_groupByCSV}} as a {% end %}", {"test": ["1","2"]})
|
|
2032
|
-
("% SELECT test as aa, ['1','2'] as test, '1,2' as a ", {})
|
|
2054
|
+
("% SELECT test as aa, ['1','2'] as test, '1,2' as a ", {}, [])
|
|
2033
2055
|
>>> render_sql_template("% SELECT {% if defined(x) %} x, 1")
|
|
2034
2056
|
Traceback (most recent call last):
|
|
2035
2057
|
...
|
|
2036
2058
|
tinybird.tornado_template.UnClosedIfError: Missing {% end %} block for if at line 1
|
|
2059
|
+
>>> render_sql_template("select * from table where str = {{pipeline}}", { 'pipeline': 'test' })
|
|
2060
|
+
("select * from table where str = 'test'", {}, ['pipeline'])
|
|
2037
2061
|
"""
|
|
2038
2062
|
escape_split_to_array = ff_split_to_array_escape.get(False)
|
|
2039
2063
|
bypass_preprocess_variables = ff_preprocess_parameters_circuit_breaker.get(False)
|
|
2040
2064
|
|
|
2041
|
-
t, template_variables = get_template_and_variables(
|
|
2065
|
+
t, template_variables, variable_warnings = get_template_and_variables(
|
|
2066
|
+
sql, name, escape_arrays=escape_split_to_array
|
|
2067
|
+
)
|
|
2042
2068
|
|
|
2043
2069
|
if not bypass_preprocess_variables and variables is not None:
|
|
2044
2070
|
processed_variables = preprocess_variables(variables, t)
|
|
@@ -2070,7 +2096,7 @@ def render_sql_template(
|
|
|
2070
2096
|
v.update(type_fns)
|
|
2071
2097
|
|
|
2072
2098
|
try:
|
|
2073
|
-
return generate(t, **v)
|
|
2099
|
+
return *generate(t, **v), variable_warnings
|
|
2074
2100
|
except NameError as e:
|
|
2075
2101
|
raise SQLTemplateException(e, documentation="/cli/advanced-templates.html#defined")
|
|
2076
2102
|
except SQLTemplateException:
|
|
@@ -892,7 +892,15 @@ def _parse(reader: _TemplateReader, template, in_block=None, in_loop=None):
|
|
|
892
892
|
reader.consume(2)
|
|
893
893
|
if not contents:
|
|
894
894
|
reader.raise_parse_error("Empty expression")
|
|
895
|
-
|
|
895
|
+
|
|
896
|
+
try:
|
|
897
|
+
body.chunks.append(_Expression(contents, line))
|
|
898
|
+
except SyntaxError:
|
|
899
|
+
operator, _, _ = contents.partition(" ")
|
|
900
|
+
|
|
901
|
+
if "from" in operator:
|
|
902
|
+
reader.raise_parse_error('"from" is a forbidden word')
|
|
903
|
+
raise
|
|
896
904
|
continue
|
|
897
905
|
|
|
898
906
|
# Block
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: tinybird-cli
|
|
3
|
-
Version: 4.1.
|
|
3
|
+
Version: 4.1.2.dev0
|
|
4
4
|
Summary: Tinybird Command Line Tool
|
|
5
5
|
Home-page: https://www.tinybird.co/docs/cli/introduction.html
|
|
6
6
|
Author: Tinybird
|
|
@@ -18,7 +18,7 @@ The Tinybird command-line tool allows you to use all the Tinybird functionality
|
|
|
18
18
|
Changelog
|
|
19
19
|
----------
|
|
20
20
|
|
|
21
|
-
4.1.1
|
|
21
|
+
4.1.1
|
|
22
22
|
************
|
|
23
23
|
|
|
24
24
|
- `Fixed` workspace info gathering when switching branches. We were prioritizing the general workspace properties over the user ones.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/tinyunit/tinyunit.py
RENAMED
|
File without changes
|
{tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/tinyunit/tinyunit_lib.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird/tb_cli_modules/workspace_members.py
RENAMED
|
File without changes
|
|
File without changes
|
{tinybird-cli-4.1.1.dev1 → tinybird-cli-4.1.2.dev0}/tinybird_cli.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|