clickhouse-driver 0.2.10__cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.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.
Files changed (89) hide show
  1. clickhouse_driver/__init__.py +9 -0
  2. clickhouse_driver/block.py +227 -0
  3. clickhouse_driver/blockstreamprofileinfo.py +22 -0
  4. clickhouse_driver/bufferedreader.cpython-310-aarch64-linux-gnu.so +0 -0
  5. clickhouse_driver/bufferedwriter.cpython-310-aarch64-linux-gnu.so +0 -0
  6. clickhouse_driver/client.py +812 -0
  7. clickhouse_driver/clientinfo.py +119 -0
  8. clickhouse_driver/columns/__init__.py +0 -0
  9. clickhouse_driver/columns/arraycolumn.py +161 -0
  10. clickhouse_driver/columns/base.py +221 -0
  11. clickhouse_driver/columns/boolcolumn.py +7 -0
  12. clickhouse_driver/columns/datecolumn.py +108 -0
  13. clickhouse_driver/columns/datetimecolumn.py +203 -0
  14. clickhouse_driver/columns/decimalcolumn.py +116 -0
  15. clickhouse_driver/columns/enumcolumn.py +129 -0
  16. clickhouse_driver/columns/exceptions.py +12 -0
  17. clickhouse_driver/columns/floatcolumn.py +34 -0
  18. clickhouse_driver/columns/intcolumn.py +157 -0
  19. clickhouse_driver/columns/intervalcolumn.py +33 -0
  20. clickhouse_driver/columns/ipcolumn.py +118 -0
  21. clickhouse_driver/columns/jsoncolumn.py +37 -0
  22. clickhouse_driver/columns/largeint.cpython-310-aarch64-linux-gnu.so +0 -0
  23. clickhouse_driver/columns/lowcardinalitycolumn.py +142 -0
  24. clickhouse_driver/columns/mapcolumn.py +73 -0
  25. clickhouse_driver/columns/nestedcolumn.py +10 -0
  26. clickhouse_driver/columns/nothingcolumn.py +13 -0
  27. clickhouse_driver/columns/nullablecolumn.py +7 -0
  28. clickhouse_driver/columns/nullcolumn.py +15 -0
  29. clickhouse_driver/columns/numpy/__init__.py +0 -0
  30. clickhouse_driver/columns/numpy/base.py +47 -0
  31. clickhouse_driver/columns/numpy/boolcolumn.py +8 -0
  32. clickhouse_driver/columns/numpy/datecolumn.py +19 -0
  33. clickhouse_driver/columns/numpy/datetimecolumn.py +146 -0
  34. clickhouse_driver/columns/numpy/floatcolumn.py +24 -0
  35. clickhouse_driver/columns/numpy/intcolumn.py +43 -0
  36. clickhouse_driver/columns/numpy/lowcardinalitycolumn.py +96 -0
  37. clickhouse_driver/columns/numpy/service.py +58 -0
  38. clickhouse_driver/columns/numpy/stringcolumn.py +78 -0
  39. clickhouse_driver/columns/numpy/tuplecolumn.py +37 -0
  40. clickhouse_driver/columns/service.py +185 -0
  41. clickhouse_driver/columns/simpleaggregatefunctioncolumn.py +7 -0
  42. clickhouse_driver/columns/stringcolumn.py +73 -0
  43. clickhouse_driver/columns/tuplecolumn.py +63 -0
  44. clickhouse_driver/columns/util.py +61 -0
  45. clickhouse_driver/columns/uuidcolumn.py +64 -0
  46. clickhouse_driver/compression/__init__.py +32 -0
  47. clickhouse_driver/compression/base.py +87 -0
  48. clickhouse_driver/compression/lz4.py +21 -0
  49. clickhouse_driver/compression/lz4hc.py +9 -0
  50. clickhouse_driver/compression/zstd.py +20 -0
  51. clickhouse_driver/connection.py +825 -0
  52. clickhouse_driver/context.py +36 -0
  53. clickhouse_driver/dbapi/__init__.py +62 -0
  54. clickhouse_driver/dbapi/connection.py +99 -0
  55. clickhouse_driver/dbapi/cursor.py +370 -0
  56. clickhouse_driver/dbapi/errors.py +40 -0
  57. clickhouse_driver/dbapi/extras.py +73 -0
  58. clickhouse_driver/defines.py +58 -0
  59. clickhouse_driver/errors.py +453 -0
  60. clickhouse_driver/log.py +48 -0
  61. clickhouse_driver/numpy/__init__.py +0 -0
  62. clickhouse_driver/numpy/block.py +8 -0
  63. clickhouse_driver/numpy/helpers.py +28 -0
  64. clickhouse_driver/numpy/result.py +123 -0
  65. clickhouse_driver/opentelemetry.py +43 -0
  66. clickhouse_driver/progress.py +44 -0
  67. clickhouse_driver/protocol.py +130 -0
  68. clickhouse_driver/queryprocessingstage.py +8 -0
  69. clickhouse_driver/reader.py +69 -0
  70. clickhouse_driver/readhelpers.py +26 -0
  71. clickhouse_driver/result.py +144 -0
  72. clickhouse_driver/settings/__init__.py +0 -0
  73. clickhouse_driver/settings/available.py +405 -0
  74. clickhouse_driver/settings/types.py +50 -0
  75. clickhouse_driver/settings/writer.py +34 -0
  76. clickhouse_driver/streams/__init__.py +0 -0
  77. clickhouse_driver/streams/compressed.py +88 -0
  78. clickhouse_driver/streams/native.py +108 -0
  79. clickhouse_driver/util/__init__.py +0 -0
  80. clickhouse_driver/util/compat.py +39 -0
  81. clickhouse_driver/util/escape.py +94 -0
  82. clickhouse_driver/util/helpers.py +173 -0
  83. clickhouse_driver/varint.cpython-310-aarch64-linux-gnu.so +0 -0
  84. clickhouse_driver/writer.py +67 -0
  85. clickhouse_driver-0.2.10.dist-info/METADATA +215 -0
  86. clickhouse_driver-0.2.10.dist-info/RECORD +89 -0
  87. clickhouse_driver-0.2.10.dist-info/WHEEL +7 -0
  88. clickhouse_driver-0.2.10.dist-info/licenses/LICENSE +21 -0
  89. clickhouse_driver-0.2.10.dist-info/top_level.txt +1 -0
