tinybird-toolset 2.6.4__tar.gz → 2.6.6__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.
Files changed (33) hide show
  1. {tinybird_toolset-2.6.4/src/tinybird_toolset.egg-info → tinybird_toolset-2.6.6}/PKG-INFO +1 -1
  2. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/setup.py +1 -1
  3. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6/src/tinybird_toolset.egg-info}/PKG-INFO +1 -1
  4. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/tests/test_check_write_query.py +29 -0
  5. tinybird_toolset-2.6.6/tests/test_validate_partition_key.py +222 -0
  6. tinybird_toolset-2.6.4/tests/test_validate_partition_key.py +0 -150
  7. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/LICENSE +0 -0
  8. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/MANIFEST.in +0 -0
  9. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/README.md +0 -0
  10. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/conf.py +0 -0
  11. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/setup.cfg +0 -0
  12. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/src/chtoolset/__init__.py +0 -0
  13. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/src/chtoolset/query.py +0 -0
  14. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/src/tinybird_toolset.egg-info/SOURCES.txt +0 -0
  15. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/src/tinybird_toolset.egg-info/dependency_links.txt +0 -0
  16. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/src/tinybird_toolset.egg-info/requires.txt +0 -0
  17. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/src/tinybird_toolset.egg-info/top_level.txt +0 -0
  18. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/tests/test_check_compatible_types.py +0 -0
  19. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/tests/test_check_ttl_partition_compatibility.py +0 -0
  20. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/tests/test_chquery.py +0 -0
  21. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/tests/test_convert_to_row_binary.py +0 -0
  22. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/tests/test_explain_ast.py +0 -0
  23. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/tests/test_get_columns_from_create_query.py +0 -0
  24. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/tests/test_get_left_table.py +0 -0
  25. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/tests/test_internal_cache.py +0 -0
  26. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/tests/test_normalize_query_keep_names.py +0 -0
  27. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/tests/test_normalize_table_column.py +0 -0
  28. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/tests/test_parse_create_materialized_view_target_table.py +0 -0
  29. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/tests/test_replace_tables.py +0 -0
  30. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/tests/test_replace_tables_backward_compat.py +0 -0
  31. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/tests/test_rewrite_aggregation_states.py +0 -0
  32. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/tests/test_tables.py +0 -0
  33. {tinybird_toolset-2.6.4 → tinybird_toolset-2.6.6}/tests/test_validate_ttl.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tinybird-toolset
3
- Version: 2.6.4
3
+ Version: 2.6.6
4
4
  Home-page: https://gitlab.com/tinybird/clickhouse-toolset
5
5
  Author: Tinybird.co
6
6
  Author-email: support@tinybird.co
@@ -1,7 +1,7 @@
1
1
  from setuptools import setup, Extension
2
2
 
3
3
  NAME = 'tinybird-toolset'
4
- VERSION = '2.6.4'
4
+ VERSION = '2.6.6'
5
5
 
6
6
  # Shared metadata for both the full (extension) build and the metadata-only
7
7
  # fallback below, so the two setup() calls can't drift apart.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tinybird-toolset
3
- Version: 2.6.4
3
+ Version: 2.6.6
4
4
  Home-page: https://gitlab.com/tinybird/clickhouse-toolset
5
5
  Author: Tinybird.co
6
6
  Author-email: support@tinybird.co
@@ -436,3 +436,32 @@ class TestCreateTable(unittest.TestCase):
436
436
  with self.assertRaisesRegex(ValueError, "Cannot parse input: expected 'eof' before: 'aaaa'"):
437
437
  q = "CREATE TABLE big_table (number Int64) ENGINE = MergeTree Order by tuple() Settings min_bytes_for_wide_part = 'aaaa'"
438
438
  query.check_valid_write_query(q)
