tinybird-toolset 2.7.1__tar.gz → 2.7.4__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.1/src/tinybird_toolset.egg-info → tinybird_toolset-2.7.4}/PKG-INFO +1 -1
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/conf.py +46 -63
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/setup.py +1 -1
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4/src/tinybird_toolset.egg-info}/PKG-INFO +1 -1
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/tests/test_replace_tables.py +56 -1
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/tests/test_rewrite_aggregation_states.py +11 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/tests/test_tables.py +25 -1
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/LICENSE +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/MANIFEST.in +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/README.md +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/setup.cfg +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/src/chtoolset/__init__.py +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/src/chtoolset/query.py +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/src/tinybird_toolset.egg-info/SOURCES.txt +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/src/tinybird_toolset.egg-info/dependency_links.txt +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/src/tinybird_toolset.egg-info/requires.txt +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/src/tinybird_toolset.egg-info/top_level.txt +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/tests/test_check_compatible_types.py +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/tests/test_check_ttl_partition_compatibility.py +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/tests/test_check_write_query.py +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/tests/test_chquery.py +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/tests/test_convert_to_row_binary.py +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/tests/test_explain_ast.py +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/tests/test_get_columns_from_create_query.py +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/tests/test_get_left_table.py +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/tests/test_internal_cache.py +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/tests/test_normalize_query_keep_names.py +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/tests/test_normalize_table_column.py +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/tests/test_parse_create_materialized_view_target_table.py +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/tests/test_replace_tables_backward_compat.py +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/tests/test_validate_partition_key.py +0 -0
- {tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/tests/test_validate_ttl.py +0 -0
|
@@ -90,6 +90,46 @@ def apply_patch(patch_path):
|
|
|
90
90
|
f"=== stderr ===\n\n{stderr_buffer.getvalue()}")
|
|
91
91
|
|
|
92
92
|
|
|
93
|
+
def apply_patches():
|
|
94
|
+
"""Apply all patches needed on the ClickHouse tree. Idempotent."""
|
|
95
|
+
# Unwind with external code leads to crashes
|
|
96
|
+
apply_patch("patches/unwind.patch")
|
|
97
|
+
|
|
98
|
+
# This patch is used to make it possible to use valgrind with the module
|
|
99
|
+
# see https://jira.mongodb.org/browse/SERVER-25771
|
|
100
|
+
apply_patch("patches/boost_flags.patch")
|
|
101
|
+
|
|
102
|
+
# Be able to set our flags in the build (PIC)
|
|
103
|
+
apply_patch("patches/Preload.patch")
|
|
104
|
+
|
|
105
|
+
# This is only for performance.
|
|
106
|
+
# Avoids calling getTreeHash() which is slow
|
|
107
|
+
# Might change the output of the query since it won't replace same subqueries with the alias
|
|
108
|
+
# This is ok as long as the subquery isn't super long, but it should be ok since in our case that would
|
|
109
|
+
# mean the query was already super long
|
|
110
|
+
apply_patch("patches/ASTWithAlias_perf.patch")
|
|
111
|
+
|
|
112
|
+
# Emit standard SQL TRIM(BOTH/LEADING/TRAILING ... FROM ...) syntax for 2-arg
|
|
113
|
+
# trimBoth/trimLeft/trimRight calls, so the output is compatible with CH < 25.2
|
|
114
|
+
apply_patch("patches/trim_format.patch")
|
|
115
|
+
|
|
116
|
+
# Builds the functions needed by validate_ttl into libclickhouse_ttl_functions.a,
|
|
117
|
+
# which is linked with --whole-archive/-force_load (see extra_libs).
|
|
118
|
+
# NOTE: after editing this patch (or any other), the early-return above skips the
|
|
119
|
+
# ClickHouse build; delete ch_build/src/Functions/libclickhouse_ttl_functions.a
|
|
120
|
+
# (or the whole ch_build) to force it to run again.
|
|
121
|
+
apply_patch("patches/dbmsfunctions.patch")
|
|
122
|
+
|
|
123
|
+
# Range-check narrow-integer Field inserts so JSON/Dynamic paths widen instead of
|
|
124
|
+
# silently wrapping (1944 -> -104). Backport of the ColumnVector::tryInsert fix;
|
|
125
|
+
# remove once the fix lands in the pinned ClickHouse submodule.
|
|
126
|
+
apply_patch("patches/ColumnVectorTryInsert.patch")
|
|
127
|
+
|
|
128
|
+
# Keep TTL result validation compatible with ClickHouse versions before 25.8:
|
|
129
|
+
# DateTime64 and Date32 results must remain rejected until all servers migrate.
|
|
130
|
+
apply_patch("patches/ttl_result_type_compat.patch")
|
|
131
|
+
|
|
132
|
+
|
|
93
133
|
class ClickHouseBuildExt(build_ext):
|
|
94
134
|
def run(self):
|
|
95
135
|
|
|
@@ -103,69 +143,7 @@ class ClickHouseBuildExt(build_ext):
|
|
|
103
143
|
'src/Functions/libclickhouse_ttl_functions.a')):
|
|
104
144
|
return
|
|
105
145
|
|
|
106
|
-
|
|
107
|
-
apply_patch("patches/createJSON.patch")
|
|
108
|
-
|
|
109
|
-
# Disable analyzer by default
|
|
110
|
-
apply_patch("patches/disable_analyzer.patch")
|
|
111
|
-
|
|
112
|
-
# Unwind with external code leads to crashes
|
|
113
|
-
apply_patch("patches/unwind.patch")
|
|
114
|
-
|
|
115
|
-
# Sets timezone to UTC manually and avoids reading system files
|
|
116
|
-
apply_patch("patches/timezone.patch")
|
|
117
|
-
|
|
118
|
-
# Easier access to ASTIdentifier private data
|
|
119
|
-
apply_patch("patches/ASTIdentifier.patch")
|
|
120
|
-
|
|
121
|
-
# Easier access to AggregateFunctionFactory private data
|
|
122
|
-
apply_patch("patches/AggregateFunctionFactory.patch")
|
|
123
|
-
|
|
124
|
-
# This patch is used to make it possible to use valgrind with the module
|
|
125
|
-
# see https://jira.mongodb.org/browse/SERVER-25771
|
|
126
|
-
apply_patch("patches/boost_flags.patch")
|
|
127
|
-
|
|
128
|
-
# Be able to set our flags in the build (PIC)
|
|
129
|
-
apply_patch("patches/Preload.patch")
|
|
130
|
-
|
|
131
|
-
# This is only for performance.
|
|
132
|
-
# Avoids calling getTreeHash() which is slow
|
|
133
|
-
# Might change the output of the query since it won't replace same subqueries with the alias
|
|
134
|
-
# This is ok as long as the subquery isn't super long, but it should be ok since in our case that would
|
|
135
|
-
# mean the query was already super long
|
|
136
|
-
apply_patch("patches/ASTWithAlias_perf.patch")
|
|
137
|
-
|
|
138
|
-
# Emit standard SQL TRIM(BOTH/LEADING/TRAILING ... FROM ...) syntax for 2-arg
|
|
139
|
-
# trimBoth/trimLeft/trimRight calls, so the output is compatible with CH < 25.2
|
|
140
|
-
apply_patch("patches/trim_format.patch")
|
|
141
|
-
|
|
142
|
-
# Removes TSA warnings (we don't compile with a libc++ with annotations)
|
|
143
|
-
apply_patch("patches/tsa.patch")
|
|
144
|
-
|
|
145
|
-
# Builds the functions needed by validate_ttl into libclickhouse_ttl_functions.a,
|
|
146
|
-
# which is linked with --whole-archive/-force_load (see extra_libs).
|
|
147
|
-
# NOTE: after editing this patch (or any other), the early-return above skips the
|
|
148
|
-
# ClickHouse build; delete ch_build/src/Functions/libclickhouse_ttl_functions.a
|
|
149
|
-
# (or the whole ch_build) to force it to run again.
|
|
150
|
-
apply_patch("patches/dbmsfunctions.patch")
|
|
151
|
-
|
|
152
|
-
# Range-check narrow-integer Field inserts so JSON/Dynamic paths widen instead of
|
|
153
|
-
# silently wrapping (1944 -> -104). Backport of the ColumnVector::tryInsert fix;
|
|
154
|
-
# remove once the fix lands in the pinned ClickHouse submodule.
|
|
155
|
-
apply_patch("patches/ColumnVectorTryInsert.patch")
|
|
156
|
-
|
|
157
|
-
# Keep TTL result validation compatible with ClickHouse versions before 25.8:
|
|
158
|
-
# DateTime64 and Date32 results must remain rejected until all servers migrate.
|
|
159
|
-
apply_patch("patches/ttl_result_type_compat.patch")
|
|
160
|
-
|
|
161
|
-
if sys.platform == 'darwin':
|
|
162
|
-
# We disable whole_archive options destined for AppleClang, which is unsupported but keeps being a PITA
|
|
163
|
-
apply_patch("patches/darwin.patch")
|
|
164
|
-
|
|
165
|
-
# Problem with offsetof macro definition
|
|
166
|
-
# NOTE: offsetof.patch is no longer needed for ClickHouse 25.3+ as the changes are already upstream
|
|
167
|
-
# apply_patch("patches/offsetof.patch")
|
|
168
|
-
|
|
146
|
+
apply_patches()
|
|
169
147
|
|
|
170
148
|
cmake_cmd = os.environ.get('CMAKE_BIN', 'cmake')
|
|
171
149
|
try:
|
|
@@ -499,3 +477,8 @@ def requirements_from_file(path):
|
|
|
499
477
|
for line in Path(path).read_text().split("\n")
|
|
500
478
|
if not line.startswith(('"', "#", "-", "git+"))
|
|
501
479
|
]
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
if __name__ == '__main__':
|
|
483
|
+
# Used by `make apply-patches` (e.g. clang-tidy needs the patched ClickHouse sources)
|
|
484
|
+
apply_patches()
|
|
@@ -687,6 +687,61 @@ class TestReplaceTables(unittest.TestCase):
|
|
|
687
687
|
replaced = chquery.replace_tables(sql, replacements, default_database="default")
|
|
688
688
|
self.assertEqual(replaced, chquery.format(expected_query))
|
|
689
689
|
|
|
690
|
+
def test_explain_query(self):
|
|
691
|
+
sql = "EXPLAIN SELECT table.col FROM table"
|
|
692
|
+
replacements = {("default", "table"): ("d_012345", "t_wadus")}
|
|
693
|
+
expected_query = "EXPLAIN SELECT t_wadus.col FROM d_012345.t_wadus as table"
|
|
694
|
+
replaced = chquery.replace_tables(sql, replacements, default_database="default")
|
|
695
|
+
self.assertEqual(replaced, chquery.format(expected_query))
|
|
696
|
+
|
|
697
|
+
def test_explain_query_with_options(self):
|
|
698
|
+
replacements = {("default", "table"): ("d_012345", "t_wadus")}
|
|
699
|
+
for sql in [
|
|
700
|
+
"EXPLAIN PLAN actions=1 SELECT table.col FROM table",
|
|
701
|
+
"EXPLAIN PIPELINE header=1 SELECT table.col FROM table",
|
|
702
|
+
"EXPLAIN QUERY TREE passes=1 SELECT table.col FROM table",
|
|
703
|
+
"EXPLAIN SYNTAX oneline=1 SELECT table.col FROM table",
|
|
704
|
+
"EXPLAIN AST SELECT table.col FROM table",
|
|
705
|
+
"EXPLAIN ESTIMATE SELECT table.col FROM table",
|
|
706
|
+
]:
|
|
707
|
+
expected_query = sql.replace("FROM table", "FROM d_012345.t_wadus as table").replace("table.col", "t_wadus.col")
|
|
708
|
+
replaced = chquery.replace_tables(sql, replacements, default_database="default")
|
|
709
|
+
self.assertEqual(replaced, chquery.format(expected_query))
|
|
710
|
+
|
|
711
|
+
def test_explain_query_validates_the_explained_query(self):
|
|
712
|
+
explained = [
|
|
713
|
+
"SELECT * FROM url('http://127.0.0.1:18765/x.csv', 'CSV')",
|
|
714
|
+
"SELECT * FROM file('/etc/passwd', 'CSV', 'a String')",
|
|
715
|
+
"SELECT * FROM view(SELECT 1)",
|
|
716
|
+
]
|
|
717
|
+
for explain in ["EXPLAIN", "EXPLAIN PLAN actions=1", "EXPLAIN PIPELINE header=1", "EXPLAIN QUERY TREE passes=1", "EXPLAIN SYNTAX oneline=1", "EXPLAIN AST", "EXPLAIN ESTIMATE"]:
|
|
718
|
+
for query in explained:
|
|
719
|
+
with self.assertRaisesRegex(ValueError, "is restricted"):
|
|
720
|
+
chquery.replace_tables(f"{explain} {query}", {("default", "t"): ("d_1", "t_1")})
|
|
721
|
+
|
|
722
|
+
def test_explain_query_does_not_leak_replacements_through_the_cache(self):
|
|
723
|
+
for sql in ["EXPLAIN SELECT * FROM events", "EXPLAIN PLAN actions=1 SELECT * FROM events"]:
|
|
724
|
+
replaced_a = chquery.replace_tables(sql, {("default", "events"): ("db_a", "events_a")}, default_database="default")
|
|
725
|
+
replaced_b = chquery.replace_tables(sql, {("default", "events"): ("db_b", "events_b")}, default_database="default")
|
|
726
|
+
self.assertIn("db_a.events_a", replaced_a)
|
|
727
|
+
self.assertNotIn("db_b", replaced_a)
|
|
728
|
+
self.assertIn("db_b.events_b", replaced_b)
|
|
729
|
+
self.assertNotIn("db_a", replaced_b)
|
|
730
|
+
|
|
731
|
+
def test_explain_query_throws_with_unsupported_explained_query(self):
|
|
732
|
+
queries = [
|
|
733
|
+
"EXPLAIN INSERT INTO test.table VALUES (1,2,3)",
|
|
734
|
+
"EXPLAIN INSERT INTO test.table SELECT * FROM other",
|
|
735
|
+
"EXPLAIN CREATE TABLE table_test (`index` String) ENGINE = MergeTree ORDER BY index",
|
|
736
|
+
"EXPLAIN TABLE OVERRIDE mysql('127.0.0.1:3306', 'db', 't', 'u', 'p') PARTITION BY toYYYYMM(d)",
|
|
737
|
+
"EXPLAIN CURRENT TRANSACTION",
|
|
738
|
+
"EXPLAIN AST DROP TABLE test",
|
|
739
|
+
"EXPLAIN AST INSERT INTO test.table VALUES (1,2,3)",
|
|
740
|
+
]
|
|
741
|
+
for q in queries:
|
|
742
|
+
with self.assertRaisesRegex(ValueError, 'EXPLAIN is only supported for SELECT queries'):
|
|
743
|
+
chquery.replace_tables(q, {("default", "table"): ("d_012345", "t_wadus")})
|
|
744
|
+
|
|
690
745
|
def test_replace_of_table_function_throws(self):
|
|
691
746
|
sql = "SELECT * FROM numbers(10)"
|
|
692
747
|
replacement = {("", "", "numbers"): ("", "", "one")}
|
|
@@ -763,7 +818,7 @@ class TestReplaceTables(unittest.TestCase):
|
|
|
763
818
|
replacement = {("default", "test_pipe_1"): ("", "something_else")}
|
|
764
819
|
for q in queries:
|
|
765
820
|
with self.assertRaisesRegex(
|
|
766
|
-
ValueError, "Only SELECT
|
|
821
|
+
ValueError, "Only SELECT, DESCRIBE and EXPLAIN queries are supported. Got: .*"
|
|
767
822
|
):
|
|
768
823
|
chquery.replace_tables(q, replacement)
|
|
769
824
|
|
|
@@ -148,3 +148,14 @@ class TestGetLeftTable(unittest.TestCase):
|
|
|
148
148
|
sql = "WITH t as (select value from table) SELECT avg(value) FROM t"
|
|
149
149
|
expected = "WITH t as (select value from table) SELECT avgState(value) FROM t"
|
|
150
150
|
self.assertEqual(chquery.format(chquery.rewrite_aggregation_states(sql)), chquery.format(expected))
|
|
151
|
+
|
|
152
|
+
def test_throws_with_explain_and_describe(self):
|
|
153
|
+
for sql in [
|
|
154
|
+
"EXPLAIN SELECT avg(value) FROM table",
|
|
155
|
+
"EXPLAIN AST SELECT avg(value) FROM table",
|
|
156
|
+
"EXPLAIN PIPELINE SELECT avg(value) FROM table",
|
|
157
|
+
"EXPLAIN ESTIMATE SELECT avg(value) FROM table",
|
|
158
|
+
"DESCRIBE TABLE table",
|
|
159
|
+
]:
|
|
160
|
+
with self.assertRaisesRegex(ValueError, "Only SELECT queries are supported"):
|
|
161
|
+
chquery.rewrite_aggregation_states(sql)
|
|
@@ -254,6 +254,30 @@ SELECT *
|
|
|
254
254
|
"""
|
|
255
255
|
self.assertEqual(chquery.tables(sql), [('', 'table', '')])
|
|
256
256
|
|
|
257
|
+
def test_explain_query(self):
|
|
258
|
+
for kind in ["", "PLAN", "PLAN indexes=1", "actions=1", "AST", "SYNTAX", "QUERY TREE", "PIPELINE", "ESTIMATE"]:
|
|
259
|
+
sql = f"EXPLAIN {kind} SELECT table.col FROM db.table JOIN other ON table.id = other.id"
|
|
260
|
+
self.assertEqual(sorted(chquery.tables(sql)),
|
|
261
|
+
[('', 'other', ''), ('db', 'table', '')], sql)
|
|
262
|
+
|
|
263
|
+
def test_explain_query_throws_with_invalid_inner_function(self):
|
|
264
|
+
with self.assertRaisesRegex(ValueError, 'DB::Exception: Unknown function doesNotExist'):
|
|
265
|
+
chquery.tables("EXPLAIN SELECT doesNotExist(number) FROM numbers(100)")
|
|
266
|
+
|
|
267
|
+
def test_explain_query_throws_with_unsupported_explained_query(self):
|
|
268
|
+
queries = [
|
|
269
|
+
"EXPLAIN INSERT INTO test.table VALUES (1,2,3)",
|
|
270
|
+
"EXPLAIN INSERT INTO test.table SELECT * FROM other",
|
|
271
|
+
"EXPLAIN CREATE TABLE table_test (`index` String) ENGINE = MergeTree ORDER BY index",
|
|
272
|
+
"EXPLAIN TABLE OVERRIDE mysql('127.0.0.1:3306', 'db', 't', 'u', 'p') PARTITION BY toYYYYMM(d)",
|
|
273
|
+
"EXPLAIN CURRENT TRANSACTION",
|
|
274
|
+
"EXPLAIN AST DROP TABLE test",
|
|
275
|
+
"EXPLAIN AST INSERT INTO test.table VALUES (1,2,3)",
|
|
276
|
+
]
|
|
277
|
+
for q in queries:
|
|
278
|
+
with self.assertRaisesRegex(ValueError, 'EXPLAIN is only supported for SELECT queries'):
|
|
279
|
+
chquery.tables(q)
|
|
280
|
+
|
|
257
281
|
def test_throws_with_invalid_query_types(self):
|
|
258
282
|
queries = [
|
|
259
283
|
"INSERT INTO test.table VALUES (1,2,3)",
|
|
@@ -265,7 +289,7 @@ SELECT *
|
|
|
265
289
|
"DROP TABLE test"
|
|
266
290
|
]
|
|
267
291
|
for q in queries:
|
|
268
|
-
with self.assertRaisesRegex(ValueError, 'Only SELECT
|
|
292
|
+
with self.assertRaisesRegex(ValueError, 'Only SELECT, DESCRIBE and EXPLAIN queries are supported. Got: .*'):
|
|
269
293
|
chquery.tables(q)
|
|
270
294
|
|
|
271
295
|
def test_throws_with_invalid_functions(self):
|
|
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.1 → tinybird_toolset-2.7.4}/src/tinybird_toolset.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/src/tinybird_toolset.egg-info/requires.txt
RENAMED
|
File without changes
|
{tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/src/tinybird_toolset.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
{tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/tests/test_check_ttl_partition_compatibility.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tinybird_toolset-2.7.1 → tinybird_toolset-2.7.4}/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.1 → tinybird_toolset-2.7.4}/tests/test_replace_tables_backward_compat.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|