@@ -0,0 +1,405 @@
1
+ from .types import (
2
+ SettingUInt64, SettingBool, SettingFloat, SettingString, SettingMaxThreads,
3
+ SettingChar
4
+ )
5
+
6
+ SettingInt64 = SettingUInt64
7
+
8
+ # Seconds and milliseconds should be set as ints.
9
+ SettingSeconds = SettingMilliseconds = SettingUInt64
10
+
11
+ # Server cares about possible choices validation.
12
+ # See https://github.com/yandex/ClickHouse/blob/master/dbms/src/
13
+ # Interpreters/Settings.h for all choices.
14
+ SettingLoadBalancing = SettingTotalsMode = SettingCompressionMethod = \
15
+ SettingDistributedProductMode = SettingGlobalSubqueriesMethod = \
16
+ SettingDateTimeInputFormat = \
17
+ SettingURI = \
18
+ SettingJoinAlgorithm = \
19
+ SettingSpecialSort = \
20
+ SettingLogQueriesType = \
21
+ SettingDefaultDatabaseEngine = \
22
+ SettingString
23
+
24
+ settings = {
25
+ # Settings
26
+ 'min_compress_block_size': SettingUInt64,
27
+ 'max_compress_block_size': SettingUInt64,
28
+ 'max_block_size': SettingUInt64,
29
+ 'max_insert_block_size': SettingUInt64,
30
+ 'min_insert_block_size_rows': SettingUInt64,
31
+ 'min_insert_block_size_bytes': SettingUInt64,
32
+ 'max_partitions_per_insert_block': SettingUInt64,
33
+ 'max_threads': SettingMaxThreads,
34
+ 'max_alter_threads': SettingMaxThreads,
35
+ 'max_read_buffer_size': SettingUInt64,
36
+ 'max_distributed_connections': SettingUInt64,
37
+ 'max_query_size': SettingUInt64,
38
+ 'interactive_delay': SettingUInt64,
39
+ 'connect_timeout': SettingSeconds,
40
+ 'connect_timeout_with_failover_ms': SettingMilliseconds,
41
+ 'receive_timeout': SettingSeconds,
42
+ 'send_timeout': SettingSeconds,
43
+ 'queue_max_wait_ms': SettingMilliseconds,
44
+ 'poll_interval': SettingUInt64,
45
+ 'distributed_connections_pool_size': SettingUInt64,
46
+ 'connections_with_failover_max_tries': SettingUInt64,
47
+ 'extremes': SettingBool,
48
+ 'use_uncompressed_cache': SettingBool,
49
+ 'replace_running_query': SettingBool,
50
+ 'background_pool_size': SettingUInt64,
51
+ 'background_schedule_pool_size': SettingUInt64,
52
+
53
+ 'distributed_directory_monitor_sleep_time_ms': SettingMilliseconds,
54
+
55
+ 'distributed_directory_monitor_batch_inserts': SettingBool,
56
+ 'distributed_directory_monitor_max_sleep_time_ms': SettingMilliseconds,
57
+
58
+ 'optimize_move_to_prewhere': SettingBool,
59
+ 'optimize_skip_unused_shards': SettingBool,
60
+ 'optimize_read_in_order': SettingBool,
61
+ 'optimize_min_equality_disjunction_chain_length': SettingUInt64,
62
+ 'enable_optimize_predicate_expression': SettingBool,
63
+
64
+ 'replication_alter_partitions_sync': SettingUInt64,
65
+ 'replication_alter_columns_timeout': SettingUInt64,
66
+
67
+ 'load_balancing': SettingLoadBalancing,
68
+
69
+ 'totals_mode': SettingTotalsMode,
70
+ 'totals_auto_threshold': SettingFloat,
71
+
72
+ 'compile': SettingBool,
73
+ 'compile_expressions': SettingBool,
74
+ 'min_count_to_compile': SettingUInt64,
75
+ 'group_by_two_level_threshold': SettingUInt64,
76
+ 'group_by_two_level_threshold_bytes': SettingUInt64,
77
+ 'distributed_aggregation_memory_efficient': SettingBool,
78
+ 'aggregation_memory_efficient_merge_threads': SettingUInt64,
79
+
80
+ 'max_parallel_replicas': SettingUInt64,
81
+ 'parallel_replicas_count': SettingUInt64,
82
+ 'parallel_replica_offset': SettingUInt64,
83
+
84
+ 'skip_unavailable_shards': SettingBool,
85
+
86
+ 'distributed_group_by_no_merge': SettingBool,
87
+
88
+ 'merge_tree_min_rows_for_concurrent_read': SettingUInt64,
89
+ 'merge_tree_min_rows_for_seek': SettingUInt64,
90
+ 'merge_tree_coarse_index_granularity': SettingUInt64,
91
+ 'merge_tree_max_rows_to_use_cache': SettingUInt64,
92
+ 'merge_tree_min_bytes_for_concurrent_read': SettingUInt64,
93
+ 'merge_tree_min_bytes_for_seek': SettingUInt64,
94
+ 'merge_tree_max_bytes_to_use_cache': SettingUInt64,
95
+ 'merge_tree_uniform_read_distribution': SettingBool,
96
+
97
+ 'mysql_max_rows_to_insert': SettingUInt64,
98
+
99
+ 'min_bytes_to_use_direct_io': SettingUInt64,
100
+
101
+ 'force_index_by_date': SettingBool,
102
+ 'force_primary_key': SettingBool,
103
+
104
+ 'mark_cache_min_lifetime': SettingUInt64,
105
+
106
+ 'max_streams_to_max_threads_ratio': SettingFloat,
107
+
108
+ 'network_compression_method': SettingCompressionMethod,
109
+
110
+ 'network_zstd_compression_level': SettingInt64,
111
+
112
+ 'priority': SettingUInt64,
113
+
114
+ 'log_queries': SettingBool,
115
+ 'log_queries_cut_to_length': SettingUInt64,
116
+ 'query_profiler_real_time_period_ns': SettingUInt64,
117
+ 'query_profiler_cpu_time_period_ns': SettingUInt64,
118
+ 'enable_debug_queries': SettingBool,
119
+
120
+ 'distributed_product_mode': SettingDistributedProductMode,
121
+
122
+ 'max_concurrent_queries_for_user': SettingUInt64,
123
+
124
+ 'insert_deduplicate': SettingBool,
125
+
126
+ 'insert_quorum': SettingUInt64,
127
+ 'insert_quorum_timeout': SettingMilliseconds,
128
+ 'select_sequential_consistency': SettingUInt64,
129
+ 'table_function_remote_max_addresses': SettingUInt64,
130
+ 'read_backoff_min_latency_ms': SettingMilliseconds,
131
+ 'read_backoff_max_throughput': SettingUInt64,
132
+ 'read_backoff_min_interval_between_events_ms': SettingMilliseconds,
133
+ 'read_backoff_min_events': SettingUInt64,
134
+
135
+ 'memory_tracker_fault_probability': SettingFloat,
136
+
137
+ 'enable_http_compression': SettingBool,
138
+ 'http_zlib_compression_level': SettingInt64,
139
+
140
+ 'http_native_compression_disable_checksumming_on_decompress': SettingBool,
141
+
142
+ 'count_distinct_implementation': SettingString,
143
+
144
+ 'add_http_cors_header': SettingBool,
145
+
146
+ 'input_format_skip_unknown_fields': SettingBool,
147
+ 'input_format_import_nested_json': SettingBool,
148
+ 'input_format_values_interpret_expressions': SettingBool,
149
+ 'input_format_with_names_use_header': SettingBool,
150
+ 'input_format_defaults_for_omitted_fields': SettingBool,
151
+ 'input_format_null_as_default': SettingBool,
152
+ 'input_format_values_deduce_templates_of_expressions': SettingBool,
153
+ 'input_format_values_accurate_types_of_literals': SettingBool,
154
+ 'input_format_allow_errors_num': SettingUInt64,
155
+ 'input_format_allow_errors_ratio': SettingFloat,
156
+ 'input_format_csv_unquoted_null_literal_as_null': SettingBool,
157
+
158
+ 'output_format_write_statistics': SettingBool,
159
+ 'output_format_json_quote_64bit_integers': SettingBool,
160
+ 'output_format_json_quote_denormals': SettingBool,
161
+ 'output_format_json_escape_forward_slashes': SettingBool,
162
+ 'output_format_pretty_max_rows': SettingUInt64,
163
+ 'output_format_pretty_max_column_pad_width': SettingUInt64,
164
+ 'output_format_pretty_color': SettingBool,
165
+ 'output_format_parquet_row_group_size': SettingUInt64,
166
+
167
+ 'use_client_time_zone': SettingBool,
168
+
169
+ 'send_progress_in_http_headers': SettingBool,
170
+
171
+ 'http_headers_progress_interval_ms': SettingUInt64,
172
+
173
+ 'fsync_metadata': SettingBool,
174
+
175
+ 'join_use_nulls': SettingBool,
176
+ 'join_default_strictness': SettingString,
177
+ 'preferred_block_size_bytes': SettingUInt64,
178
+
179
+ 'max_replica_delay_for_distributed_queries': SettingUInt64,
180
+ 'fallback_to_stale_replicas_for_distributed_queries': SettingBool,
181
+ 'preferred_max_column_in_block_size_bytes': SettingUInt64,
182
+
183
+ 'insert_distributed_sync': SettingBool,
184
+ 'insert_distributed_timeout': SettingUInt64,
185
+ 'distributed_ddl_task_timeout': SettingInt64,
186
+ 'stream_flush_interval_ms': SettingMilliseconds,
187
+ 'format_schema': SettingString,
188
+ 'insert_allow_materialized_columns': SettingBool,
189
+ 'http_connection_timeout': SettingSeconds,
190
+ 'http_send_timeout': SettingSeconds,
191
+ 'http_receive_timeout': SettingSeconds,
192
+ 'optimize_throw_if_noop': SettingBool,
193
+ 'use_index_for_in_with_subqueries': SettingBool,
194
+ 'empty_result_for_aggregation_by_empty_set': SettingBool,
195
+ 'allow_distributed_ddl': SettingBool,
196
+ 'odbc_max_field_size': SettingUInt64,
197
+
198
+ # Limits
199
+ 'max_rows_to_read': SettingUInt64,
200
+ 'max_bytes_to_read': SettingUInt64,
201
+ 'read_overflow_mode': SettingString,
202
+
203
+ 'max_rows_to_group_by': SettingUInt64,
204
+ 'group_by_overflow_mode': SettingString,
205
+ 'max_bytes_before_external_group_by': SettingUInt64,
206
+
207
+ 'max_rows_to_sort': SettingUInt64,
208
+ 'max_bytes_to_sort': SettingUInt64,
209
+ 'sort_overflow_mode': SettingString,
210
+ 'max_bytes_before_external_sort': SettingUInt64,
211
+ 'max_bytes_before_remerge_sort': SettingUInt64,
212
+ 'max_result_rows': SettingUInt64,
213
+ 'max_result_bytes': SettingUInt64,
214
+ 'result_overflow_mode': SettingString,
215
+
216
+ 'max_execution_time': SettingSeconds,
217
+ 'timeout_overflow_mode': SettingString,
218
+
219
+ 'min_execution_speed': SettingUInt64,
220
+ 'timeout_before_checking_execution_speed': SettingSeconds,
221
+
222
+ 'max_columns_to_read': SettingUInt64,
223
+ 'max_temporary_columns': SettingUInt64,
224
+ 'max_temporary_non_const_columns': SettingUInt64,
225
+
226
+ 'max_subquery_depth': SettingUInt64,
227
+ 'max_pipeline_depth': SettingUInt64,
228
+ 'max_ast_depth': SettingUInt64,
229
+ 'max_ast_elements': SettingUInt64,
230
+ 'max_expanded_ast_elements': SettingUInt64,
231
+
232
+ 'readonly': SettingUInt64,
233
+
234
+ 'max_rows_in_set': SettingUInt64,
235
+ 'max_bytes_in_set': SettingUInt64,
236
+ 'set_overflow_mode': SettingString,
237
+
238
+ 'max_rows_in_join': SettingUInt64,
239
+ 'max_bytes_in_join': SettingUInt64,
240
+ 'join_overflow_mode': SettingString,
241
+
242
+ 'max_rows_to_transfer': SettingUInt64,
243
+ 'max_bytes_to_transfer': SettingUInt64,
244
+ 'transfer_overflow_mode': SettingString,
245
+
246
+ 'max_rows_in_distinct': SettingUInt64,
247
+ 'max_bytes_in_distinct': SettingUInt64,
248
+ 'distinct_overflow_mode': SettingString,
249
+
250
+ 'max_memory_usage': SettingUInt64,
251
+ 'max_memory_usage_for_user': SettingUInt64,
252
+ 'max_memory_usage_for_all_queries': SettingUInt64,
253
+
254
+ 'max_network_bandwidth': SettingUInt64,
255
+ 'max_network_bytes': SettingUInt64,
256
+ 'max_network_bandwidth_for_user': SettingUInt64,
257
+ 'max_network_bandwidth_for_all_users': SettingUInt64,
258
+
259
+ 'max_streams_multiplier_for_merge_tables': SettingFloat,
260
+ 'max_http_get_redirects': SettingUInt64,
261
+ 'max_execution_speed': SettingUInt64,
262
+ 'max_execution_speed_bytes': SettingUInt64,
263
+
264
+ 'format_csv_delimiter': SettingChar,
265
+ 'format_csv_allow_single_quotes': SettingBool,
266
+ 'format_csv_allow_double_quotes': SettingBool,
267
+
268
+ 'format_template_resultset': SettingString,
269
+ 'format_template_row': SettingString,
270
+ 'format_template_rows_between_delimiter': SettingString,
271
+ 'format_custom_escaping_rule': SettingString,
272
+ 'format_custom_field_delimiter': SettingString,
273
+ 'format_custom_row_before_delimiter': SettingString,
274
+ 'format_custom_row_after_delimiter': SettingString,
275
+ 'format_custom_row_between_delimiter': SettingString,
276
+ 'format_custom_result_before_delimiter': SettingString,
277
+ 'format_custom_result_after_delimiter': SettingString,
278
+
279
+ 'enable_conditional_computation': SettingUInt64,
280
+
281
+ 'date_time_input_format': SettingDateTimeInputFormat,
282
+ 'log_profile_events': SettingBool,
283
+ 'log_query_settings': SettingBool,
284
+ 'log_query_threads': SettingBool,
285
+ 'send_logs_level': SettingString,
286
+ 'low_cardinality_max_dictionary_size': SettingUInt64,
287
+ 'low_cardinality_use_single_dictionary_for_part': SettingBool,
288
+ 'decimal_check_overflow': SettingBool,
289
+ 'prefer_localhost_replica': SettingBool,
290
+ 'max_fetch_partition_retries_count': SettingUInt64,
291
+ 'asterisk_left_columns_only': SettingBool,
292
+ 'http_max_multipart_form_data_size': SettingUInt64,
293
+ 'calculate_text_stack_trace': SettingBool,
294
+ 'parallel_view_processing': SettingBool,
295
+
296
+ 'allow_experimental_low_cardinality_type': SettingBool,
297
+ 'allow_experimental_decimal_type': SettingBool,
298
+ 'allow_suspicious_low_cardinality_types': SettingBool,
299
+ 'allow_experimental_multiple_joins_emulation': SettingBool,
300
+ 'allow_experimental_cross_to_join_conversion': SettingBool,
301
+ 'allow_experimental_data_skipping_indices': SettingBool,
302
+ 'allow_hyperscan': SettingBool,
303
+ 'allow_simdjson': SettingBool,
304
+ 'allow_introspection_functions': SettingBool,
305
+ 'allow_drop_detached': SettingBool,
306
+ 'allow_experimental_live_view': SettingBool,
307
+ 'allow_ddl': SettingBool,
308
+
309
+ 'partial_merge_join': SettingBool,
310
+ 'partial_merge_join_optimizations': SettingBool,
311
+ 'partial_merge_join_rows_in_right_blocks': SettingUInt64,
312
+ 'partial_merge_join_rows_in_left_blocks': SettingFloat,
313
+
314
+ 'distributed_replica_error_half_life': SettingSeconds,
315
+ 'distributed_replica_error_cap': SettingUInt64,
316
+
317
+ 'min_free_disk_space_for_temporary_data': SettingUInt64,
318
+ 'tcp_keep_alive_timeout': SettingSeconds,
319
+ 'connection_pool_max_wait_ms': SettingMilliseconds,
320
+ 'kafka_max_wait_ms': SettingMilliseconds,
321
+ 'idle_connection_timeout': SettingUInt64,
322
+ 's3_min_upload_part_size': SettingUInt64,
323
+ 'any_join_distinct_right_table_keys': SettingBool,
324
+ 'join_any_take_last_row': SettingBool,
325
+ 'stream_poll_timeout_ms': SettingMilliseconds,
326
+ 'joined_subquery_requires_alias': SettingBool,
327
+ 'enable_unaligned_array_join': SettingBool,
328
+ 'low_cardinality_allow_in_native_format': SettingBool,
329
+ 'external_table_functions_use_nulls': SettingBool,
330
+ 'experimental_use_processors': SettingBool,
331
+ 'check_query_single_value_result': SettingBool,
332
+ 'live_view_heartbeat_interval': SettingSeconds,
333
+ 'temporary_live_view_timeout': SettingSeconds,
334
+ 'max_live_view_insert_blocks_before_refresh': SettingUInt64,
335
+
336
+ 'max_insert_threads': SettingUInt64,
337
+ 'replace_running_query_max_wait_ms': SettingMilliseconds,
338
+ 'background_move_pool_size': SettingUInt64,
339
+ 'min_count_to_compile_expression': SettingUInt64,
340
+ 'force_optimize_skip_unused_shards': SettingUInt64,
341
+ 'input_format_parallel_parsing': SettingBool,
342
+ 'min_chunk_bytes_for_parallel_parsing': SettingUInt64,
343
+ 'min_bytes_to_use_mmap_io': SettingUInt64,
344
+ 'os_thread_priority': SettingInt64,
345
+ 'input_format_tsv_empty_as_default': SettingBool,
346
+ 'input_format_avro_schema_registry_url': SettingString,
347
+ 'output_format_avro_codec': SettingString,
348
+ 'output_format_avro_sync_interval': SettingUInt64,
349
+ 'min_execution_speed_bytes': SettingUInt64,
350
+ 'default_max_bytes_in_join': SettingUInt64,
351
+ 'enable_optimize_predicate_expression_to_final_subquery': SettingBool,
352
+ 'cancel_http_readonly_queries_on_client_close': SettingBool,
353
+ 'enable_scalar_subquery_optimization': SettingBool,
354
+ 'optimize_trivial_count_query': SettingBool,
355
+ 'mutations_sync': SettingUInt64,
356
+ 'optimize_if_chain_to_miltiif': SettingBool,
357
+ 'max_parser_depth': SettingUInt64,
358
+
359
+ 'max_joined_block_size_rows': SettingUInt64,
360
+ 'connect_timeout_with_failover_secure_ms': SettingMilliseconds,
361
+ 'parallel_distributed_insert_select': SettingBool,
362
+ 'force_optimize_skip_unused_shards_no_nested': SettingBool,
363
+ 'format_avro_schema_registry_url': SettingURI,
364
+ 'output_format_tsv_crlf_end_of_line': SettingBool,
365
+ 'join_algorithm': SettingJoinAlgorithm,
366
+ 'memory_profiler_step': SettingUInt64,
367
+ 'output_format_csv_crlf_end_of_line': SettingBool,
368
+ 'allow_experimental_alter_materialized_view_structure': SettingBool,
369
+ 'enable_early_constant_folding': SettingBool,
370
+ 'deduplicate_blocks_in_dependent_materialized_views': SettingBool,
371
+ 'use_compact_format_in_distributed_parts_names': SettingBool,
372
+ 'multiple_joins_rewriter_version': SettingUInt64,
373
+
374
+ 'min_insert_block_size_rows_for_materialized_views': SettingUInt64,
375
+ 'min_insert_block_size_bytes_for_materialized_views': SettingUInt64,
376
+ 'max_final_threads': SettingUInt64,
377
+ 'background_buffer_flush_schedule_pool_size': SettingUInt64,
378
+ 'background_distributed_schedule_pool_size': SettingUInt64,
379
+ 'special_sort': SettingSpecialSort,
380
+ 'optimize_distributed_group_by_sharding_key': SettingBool,
381
+ 'log_queries_min_type': SettingLogQueriesType,
382
+ 'allow_suspicious_codecs': SettingBool,
383
+ 'metrics_perf_events_enabled': SettingBool,
384
+ 'metrics_perf_events_list': SettingString,
385
+ 'join_on_disk_max_files_to_merge': SettingUInt64,
386
+ 'temporary_files_codec': SettingString,
387
+ 'max_untracked_memory': SettingUInt64,
388
+ 'memory_profiler_sample_probability': SettingFloat,
389
+ 'optimize_aggregation_in_order': SettingBool,
390
+ 'default_database_engine': SettingDefaultDatabaseEngine,
391
+ 'allow_experimental_database_atomic': SettingBool,
392
+ 'show_table_uuid_in_table_create_query_if_not_nil': SettingBool,
393
+ 'optimize_arithmetic_operations_in_aggregate_functions': SettingBool,
394
+ 'validate_polygons': SettingBool,
395
+ 'transform_null_in': SettingBool,
396
+ 'allow_nondeterministic_mutations': SettingBool,
397
+ 'lock_acquire_timeout': SettingSeconds,
398
+ 'materialize_ttl_after_modify': SettingBool,
399
+ 'allow_experimental_geo_types': SettingBool,
400
+ 'output_format_pretty_max_value_width': SettingUInt64,
401
+ 'format_regexp': SettingString,
402
+ 'format_regexp_escaping_rule': SettingString,
403
+ 'format_regexp_skip_unmatched': SettingBool,
404
+ 'output_format_enable_streaming': SettingBool,
405
+ }
@@ -0,0 +1,50 @@
1
+ from ..util.helpers import asbool
2
+ from ..varint import write_varint
3
+ from ..writer import write_binary_str
4
+
5
+
6
+ class SettingType(object):
7
+ @classmethod
8
+ def write(cls, value, buf):
9
+ raise NotImplementedError
10
+
11
+
12
+ class SettingUInt64(SettingType):
13
+ @classmethod
14
+ def write(cls, value, buf):
15
+ write_varint(int(value), buf)
16
+
17
+
18
+ class SettingBool(SettingType):
19
+ @classmethod
20
+ def write(cls, value, buf):
21
+ write_varint(asbool(value), buf)
22
+
23
+
24
+ class SettingString(SettingType):
25
+ @classmethod
26
+ def write(cls, value, buf):
27
+ write_binary_str(value, buf)
28
+
29
+
30
+ class SettingChar(SettingType):
31
+ @classmethod
32
+ def write(cls, value, buf):
33
+ write_binary_str(value[0], buf)
34
+
35
+
36
+ class SettingFloat(SettingType):
37
+ @classmethod
38
+ def write(cls, value, buf):
39
+ """
40
+ Float is written in string representation.
41
+ """
42
+ write_binary_str(str(value), buf)
43
+
44
+
45
+ class SettingMaxThreads(SettingUInt64):
46
+ @classmethod
47
+ def write(cls, value, buf):
48
+ if value == 'auto':
49
+ value = 0
50
+ super(SettingMaxThreads, cls).write(value, buf)
@@ -0,0 +1,34 @@
1
+ import logging
2
+
3
+ from ..writer import write_binary_str, write_binary_uint8
4
+ from .available import settings as available_settings
5
+
6
+
7
+ logger = logging.getLogger(__name__)
8
+
9
+
10
+ class SettingsFlags:
11
+ IMPORTANT = 0x1
12
+ CUSTOM = 0x2
13
+
14
+
15
+ def write_settings(settings, buf, settings_as_strings, flags):
16
+ for setting, value in (settings or {}).items():
17
+ # If the server support settings as string we do not need to know
18
+ # anything about them, so we can write any setting.
19
+ if settings_as_strings:
20
+ write_binary_str(setting, buf)
21
+ write_binary_uint8(flags, buf)
22
+ write_binary_str(str(value), buf)
23
+
24
+ else:
25
+ # If the server requires string in binary,
26
+ # then they cannot be written without type.
27
+ setting_writer = available_settings.get(setting)
28
+ if not setting_writer:
29
+ logger.warning('Unknown setting %s. Skipping', setting)
30
+ continue
31
+ write_binary_str(setting, buf)
32
+ setting_writer.write(value, buf)
33
+
34
+ write_binary_str('', buf) # end of settings
File without changes
@@ -0,0 +1,88 @@
1
+ from io import BytesIO
2
+
3
+ try:
4
+ from clickhouse_cityhash.cityhash import CityHash128
5
+ except ImportError:
6
+ raise RuntimeError(
7
+ 'Package clickhouse-cityhash is required to use compression'
8
+ )
9
+
10
+ from .native import BlockOutputStream, BlockInputStream
11
+ from ..bufferedreader import CompressedBufferedReader
12
+ from ..bufferedwriter import CompressedBufferedWriter
13
+ from ..compression import get_decompressor_cls
14
+ from ..defines import BUFFER_SIZE
15
+ from ..reader import read_binary_uint8, read_binary_uint128
16
+ from ..writer import write_binary_uint8, write_binary_uint128
17
+
18
+
19
+ class CompressedBlockOutputStream(BlockOutputStream):
20
+ def __init__(self, compressor_cls, compress_block_size, fout, context):
21
+ self.compressor_cls = compressor_cls
22
+ self.compress_block_size = compress_block_size
23
+ self.raw_fout = fout
24
+
25
+ self.compressor = self.compressor_cls()
26
+ self.fout = CompressedBufferedWriter(self.compressor, BUFFER_SIZE)
27
+ super(CompressedBlockOutputStream, self).__init__(self.fout, context)
28
+
29
+ def get_compressed_hash(self, data):
30
+ return CityHash128(data)
31
+
32
+ def finalize(self):
33
+ self.fout.flush()
34
+
35
+ compressed = self.get_compressed()
36
+ compressed_size = len(compressed)
37
+
38
+ compressed_hash = self.get_compressed_hash(compressed)
39
+ write_binary_uint128(compressed_hash, self.raw_fout)
40
+
41
+ block_size = self.compress_block_size
42
+
43
+ i = 0
44
+ while i < compressed_size:
45
+ self.raw_fout.write(compressed[i:i + block_size])
46
+ i += block_size
47
+
48
+ self.raw_fout.flush()
49
+
50
+ def get_compressed(self):
51
+ compressed = BytesIO()
52
+
53
+ if self.compressor.method_byte is not None:
54
+ write_binary_uint8(self.compressor.method_byte, compressed)
55
+ extra_header_size = 1 # method
56
+ else:
57
+ extra_header_size = 0
58
+
59
+ data = self.compressor.get_compressed_data(extra_header_size)
60
+ compressed.write(data)
61
+
62
+ return compressed.getvalue()
63
+
64
+
65
+ class CompressedBlockInputStream(BlockInputStream):
66
+ def __init__(self, fin, context):
67
+ self.raw_fin = fin
68
+ fin = CompressedBufferedReader(self.read_block, BUFFER_SIZE)
69
+ super(CompressedBlockInputStream, self).__init__(fin, context)
70
+
71
+ def get_compressed_hash(self, data):
72
+ return CityHash128(data)
73
+
74
+ def read_block(self):
75
+ compressed_hash = read_binary_uint128(self.raw_fin)
76
+ method_byte = read_binary_uint8(self.raw_fin)
77
+
78
+ decompressor_cls = get_decompressor_cls(method_byte)
79
+ decompressor = decompressor_cls(self.raw_fin)
80
+
81
+ if decompressor.method_byte is not None:
82
+ extra_header_size = 1 # method
83
+ else:
84
+ extra_header_size = 0
85
+
86
+ return decompressor.get_decompressed_data(
87
+ method_byte, compressed_hash, extra_header_size
88
+ )
@@ -0,0 +1,108 @@
1
+ import logging
2
+
3
+ from ..block import ColumnOrientedBlock, BlockInfo
4
+ from ..columns.service import read_column, write_column
5
+ from ..reader import read_binary_str, read_binary_uint8
6
+ from ..varint import write_varint, read_varint
7
+ from ..writer import write_binary_str, write_binary_uint8
8
+ from .. import defines
9
+
10
+ logger = logging.getLogger(__name__)
11
+
12
+
13
+ class BlockOutputStream(object):
14
+ def __init__(self, fout, context):
15
+ self.fout = fout
16
+ self.context = context
17
+
18
+ super(BlockOutputStream, self).__init__()
19
+
20
+ def write(self, block):
21
+ revision = self.context.server_info.used_revision
22
+ if revision >= defines.DBMS_MIN_REVISION_WITH_BLOCK_INFO:
23
+ block.info.write(self.fout)
24
+
25
+ # We write transposed data.
26
+ n_columns = block.num_columns
27
+ n_rows = block.num_rows
28
+
29
+ write_varint(n_columns, self.fout)
30
+ write_varint(n_rows, self.fout)
31
+
32
+ for i, (col_name, col_type) in enumerate(block.columns_with_types):
33
+ write_binary_str(col_name, self.fout)
34
+ write_binary_str(col_type, self.fout)
35
+
36
+ if n_columns:
37
+ try:
38
+ items = block.get_column_by_index(i)
39
+ except IndexError:
40
+ raise ValueError('Different rows length')
41
+
42
+ if revision >= \
43
+ defines.DBMS_MIN_REVISION_WITH_CUSTOM_SERIALIZATION:
44
+ # We write always sparse data without custom serialization.
45
+ write_binary_uint8(0, self.fout)
46
+
47
+ logger.debug('Writing column %s', col_name)
48
+ write_column(self.context, col_name, col_type, items,
49
+ self.fout, types_check=block.types_check)
50
+
51
+ self.finalize()
52
+
53
+ def finalize(self):
54
+ self.fout.flush()
55
+
56
+
57
+ class BlockInputStream(object):
58
+ def __init__(self, fin, context):
59
+ self.fin = fin
60
+ self.context = context
61
+
62
+ super(BlockInputStream, self).__init__()
63
+
64
+ def read(self, use_numpy=None):
65
+ info = BlockInfo()
66
+
67
+ revision = self.context.server_info.used_revision
68
+ if revision >= defines.DBMS_MIN_REVISION_WITH_BLOCK_INFO:
69
+ info.read(self.fin)
70
+
71
+ n_columns = read_varint(self.fin)
72
+ n_rows = read_varint(self.fin)
73
+
74
+ data, names, types = [], [], []
75
+
76
+ for i in range(n_columns):
77
+ column_name = read_binary_str(self.fin)
78
+ column_type = read_binary_str(self.fin)
79
+
80
+ names.append(column_name)
81
+ types.append(column_type)
82
+
83
+ has_custom_serialization = False
84
+ if revision >= defines.DBMS_MIN_REVISION_WITH_CUSTOM_SERIALIZATION:
85
+ has_custom_serialization = bool(read_binary_uint8(self.fin))
86
+
87
+ if n_rows:
88
+ logger.debug('Reading column %s', column_name)
89
+ column = read_column(
90
+ self.context, column_type, n_rows,
91
+ self.fin, use_numpy=use_numpy,
92
+ has_custom_serialization=has_custom_serialization
93
+ )
94
+ data.append(column)
95
+
96
+ if self.context.client_settings['use_numpy']:
97
+ from ..numpy.block import NumpyColumnOrientedBlock
98
+ block_cls = NumpyColumnOrientedBlock
99
+ else:
100
+ block_cls = ColumnOrientedBlock
101
+
102
+ block = block_cls(
103
+ columns_with_types=list(zip(names, types)),
104
+ data=data,
105
+ info=info,
106
+ )
107
+
108
+ return block
File without changes