tinybird-toolset 2.7.4__tar.gz → 2.8.0__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_toolset-2.7.4/src/tinybird_toolset.egg-info → tinybird_toolset-2.8.0}/PKG-INFO +1 -1
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/setup.py +1 -1
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0/src/tinybird_toolset.egg-info}/PKG-INFO +1 -1
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_check_write_query.py +81 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_replace_tables.py +56 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_tables.py +8 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/LICENSE +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/MANIFEST.in +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/README.md +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/conf.py +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/setup.cfg +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/src/chtoolset/__init__.py +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/src/chtoolset/query.py +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/src/tinybird_toolset.egg-info/SOURCES.txt +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/src/tinybird_toolset.egg-info/dependency_links.txt +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/src/tinybird_toolset.egg-info/requires.txt +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/src/tinybird_toolset.egg-info/top_level.txt +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_check_compatible_types.py +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_check_ttl_partition_compatibility.py +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_chquery.py +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_convert_to_row_binary.py +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_explain_ast.py +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_get_columns_from_create_query.py +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_get_left_table.py +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_internal_cache.py +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_normalize_query_keep_names.py +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_normalize_table_column.py +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_parse_create_materialized_view_target_table.py +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_replace_tables_backward_compat.py +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_rewrite_aggregation_states.py +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_validate_partition_key.py +0 -0
- {tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_validate_ttl.py +0 -0
|
@@ -154,6 +154,37 @@ class TestCreateTable(unittest.TestCase):
|
|
|
154
154
|
"""
|
|
155
155
|
self.assertEqual(query.format(query.check_valid_write_query(q)), query.format(q))
|
|
156
156
|
|
|
157
|
+
def test_create_table_column_list_functions(self):
|
|
158
|
+
restricted = [
|
|
159
|
+
"CREATE TABLE t (a Int32, b String DEFAULT hostName()) ENGINE = MergeTree ORDER BY a",
|
|
160
|
+
"CREATE TABLE t (a Int32, b UInt8 MATERIALIZED sleep(1)) ENGINE = MergeTree ORDER BY a",
|
|
161
|
+
"CREATE TABLE t (a Int32, b String ALIAS hostName()) ENGINE = MergeTree ORDER BY a",
|
|
162
|
+
"CREATE TABLE t (a Int32, b String DEFAULT a IN (SELECT hostName())) ENGINE = MergeTree ORDER BY a",
|
|
163
|
+
"CREATE TABLE t (a Int32, d Date, b Int32 TTL d + toIntervalDay(toUInt8(sleep(1)))) ENGINE = MergeTree ORDER BY a",
|
|
164
|
+
"CREATE TABLE t (a Int32 CODEC(ZSTD(toUInt64(hostName())))) ENGINE = MergeTree ORDER BY a",
|
|
165
|
+
"CREATE TABLE t (a Int32, INDEX i hostName() TYPE minmax) ENGINE = MergeTree ORDER BY a",
|
|
166
|
+
]
|
|
167
|
+
for q in restricted:
|
|
168
|
+
with self.subTest(q=q), self.assertRaisesRegex(ValueError, "Usage of function .* is restricted"):
|
|
169
|
+
query.check_valid_write_query(q)
|
|
170
|
+
|
|
171
|
+
with self.assertRaisesRegex(ValueError, "CREATE TABLE: Unsupported subquery: in INDEX declaration"):
|
|
172
|
+
query.check_valid_write_query(
|
|
173
|
+
"CREATE TABLE t (a Int32, INDEX i a IN (SELECT 1 FROM system.tables) TYPE minmax) ENGINE = MergeTree ORDER BY a"
|
|
174
|
+
)
|
|
175
|
+
with self.assertRaisesRegex(ValueError, "CREATE TABLE: Unsupported function dictGetUInt8: in column TTL declaration"):
|
|
176
|
+
query.check_valid_write_query(
|
|
177
|
+
"CREATE TABLE t (a Int32, d Date, b Int32 TTL d + toIntervalDay(dictGetUInt8('d', 'x', a))) ENGINE = MergeTree ORDER BY a"
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
for q in [
|
|
181
|
+
"CREATE TABLE t (a Int32, b String DEFAULT dictGetString('d', 'x', a)) ENGINE = MergeTree ORDER BY a",
|
|
182
|
+
"CREATE TABLE t (a Nullable(Int32) CODEC(Delta, ZSTD(3)), b LowCardinality(String) DEFAULT toString(a)) ENGINE = MergeTree ORDER BY tuple()",
|
|
183
|
+
"CREATE TABLE t (a Int32, d Date, b Int32 TTL d + INTERVAL 1 DAY, INDEX i a * 2 TYPE bloom_filter(0.01) GRANULARITY 1) ENGINE = MergeTree ORDER BY a",
|
|
184
|
+
]:
|
|
185
|
+
with self.subTest(q=q):
|
|
186
|
+
query.check_valid_write_query(q)
|
|
187
|
+
|
|
157
188
|
def test_create_table_with_subqueries_in_alias_definition__is_ok(self):
|
|
158
189
|
q = """
|
|
159
190
|
CREATE TABLE visits4
|
|
@@ -263,6 +294,56 @@ class TestCreateTable(unittest.TestCase):
|
|
|
263
294
|
ORDER BY id
|
|
264
295
|
""")
|
|
265
296
|
|
|
297
|
+
def test_create_table_with_apply(self):
|
|
298
|
+
restricted = [
|
|
299
|
+
"CREATE TABLE t (a Int8, PROJECTION p (SELECT * APPLY(x -> hostName()))) ENGINE = MergeTree ORDER BY a",
|
|
300
|
+
"CREATE TABLE t (a Int8, PROJECTION p (SELECT * APPLY(sleepEachRow))) ENGINE = MergeTree ORDER BY a",
|
|
301
|
+
"CREATE TABLE t (a Int8) ENGINE = MergeTree ORDER BY tuple(* APPLY(x -> hostName()))",
|
|
302
|
+
]
|
|
303
|
+
for q in restricted:
|
|
304
|
+
with self.subTest(q=q), self.assertRaisesRegex(ValueError, "Usage of function .* is restricted"):
|
|
305
|
+
query.check_valid_write_query(q)
|
|
306
|
+
|
|
307
|
+
subqueries = [
|
|
308
|
+
"CREATE TABLE t (a Int8) ENGINE = MergeTree ORDER BY tuple(* APPLY(x -> (SELECT 1 FROM system.tables)))",
|
|
309
|
+
"CREATE TABLE t (a Int8) ENGINE = MergeTree ORDER BY tuple(* APPLY(x -> x IN (SELECT 1 FROM system.tables)))",
|
|
310
|
+
]
|
|
311
|
+
for q in subqueries:
|
|
312
|
+
with self.subTest(q=q), self.assertRaisesRegex(ValueError, "CREATE TABLE: Unsupported subquery: in ORDER BY declaration"):
|
|
313
|
+
query.check_valid_write_query(q)
|
|
314
|
+
|
|
315
|
+
with self.assertRaisesRegex(ValueError, "CREATE TABLE: Unsupported function dictGetString: in ORDER BY declaration"):
|
|
316
|
+
query.check_valid_write_query("CREATE TABLE t (a Int8) ENGINE = MergeTree ORDER BY tuple(COLUMNS('a') APPLY(dictGetString))")
|
|
317
|
+
|
|
318
|
+
def test_create_table_with_ttl_group_by(self):
|
|
319
|
+
restricted = [
|
|
320
|
+
"CREATE TABLE t (a Int32, d Date) ENGINE = MergeTree ORDER BY a TTL d GROUP BY a SET a = toInt32OrZero(hostName())",
|
|
321
|
+
"CREATE TABLE t (a Int32, d Date) ENGINE = MergeTree ORDER BY a TTL d GROUP BY a SET a = toInt32(sleep(3))",
|
|
322
|
+
]
|
|
323
|
+
for q in restricted:
|
|
324
|
+
with self.subTest(q=q), self.assertRaisesRegex(ValueError, "Usage of function .* is restricted"):
|
|
325
|
+
query.check_valid_write_query(q)
|
|
326
|
+
|
|
327
|
+
query.check_valid_write_query(
|
|
328
|
+
"CREATE TABLE t (a Int32, b Int32, d Date) ENGINE = MergeTree ORDER BY a TTL d GROUP BY a SET b = max(b)"
|
|
329
|
+
)
|
|
330
|
+
query.check_valid_write_query(
|
|
331
|
+
"CREATE TABLE t (a Int32, d Date) ENGINE = MergeTree ORDER BY a TTL d RECOMPRESS CODEC(ZSTD(12))"
|
|
332
|
+
)
|
|
333
|
+
query.check_valid_write_query(
|
|
334
|
+
"CREATE TABLE t (a Int32, d Date) ENGINE = MergeTree ORDER BY a TTL d RECOMPRESS CODEC(Delta, LZ4)"
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
def test_create_table_with_ttl_recompress_codec_arguments(self):
|
|
338
|
+
with self.assertRaisesRegex(ValueError, "Usage of function .* is restricted"):
|
|
339
|
+
query.check_valid_write_query(
|
|
340
|
+
"CREATE TABLE t (a Int32, d Date) ENGINE = MergeTree ORDER BY a TTL d RECOMPRESS CODEC(ZSTD(toUInt64(hostName())))"
|
|
341
|
+
)
|
|
342
|
+
with self.assertRaisesRegex(ValueError, "CREATE TABLE: Unsupported subquery: in TTL declaration"):
|
|
343
|
+
query.check_valid_write_query(
|
|
344
|
+
"CREATE TABLE t (a Int32, d Date) ENGINE = MergeTree ORDER BY a TTL d RECOMPRESS CODEC(ZSTD((SELECT 1 FROM system.tables)))"
|
|
345
|
+
)
|
|
346
|
+
|
|
266
347
|
def test_create_table_with_join_engine_is_forbidden(self):
|
|
267
348
|
with self.assertRaisesRegex(ValueError, "Creation of tables with ENGINE Join is not supported"):
|
|
268
349
|
query.check_valid_write_query("""
|
|
@@ -100,6 +100,31 @@ class TestReplaceTables(unittest.TestCase):
|
|
|
100
100
|
},
|
|
101
101
|
"SELECT * FROM database.t_01010101 AS t WHERE (c1, c2) IN database.t_02020202",
|
|
102
102
|
),
|
|
103
|
+
(
|
|
104
|
+
"SELECT * APPLY(x -> (SELECT count() FROM tt)) FROM (SELECT 1 AS a)",
|
|
105
|
+
{("", "tt"): ("", "(select a from table2 where a > 1)")},
|
|
106
|
+
"SELECT * APPLY(x -> (SELECT count() FROM (select a from table2 where a > 1) AS tt)) FROM (SELECT 1 AS a)",
|
|
107
|
+
),
|
|
108
|
+
(
|
|
109
|
+
"SELECT * APPLY(x -> x IN (SELECT a FROM tt)) FROM (SELECT 1 AS a)",
|
|
110
|
+
{("", "tt"): ("database", "t_01010101")},
|
|
111
|
+
"SELECT * APPLY(x -> x IN (SELECT a FROM database.t_01010101 AS tt)) FROM (SELECT 1 AS a)",
|
|
112
|
+
),
|
|
113
|
+
(
|
|
114
|
+
"SELECT * APPLY(x -> x IN tt) FROM (SELECT 1 AS a)",
|
|
115
|
+
{("", "tt"): ("database", "t_01010101")},
|
|
116
|
+
"SELECT * APPLY(x -> x IN database.t_01010101) FROM (SELECT 1 AS a)",
|
|
117
|
+
),
|
|
118
|
+
(
|
|
119
|
+
"SELECT sum(a) OVER (PARTITION BY (SELECT count() FROM tt)) FROM (SELECT 1 AS a)",
|
|
120
|
+
{("", "tt"): ("database", "t_01010101")},
|
|
121
|
+
"SELECT sum(a) OVER (PARTITION BY (SELECT count() FROM database.t_01010101 AS tt)) FROM (SELECT 1 AS a)",
|
|
122
|
+
),
|
|
123
|
+
(
|
|
124
|
+
"SELECT sum(a) OVER w FROM (SELECT 1 AS a) WINDOW w AS (PARTITION BY a IN (SELECT a FROM tt))",
|
|
125
|
+
{("", "tt"): ("database", "t_01010101")},
|
|
126
|
+
"SELECT sum(a) OVER w FROM (SELECT 1 AS a) WINDOW w AS (PARTITION BY a IN (SELECT a FROM database.t_01010101 AS tt))",
|
|
127
|
+
),
|
|
103
128
|
]
|
|
104
129
|
|
|
105
130
|
def test_asterisks_no_database(self):
|
|
@@ -1017,6 +1042,37 @@ class TestDisabledFunctions(unittest.TestCase):
|
|
|
1017
1042
|
):
|
|
1018
1043
|
chquery.replace_tables(q, replacements)
|
|
1019
1044
|
|
|
1045
|
+
def test_blocked_function_in_apply(self):
|
|
1046
|
+
queries = [
|
|
1047
|
+
"SELECT * APPLY(sleep) FROM (SELECT 2 AS a)",
|
|
1048
|
+
"SELECT * APPLY(x -> hostName()) FROM (SELECT 1 AS a)",
|
|
1049
|
+
"SELECT * APPLY(filesystemCapacity) FROM (SELECT 'default' AS a)",
|
|
1050
|
+
"SELECT COLUMNS('a') APPLY(x -> sleep(x)) FROM (SELECT 1 AS a)",
|
|
1051
|
+
"SELECT t.* APPLY(x -> toInt64(currentUser())) FROM (SELECT 1 AS a) AS t",
|
|
1052
|
+
]
|
|
1053
|
+
for q in queries:
|
|
1054
|
+
with self.assertRaisesRegex(ValueError, "DB::Exception: Usage of function .* is restricted"):
|
|
1055
|
+
chquery.replace_tables(q, {})
|
|
1056
|
+
|
|
1057
|
+
def test_allowed_function_in_apply(self):
|
|
1058
|
+
for q in [
|
|
1059
|
+
"SELECT * APPLY(sum) FROM (SELECT 2 AS a)",
|
|
1060
|
+
"SELECT * APPLY(quantile(0.9)) FROM (SELECT 2 AS a)",
|
|
1061
|
+
"SELECT * APPLY(x -> toString(x)) FROM (SELECT 2 AS a)",
|
|
1062
|
+
]:
|
|
1063
|
+
chquery.replace_tables(q, {})
|
|
1064
|
+
|
|
1065
|
+
def test_blocked_function_in_window(self):
|
|
1066
|
+
queries = [
|
|
1067
|
+
"SELECT sum(a) OVER (PARTITION BY sleep(1)) FROM (SELECT 1 AS a)",
|
|
1068
|
+
"SELECT sum(a) OVER (ORDER BY hostName()) FROM (SELECT 1 AS a)",
|
|
1069
|
+
"SELECT sum(a) OVER (ORDER BY a ROWS BETWEEN toUInt64(sleep(1)) PRECEDING AND CURRENT ROW) FROM (SELECT 1 AS a)",
|
|
1070
|
+
"SELECT sum(a) OVER w FROM (SELECT 1 AS a) WINDOW w AS (PARTITION BY sleep(1))",
|
|
1071
|
+
]
|
|
1072
|
+
for q in queries:
|
|
1073
|
+
with self.subTest(q=q), self.assertRaisesRegex(ValueError, "DB::Exception: Usage of function .* is restricted"):
|
|
1074
|
+
chquery.replace_tables(q, {})
|
|
1075
|
+
|
|
1020
1076
|
def test_sleep_in_replacements(self):
|
|
1021
1077
|
sql = "SELECT * FROM a, a"
|
|
1022
1078
|
replacement = {
|
|
@@ -27,6 +27,14 @@ class TestTables(unittest.TestCase):
|
|
|
27
27
|
('SELECT * FROM t WHERE event_date IN system.query_log', [('', 't', ''), ('system', 'query_log', '')]),
|
|
28
28
|
('SELECT * FROM t WHERE event_date GLOBAL NOT IN system.query_log', [('', 't', ''), ('system', 'query_log', '')]),
|
|
29
29
|
('SELECT * FROM t WHERE event_date IN (Select * FROM system.query_log)', [('', 't', ''), ('system', 'query_log', '')]),
|
|
30
|
+
('SELECT * APPLY(x -> (SELECT count() FROM system.trace_log)) FROM (SELECT 1 AS a)', [('system', 'trace_log', '')]),
|
|
31
|
+
('SELECT * APPLY(x -> x IN (SELECT count() FROM system.tables)) FROM (SELECT 1 AS a)', [('system', 'tables', '')]),
|
|
32
|
+
('SELECT * APPLY(x -> x IN system.tables) FROM (SELECT 1 AS a)', [('system', 'tables', '')]),
|
|
33
|
+
('SELECT COLUMNS(\'a\') APPLY(x -> (SELECT max(b) FROM t2)) FROM t', [('', 't', ''), ('', 't2', '')]),
|
|
34
|
+
('SELECT * APPLY(x -> (WITH c AS (SELECT b FROM t) SELECT count() FROM c)) FROM (SELECT 1 AS a)', [('', 't', '')]),
|
|
35
|
+
('SELECT sum(a) OVER (PARTITION BY (SELECT count() FROM system.trace_log)) FROM (SELECT 1 AS a)', [('system', 'trace_log', '')]),
|
|
36
|
+
('SELECT sum(a) OVER (ORDER BY a IN system.tables) FROM (SELECT 1 AS a)', [('system', 'tables', '')]),
|
|
37
|
+
('SELECT sum(a) OVER w FROM (SELECT 1 AS a) WINDOW w AS (PARTITION BY (SELECT count() FROM system.trace_log))', [('system', 'trace_log', '')]),
|
|
30
38
|
]
|
|
31
39
|
|
|
32
40
|
def test_json_all_paths_is_allowed(self):
|
|
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_toolset-2.7.4 → tinybird_toolset-2.8.0}/src/tinybird_toolset.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/src/tinybird_toolset.egg-info/requires.txt
RENAMED
|
File without changes
|
{tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/src/tinybird_toolset.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
{tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_check_ttl_partition_compatibility.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_get_columns_from_create_query.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tinybird_toolset-2.7.4 → tinybird_toolset-2.8.0}/tests/test_replace_tables_backward_compat.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|