439
+
440
+ def test_replicated_deduplication_window_up_to_default_is_ok(self):
441
+ for value in (0, 1000, 10000):
442
+ q = 'CREATE TABLE big_table (number Int64) ENGINE = MergeTree Order by tuple() ' \
443
+ f'SETTINGS replicated_deduplication_window = {value}'
444
+ self.assertEqual(query.format(query.check_valid_write_query(q)), query.format(q))
445
+
446
+ def test_replicated_deduplication_window_above_default_is_forbidden(self):
447
+ q = 'CREATE TABLE big_table (number Int64) ENGINE = MergeTree Order by tuple() ' \
448
+ 'SETTINGS replicated_deduplication_window = 10001'
449
+ error = "The value for 'replicated_deduplication_window' is too big \\(10001 > 10000\\). Contact .*"
450
+ with self.assertRaisesRegex(ValueError, error):
451
+ query.check_valid_write_query(q)
452
+
453
+ expected = 'CREATE TABLE big_table (number Int64) ENGINE = MergeTree Order by tuple()'
454
+ result = query.check_valid_write_query(q, clean_table_settings=True)
455
+ self.assertEqual(query.format(result), query.format(expected))
456
+
457
+ with self.assertRaisesRegex(ValueError, "Cannot parse input: expected 'eof' before: 'aaaa'"):
458
+ q = 'CREATE TABLE big_table (number Int64) ENGINE = MergeTree Order by tuple() ' \
459
+ "SETTINGS replicated_deduplication_window = 'aaaa'"
460
+ query.check_valid_write_query(q)
461
+
462
+ def test_replicated_deduplication_window_seconds_is_still_forbidden(self):
463
+ q = 'CREATE TABLE big_table (number Int64) ENGINE = MergeTree Order by tuple() ' \
464
+ 'SETTINGS replicated_deduplication_window_seconds = 60'
465
+ error = "Usage of setting 'replicated_deduplication_window_seconds' is restricted"
466
+ with self.assertRaisesRegex(ValueError, error):
467
+ query.check_valid_write_query(q)
@@ -0,0 +1,222 @@
1
+ import unittest
2
+ from chtoolset import query as chquery
3
+
4
+
5
+ class TestValidatePartitionKey(unittest.TestCase):
6
+ def test_valid_empty_partition_key(self):
7
+ self.assertIsNone(
8
+ chquery.validate_partition_key(
9
+ columns=[{"name": "ts", "type": "DateTime"}],
10
+ partition_key="",
11
+ )
12
+ )
13
+
14
+ def test_valid_hourly_partition_key(self):
15
+ # Hour is the floor - allowed.
16
+ self.assertIsNone(
17
+ chquery.validate_partition_key(
18
+ columns=[{"name": "ts", "type": "DateTime"}],
19
+ partition_key="toStartOfHour(ts)",
20
+ )
21
+ )
22
+
23
+ def test_valid_daily_partition_key(self):
24
+ self.assertIsNone(
25
+ chquery.validate_partition_key(
26
+ columns=[{"name": "ts", "type": "DateTime"}],
27
+ partition_key="toDate(ts)",
28
+ )
29
+ )
30
+
31
+ def test_valid_monthly_partition_key(self):
32
+ self.assertIsNone(
33
+ chquery.validate_partition_key(
34
+ columns=[{"name": "ts", "type": "DateTime"}],
35
+ partition_key="toYYYYMM(ts)",
36
+ )
37
+ )
38
+
39
+ def test_invalid_minute_partition_key(self):
40
+ err = chquery.validate_partition_key(
41
+ columns=[{"name": "ts", "type": "DateTime"}],
42
+ partition_key="toStartOfMinute(ts)",
43
+ )
44
+ self.assertEqual(
45
+ err,
46
+ "Partition key granularity (Minute) on column 'ts' is finer than hourly. This tends to create a very "
47
+ "large number of parts, which makes merges and queries expensive regardless of the table's TTL. Use "
48
+ "an hourly or coarser partition key.",
49
+ )
50
+
51
+ def test_invalid_second_partition_key(self):
52
+ err = chquery.validate_partition_key(
53
+ columns=[{"name": "ts", "type": "DateTime"}],
54
+ partition_key="toStartOfSecond(ts)",
55
+ )
56
+ self.assertEqual(
57
+ err,
58
+ "Partition key granularity (Second) on column 'ts' is finer than hourly. This tends to create a very "
59
+ "large number of parts, which makes merges and queries expensive regardless of the table's TTL. Use "
60
+ "an hourly or coarser partition key.",
61
+ )
62
+
63
+ def test_invalid_five_minute_partition_key(self):
64
+ err = chquery.validate_partition_key(
65
+ columns=[{"name": "ts", "type": "DateTime"}],
66
+ partition_key="toStartOfFiveMinutes(ts)",
67
+ )
68
+ self.assertEqual(
69
+ err,
70
+ "Partition key granularity (Minute) on column 'ts' is finer than hourly. This tends to create a very "
71
+ "large number of parts, which makes merges and queries expensive regardless of the table's TTL. Use "
72
+ "an hourly or coarser partition key.",
73
+ )
74
+
75
+ def test_invalid_ten_minute_partition_key(self):
76
+ err = chquery.validate_partition_key(
77
+ columns=[{"name": "ts", "type": "DateTime"}],
78
+ partition_key="toStartOfTenMinutes(ts)",
79
+ )
80
+ self.assertEqual(
81
+ err,
82
+ "Partition key granularity (Minute) on column 'ts' is finer than hourly. This tends to create a very "
83
+ "large number of parts, which makes merges and queries expensive regardless of the table's TTL. Use "
84
+ "an hourly or coarser partition key.",
85
+ )
86
+
87
+ def test_invalid_fifteen_minute_partition_key(self):
88
+ err = chquery.validate_partition_key(
89
+ columns=[{"name": "ts", "type": "DateTime"}],
90
+ partition_key="toStartOfFifteenMinutes(ts)",
91
+ )
92
+ self.assertEqual(
93
+ err,
94
+ "Partition key granularity (Minute) on column 'ts' is finer than hourly. This tends to create a very "
95
+ "large number of parts, which makes merges and queries expensive regardless of the table's TTL. Use "
96
+ "an hourly or coarser partition key.",
97
+ )
98
+
99
+ def test_invalid_five_minute_singular_alias_partition_key(self):
100
+ # toStartOfFiveMinute (singular) is a registered alias for toStartOfFiveMinutes.
101
+ err = chquery.validate_partition_key(
102
+ columns=[{"name": "ts", "type": "DateTime"}],
103
+ partition_key="toStartOfFiveMinute(ts)",
104
+ )
105
+ self.assertEqual(
106
+ err,
107
+ "Partition key granularity (Minute) on column 'ts' is finer than hourly. This tends to create a very "
108
+ "large number of parts, which makes merges and queries expensive regardless of the table's TTL. Use "
109
+ "an hourly or coarser partition key.",
110
+ )
111
+
112
+ def test_invalid_millisecond_partition_key(self):
113
+ err = chquery.validate_partition_key(
114
+ columns=[{"name": "ts", "type": "DateTime64(3)"}],
115
+ partition_key="toStartOfMillisecond(ts)",
116
+ )
117
+ self.assertEqual(
118
+ err,
119
+ "Partition key granularity (Millisecond) on column 'ts' is finer than hourly. This tends to create a "
120
+ "very large number of parts, which makes merges and queries expensive regardless of the table's TTL. "
121
+ "Use an hourly or coarser partition key.",
122
+ )
123
+
124
+ def test_invalid_microsecond_partition_key(self):
125
+ err = chquery.validate_partition_key(
126
+ columns=[{"name": "ts", "type": "DateTime64(6)"}],
127
+ partition_key="toStartOfMicrosecond(ts)",
128
+ )
129
+ self.assertEqual(
130
+ err,
131
+ "Partition key granularity (Microsecond) on column 'ts' is finer than hourly. This tends to create a "
132
+ "very large number of parts, which makes merges and queries expensive regardless of the table's TTL. "
133
+ "Use an hourly or coarser partition key.",
134
+ )
135
+
136
+ def test_invalid_nanosecond_partition_key(self):
137
+ err = chquery.validate_partition_key(
138
+ columns=[{"name": "ts", "type": "DateTime64(9)"}],
139
+ partition_key="toStartOfNanosecond(ts)",
140
+ )
141
+ self.assertEqual(
142
+ err,
143
+ "Partition key granularity (Nanosecond) on column 'ts' is finer than hourly. This tends to create a "
144
+ "very large number of parts, which makes merges and queries expensive regardless of the table's TTL. "
145
+ "Use an hourly or coarser partition key.",
146
+ )
147
+
148
+ def test_invalid_yyyymmddhhmmss_partition_key(self):
149
+ # Packs the full date+time down to the second - no coarsening at all.
150
+ err = chquery.validate_partition_key(
151
+ columns=[{"name": "ts", "type": "DateTime"}],
152
+ partition_key="toYYYYMMDDhhmmss(ts)",
153
+ )
154
+ self.assertEqual(
155
+ err,
156
+ "Partition key granularity (Second) on column 'ts' is finer than hourly. This tends to create a very "
157
+ "large number of parts, which makes merges and queries expensive regardless of the table's TTL. Use "
158
+ "an hourly or coarser partition key.",
159
+ )
160
+
161
+ def test_valid_skipped_for_composite_partition_key(self):
162
+ self.assertIsNone(
163
+ chquery.validate_partition_key(
164
+ columns=[
165
+ {"name": "ts", "type": "DateTime"},
166
+ {"name": "k", "type": "String"},
167
+ ],
168
+ partition_key="toStartOfMinute(ts), k",
169
+ )
170
+ )
171
+
172
+ def test_valid_skipped_for_unrecognized_function(self):
173
+ self.assertIsNone(
174
+ chquery.validate_partition_key(
175
+ columns=[{"name": "ts", "type": "DateTime"}],
176
+ partition_key="intDiv(toUInt32(ts), 60)",
177
+ )
178
+ )
179
+
180
+ def test_valid_skipped_for_bare_column(self):
181
+ self.assertIsNone(
182
+ chquery.validate_partition_key(
183
+ columns=[{"name": "k", "type": "String"}],
184
+ partition_key="k",
185
+ )
186
+ )
187
+
188
+ def test_invalid_bare_datetime_partition_key(self):
189
+ err = chquery.validate_partition_key(
190
+ columns=[{"name": "ts", "type": "DateTime"}],
191
+ partition_key="ts",
192
+ )
193
+ self.assertEqual(
194
+ err,
195
+ "Partition key granularity (Second) on column 'ts' is finer than hourly. This tends to create a very "
196
+ "large number of parts, which makes merges and queries expensive regardless of the table's TTL. Use "
197
+ "an hourly or coarser partition key, e.g. toStartOfHour(ts), toYYYYMMDD(ts), or toYYYYMM(ts).",
198
+ )
199
+
200
+ def test_invalid_bare_datetime64_partition_key(self):
201
+ err = chquery.validate_partition_key(
202
+ columns=[{"name": "ts", "type": "DateTime64(3)"}],
203
+ partition_key="ts",
204
+ )
205
+ self.assertEqual(
206
+ err,
207
+ "Partition key granularity (Millisecond) on column 'ts' is finer than hourly. This tends to create a "
208
+ "very large number of parts, which makes merges and queries expensive regardless of the table's TTL. "
209
+ "Use an hourly or coarser partition key, e.g. toStartOfHour(ts), toYYYYMMDD(ts), or toYYYYMM(ts).",
210
+ )
211
+
212
+ def test_valid_skipped_for_bare_date_column(self):
213
+ self.assertIsNone(
214
+ chquery.validate_partition_key(
215
+ columns=[{"name": "d", "type": "Date"}],
216
+ partition_key="d",
217
+ )
218
+ )
219
+
220
+
221
+ if __name__ == "__main__":
222
+ unittest.main()
@@ -1,150 +0,0 @@
1
- import unittest
2
- from chtoolset import query as chquery
3
-
4
-
5
- class TestValidatePartitionKey(unittest.TestCase):
6
- def test_valid_empty_partition_key(self):
7
- self.assertIsNone(
8
- chquery.validate_partition_key(
9
- columns=[{"name": "ts", "type": "DateTime"}],
10
- partition_key="",
11
- )
12
- )
13
-
14
- def test_valid_hourly_partition_key(self):
15
- # Hour is the floor - allowed.
16
- self.assertIsNone(
17
- chquery.validate_partition_key(
18
- columns=[{"name": "ts", "type": "DateTime"}],
19
- partition_key="toStartOfHour(ts)",
20
- )
21
- )
22
-
23
- def test_valid_daily_partition_key(self):
24
- self.assertIsNone(
25
- chquery.validate_partition_key(
26
- columns=[{"name": "ts", "type": "DateTime"}],
27
- partition_key="toDate(ts)",
28
- )
29
- )
30
-
31
- def test_valid_monthly_partition_key(self):
32
- self.assertIsNone(
33
- chquery.validate_partition_key(
34
- columns=[{"name": "ts", "type": "DateTime"}],
35
- partition_key="toYYYYMM(ts)",
36
- )
37
- )
38
-
39
- def test_invalid_minute_partition_key(self):
40
- err = chquery.validate_partition_key(
41
- columns=[{"name": "ts", "type": "DateTime"}],
42
- partition_key="toStartOfMinute(ts)",
43
- )
44
- self.assertIsNotNone(err)
45
- self.assertIn("finer than hourly", err)
46
-
47
- def test_invalid_second_partition_key(self):
48
- err = chquery.validate_partition_key(
49
- columns=[{"name": "ts", "type": "DateTime"}],
50
- partition_key="toStartOfSecond(ts)",
51
- )
52
- self.assertIsNotNone(err)
53
- self.assertIn("finer than hourly", err)
54
-
55
- def test_invalid_five_minute_partition_key(self):
56
- err = chquery.validate_partition_key(
57
- columns=[{"name": "ts", "type": "DateTime"}],
58
- partition_key="toStartOfFiveMinutes(ts)",
59
- )
60
- self.assertIsNotNone(err)
61
- self.assertIn("finer than hourly", err)
62
-
63
- def test_invalid_ten_minute_partition_key(self):
64
- err = chquery.validate_partition_key(
65
- columns=[{"name": "ts", "type": "DateTime"}],
66
- partition_key="toStartOfTenMinutes(ts)",
67
- )
68
- self.assertIsNotNone(err)
69
- self.assertIn("finer than hourly", err)
70
-
71
- def test_invalid_fifteen_minute_partition_key(self):
72
- err = chquery.validate_partition_key(
73
- columns=[{"name": "ts", "type": "DateTime"}],
74
- partition_key="toStartOfFifteenMinutes(ts)",
75
- )
76
- self.assertIsNotNone(err)
77
- self.assertIn("finer than hourly", err)
78
-
79
- def test_invalid_five_minute_singular_alias_partition_key(self):
80
- # toStartOfFiveMinute (singular) is a registered alias for toStartOfFiveMinutes.
81
- err = chquery.validate_partition_key(
82
- columns=[{"name": "ts", "type": "DateTime"}],
83
- partition_key="toStartOfFiveMinute(ts)",
84
- )
85
- self.assertIsNotNone(err)
86
- self.assertIn("finer than hourly", err)
87
-
88
- def test_invalid_millisecond_partition_key(self):
89
- err = chquery.validate_partition_key(
90
- columns=[{"name": "ts", "type": "DateTime64(3)"}],
91
- partition_key="toStartOfMillisecond(ts)",
92
- )
93
- self.assertIsNotNone(err)
94
- self.assertIn("finer than hourly", err)
95
-
96
- def test_invalid_microsecond_partition_key(self):
97
- err = chquery.validate_partition_key(
98
- columns=[{"name": "ts", "type": "DateTime64(6)"}],
99
- partition_key="toStartOfMicrosecond(ts)",
100
- )
101
- self.assertIsNotNone(err)
102
- self.assertIn("finer than hourly", err)
103
-
104
- def test_invalid_nanosecond_partition_key(self):
105
- err = chquery.validate_partition_key(
106
- columns=[{"name": "ts", "type": "DateTime64(9)"}],
107
- partition_key="toStartOfNanosecond(ts)",
108
- )
109
- self.assertIsNotNone(err)
110
- self.assertIn("finer than hourly", err)
111
-
112
- def test_invalid_yyyymmddhhmmss_partition_key(self):
113
- # Packs the full date+time down to the second - no coarsening at all.
114
- err = chquery.validate_partition_key(
115
- columns=[{"name": "ts", "type": "DateTime"}],
116
- partition_key="toYYYYMMDDhhmmss(ts)",
117
- )
118
- self.assertIsNotNone(err)
119
- self.assertIn("finer than hourly", err)
120
-
121
- def test_valid_skipped_for_composite_partition_key(self):
122
- self.assertIsNone(
123
- chquery.validate_partition_key(
124
- columns=[
125
- {"name": "ts", "type": "DateTime"},
126
- {"name": "k", "type": "String"},
127
- ],
128
- partition_key="toStartOfMinute(ts), k",
129
- )
130
- )
131
-
132
- def test_valid_skipped_for_unrecognized_function(self):
133
- self.assertIsNone(
134
- chquery.validate_partition_key(
135
- columns=[{"name": "ts", "type": "DateTime"}],
136
- partition_key="intDiv(toUInt32(ts), 60)",
137
- )
138
- )
139
-
140
- def test_valid_skipped_for_bare_column(self):
141
- self.assertIsNone(
142
- chquery.validate_partition_key(
143
- columns=[{"name": "k", "type": "String"}],
144
- partition_key="k",
145
- )
146
- )
147
-
148
-
149
- if __name__ == "__main__":
150
- unittest.main()